diff options
author | Sascha Silbe <sascha@silbe.org> | 2009-11-08 10:27:01 (GMT) |
---|---|---|
committer | Sascha Silbe <sascha@silbe.org> | 2009-11-08 10:27:01 (GMT) |
commit | 2b51f7da23a312c24e3dc8e47836bb93d082364f (patch) | |
tree | 158bd3e08eabd5515357d5f49d5bfeefa4eb4d98 | |
parent | eb7cfa029404bb305a542f138d5bf28cc36216bc (diff) |
print test suite descriptions
-rwxr-xr-x | tests/runalltests.py | 19 | ||||
-rw-r--r-- | tests/test_massops.py | 5 |
2 files changed, 18 insertions, 6 deletions
diff --git a/tests/runalltests.py b/tests/runalltests.py index e1a3426..2f36582 100755 --- a/tests/runalltests.py +++ b/tests/runalltests.py @@ -170,6 +170,10 @@ class TestSuiteWrapper(unittest.TestCase): finally: result.stopTest(self) + def shortDescription(self): + doc = self._wrapped_suite.__doc__ + return doc and doc.split("\n")[0].strip() or None + def tearDown(self): self._kill_data_store() self._clean_data_store() @@ -218,11 +222,15 @@ class TimedTestResult(unittest._TextTestResult): def startTest(self, test): self.start_times[test] = time.time() - if isinstance(test, TestSuiteWrapper): - unittest.TestResult.startTest(self, test) + unittest.TestResult.startTest(self, test) + if not self.showAll: return - unittest._TextTestResult.startTest(self, test) + description = self.getDescription(test) + if isinstance(test, TestSuiteWrapper): + self.stream.write('Test Suite: %s\n' % (description, )) + else: + self.stream.write(' %s ... ' % (description, )) def stopTest(self, test): if test in self.start_times and test not in self.run_times: @@ -264,8 +272,9 @@ def test_suite(tests=None): for test in tests: if test.endswith('.txt'): - suite.addTest(TestSuiteWrapper(doctest.DocFileSuite(test, - optionflags=DOCTEST_OPTIONS))) + doc_suite = doctest.DocFileSuite(test, optionflags=DOCTEST_OPTIONS) + doc_suite.__doc__ = test + suite.addTest(TestSuiteWrapper(doc_suite)) elif test.endswith('.py'): m = __import__(test[:-3]) diff --git a/tests/test_massops.py b/tests/test_massops.py index 4eb65aa..6fdf0b2 100644 --- a/tests/test_massops.py +++ b/tests/test_massops.py @@ -98,4 +98,7 @@ class MassOpsTestCase(unittest.TestCase): os.remove(filename) -suite = lambda: unittest.TestLoader().loadTestsFromTestCase(MassOpsTestCase) +def suite(): + test_suite = unittest.TestLoader().loadTestsFromTestCase(MassOpsTestCase) + test_suite.__doc__ = MassOpsTestCase.__doc__ + return test_suite |