Commit 5cd81507 authored by zhifan huang's avatar zhifan huang

add test runner

parent 68ded13f
...@@ -81,7 +81,7 @@ setup( ...@@ -81,7 +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=tests.test_registry:main' 're6st-testrunner=tests.runner:main'
], ],
}, },
package_data = { package_data = {
......
import sys
import os
import unittest
import time
import json
from .test_registry import TestRegistrtServer
class TestResult(unittest.TextTestResult):
def startTestRun(self):
self.start = time.time()
def stopTestRun(self):
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 = "%.2fs" % (self.end - self.start)
)
class runner(unittest.TextTestRunner):
def _makeResult(self):
return TestResult(self.stream, self.descriptions, self.verbosity)
def main():
test_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(test_dir)
suite = unittest.TestSuite()
for method in dir(TestRegistrtServer):
if method.startswith("test"):
suite.addTest(TestRegistrtServer(method))
result = runner().run(suite)
print json.dumps(result.report)
if __name__ == "__main__":
main()
\ No newline at end of file
...@@ -506,7 +506,7 @@ def main(): ...@@ -506,7 +506,7 @@ def main():
for method in dir(TestRegistrtServer): for method in dir(TestRegistrtServer):
if method.startswith("test"): if method.startswith("test"):
suite.addTest(TestRegistrtServer(method)) suite.addTest(TestRegistrtServer(method))
unittest.TextTestRunner().run(suite) result = unittest.TextTestRunner().run(suite)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment