Skip to content
Snippets Groups Projects
Commit 203ed3cf authored by Gregory Szorc's avatar Gregory Szorc
Browse files

run-tests: define custom result and runner classes for unittest

We need to teach unittest about some custom result types. This will
require some custom classes. This patch creates a skeleton for them.
parent 3df2ecf8
No related branches found
No related tags found
No related merge requests found
......@@ -982,6 +982,19 @@
iolock = threading.Lock()
class TestResult(unittest._TextTestResult):
"""Holds results when executing via unittest."""
# Don't worry too much about accessing the non-public _TextTestResult.
# It is relatively common in Python testing tools.
def __init__(self, *args, **kwargs):
super(TestResult, self).__init__(*args, **kwargs)
class TextTestRunner(unittest.TextTestRunner):
"""Custom unittest test runner that uses appropriate settings."""
def _makeResult(self):
return TestResult(self.stream, self.descriptions, self.verbosity)
class TestRunner(object):
"""Holds context for executing tests.
......@@ -1191,7 +1204,7 @@
verbosity = 1
if self.options.verbose:
verbosity = 2
runner = unittest.TextTestRunner(verbosity=verbosity)
runner = TextTestRunner(verbosity=verbosity)
runner.run(suite)
else:
self._executetests(tests)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment