diff options
author | Jason Pellerin <jpellerin@gmail.com> | 2008-04-03 23:11:37 +0000 |
---|---|---|
committer | Jason Pellerin <jpellerin@gmail.com> | 2008-04-03 23:11:37 +0000 |
commit | 73f35bb633aebc8f0001a384c155ad0df82ad8c2 (patch) | |
tree | 93ac94bb8ec23280bdfcf91d8745d6fc07acc3d2 | |
parent | 144985067f72d3cffd17a5396b89a2016a9b2c56 (diff) | |
download | nose-73f35bb633aebc8f0001a384c155ad0df82ad8c2.tar.gz |
Applied updated patch from issue 142
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | functional_tests/doc_tests/test_issue142/errorclass_failure.rst | 21 | ||||
-rw-r--r-- | nose/result.py | 45 |
3 files changed, 38 insertions, 30 deletions
@@ -17,6 +17,8 @@ - Fixed bugs in handling of config files and config file options for plugins excluded by a RestrictedPluginManager. Thanks to John J Lee and Philip Jenvey for the bug reports and patches (#158, #166). +- Updated ErrorClass exception reporting to be shorter and more clear. Thanks + to John J Lee for the patch (#142). 0.10.1 diff --git a/functional_tests/doc_tests/test_issue142/errorclass_failure.rst b/functional_tests/doc_tests/test_issue142/errorclass_failure.rst index cc7ce3a..4ec8cfa 100644 --- a/functional_tests/doc_tests/test_issue142/errorclass_failure.rst +++ b/functional_tests/doc_tests/test_issue142/errorclass_failure.rst @@ -21,7 +21,7 @@ represent test failures. >>> misc_test = os.path.join(support, 'errorclass_tests.py') nose.plugins.errorclass.ErrorClass has an argument isfailure . With a -true isfailure, when the errorclass' exception is caught by nose, +true isfailure, when the errorclass' exception is raised by a test, tracebacks are printed. >>> run(argv=["nosetests", "-v", "--with-todo", todo_test], @@ -61,8 +61,9 @@ Also, --stop stops the test run. FAILED (TODO=1) -With a false isfailure, when the errorclass' exception is caught by -nose, tracebacks are not printed, and the test run does not stop. +With a false .isfailure , errorclass exceptions raised by tests are +treated as "ignored errors". For ignored errors, tracebacks are not +printed, and the test run does not stop. >>> run(argv=["nosetests", "-v", "--with-non-failure-todo", "--stop", ... todo_test], @@ -73,12 +74,12 @@ nose, tracebacks are not printed, and the test run does not stop. ---------------------------------------------------------------------- Ran 2 tests in ...s <BLANKLINE> - OK + OK (TODO=1) Exception detail strings of errorclass errors are always printed when --v is in effect, whether the errorclass is failure or non-failure. -Note that exception detail strings may have more than one line. +-v is in effect, regardless of whether the error is ignored. Note +that exception detail strings may have more than one line. >>> run(argv=["nosetests", "-v", "--with-todo", misc_test], ... plugins=[TodoPlugin(), Skip(), Deprecated()]) @@ -103,10 +104,10 @@ Note that exception detail strings may have more than one line. ---------------------------------------------------------------------- Ran 6 tests in ...s <BLANKLINE> - FAILED (TODO=1) + FAILED (DEPRECATED=2, SKIP=2, TODO=1) -Without -v, the exception detail strings only appear in failure -errorclass tracebacks +Without -v, the exception detail strings are only displayed if the +error is not ignored (otherwise, there's no traceback) >>> run(argv=["nosetests", "--with-todo", misc_test], ... plugins=[TodoPlugin(), Skip(), Deprecated()]) @@ -122,6 +123,6 @@ errorclass tracebacks ---------------------------------------------------------------------- Ran 6 tests in ...s <BLANKLINE> - FAILED (TODO=1) + FAILED (DEPRECATED=2, SKIP=2, TODO=1) >>> sys.path.remove(support) diff --git a/nose/result.py b/nose/result.py index 69f080b..41bb90a 100644 --- a/nose/result.py +++ b/nose/result.py @@ -11,7 +11,7 @@ reporting. import logging from unittest import _TextTestResult from nose.config import Config -from nose.util import isclass, odict, ln as _ln # backwards compat +from nose.util import isclass, ln as _ln # backwards compat log = logging.getLogger('nose.result') @@ -97,27 +97,32 @@ class TextTestResult(_TextTestResult): writeln(self.separator2) writeln("Ran %s test%s in %.3fs" % (run, plural, taken)) writeln() + + summary = {} + eckeys = self.errorClasses.keys() + eckeys.sort() + for cls in eckeys: + storage, label, isfail = self.errorClasses[cls] + count = len(storage) + if not count: + continue + summary[label] = count + if len(self.failures): + summary['failures'] = len(self.failures) + if len(self.errors): + summary['errors'] = len(self.errors) + if not self.wasSuccessful(): - write("FAILED (") - summary = odict() - summary['failures'], summary['errors'] = \ - map(len, [self.failures, self.errors]) - for cls in self.errorClasses.keys(): - storage, label, isfail = self.errorClasses[cls] - if not isfail: - continue - summary[label] = len(storage) - any = False - for label, count in summary.items(): - if not count: - continue - if any: - write(", ") - write("%s=%s" % (label, count)) - any = True - writeln(")") + write("FAILED") else: - writeln("OK") + write("OK") + items = summary.items() + if items: + items.sort() + write(" (") + write(", ".join(["%s=%s" % (label, count) for + label, count in items])) + writeln(")") def wasSuccessful(self): """Overrides to check that there are no errors in errorClasses |