Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
zhifan huang
re6stnet
Commits
713ef0e7
Commit
713ef0e7
authored
Feb 24, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add enter-point for unittest at setup;;add test runner script
parent
e83b20d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
re6st/tests/runner.py
re6st/tests/runner.py
+65
-0
setup.py
setup.py
+3
-0
No files found.
re6st/tests/runner.py
0 → 100644
View file @
713ef0e7
import
sys
import
os
import
unittest
import
time
from
StringIO
import
StringIO
import
json
from
re6st.tests
import
*
class
TestResult
(
unittest
.
TextTestResult
):
def
startTestRun
(
self
):
self
.
start
=
time
.
time
()
def
stopTestRun
(
self
):
""" custom report dict"""
self
.
end
=
time
.
time
()
self
.
report
=
dict
(
test_count
=
self
.
testsRun
,
error_count
=
len
(
self
.
errors
),
failure_count
=
len
(
self
.
failures
),
skip_count
=
len
(
self
.
skipped
),
duration
=
round
(
self
.
end
-
self
.
start
,
2
),
date
=
time
.
strftime
(
"%Y/%m/%d %H:%M:%S"
,
time
.
gmtime
(
self
.
start
))
)
class
runner
(
unittest
.
TextTestRunner
):
def
_makeResult
(
self
):
return
TestResult
(
self
.
stream
,
self
.
descriptions
,
self
.
verbosity
)
def
load_test
():
test_module
=
[(
name
,
mod
)
for
name
,
mod
in
globals
().
items
()
if
name
.
split
(
'_'
,
1
)[
0
]
==
'test'
]
test_case
=
{}
for
name
,
mod
in
test_module
:
if
hasattr
(
mod
,
"__all__"
):
test_module
+=
\
[(
name
+
"."
+
sub_mod
,
getattr
(
mod
,
sub_mod
))
for
sub_mod
in
mod
.
__all__
]
else
:
test_case
[
name
]
=
unittest
.
TestLoader
().
loadTestsFromModule
(
mod
)
return
test_case
def
main
():
test_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
os
.
chdir
(
test_dir
)
test_case
=
load_test
()
result
=
{}
for
case
,
suite
in
test_case
.
items
():
err
=
StringIO
()
result
[
case
]
=
runner
(
stream
=
err
,
verbosity
=
3
).
run
(
suite
).
report
sys
.
stderr
.
write
(
"
\
n
-------%s start--------
\
n
"
%
case
)
sys
.
stderr
.
write
(
err
.
getvalue
())
sys
.
stderr
.
write
(
json
.
dumps
(
result
[
case
])
+
'
\
n
'
)
sys
.
stderr
.
write
(
"
\
n
-------%s end--------
\
n
"
%
case
)
result
[
case
][
'stderr'
]
=
err
.
getvalue
()
err
.
close
()
print
json
.
dumps
(
result
)
if
__name__
==
"__main__"
:
main
()
\ No newline at end of file
setup.py
View file @
713ef0e7
...
@@ -81,6 +81,7 @@ setup(
...
@@ -81,6 +81,7 @@ setup(
're6st-conf=re6st.cli.conf:main'
,
're6st-conf=re6st.cli.conf:main'
,
're6stnet=re6st.cli.node:main'
,
're6stnet=re6st.cli.node:main'
,
're6st-registry=re6st.cli.registry:main'
,
're6st-registry=re6st.cli.registry:main'
,
're6st-testrunner=re6st.tests.runner:main'
],
],
},
},
package_data
=
{
package_data
=
{
...
@@ -94,10 +95,12 @@ setup(
...
@@ -94,10 +95,12 @@ setup(
install_requires
=
[
'pyOpenSSL >= 0.13'
,
'miniupnpc'
],
install_requires
=
[
'pyOpenSSL >= 0.13'
,
'miniupnpc'
],
extras_require
=
{
extras_require
=
{
'geoip'
:
[
'geoip2'
],
'geoip'
:
[
'geoip2'
],
'test'
:
[
'mock'
,
'pathlib2'
]
},
},
#dependency_links = [
#dependency_links = [
# "http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.7.20120714.tar.gz#egg=miniupnpc-1.7",
# "http://miniupnp.free.fr/files/download.php?file=miniupnpc-1.7.20120714.tar.gz#egg=miniupnpc-1.7",
# ],
# ],
zip_safe
=
False
,
zip_safe
=
False
,
cmdclass
=
dict
(
build_py
=
build_py
,
sdist
=
sdist
),
cmdclass
=
dict
(
build_py
=
build_py
,
sdist
=
sdist
),
test_suite
=
"tests"
,
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment