summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-28 21:42:05 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-28 21:42:05 (GMT)
commite549ead8263819ac47f60cdd0239592750888f0b (patch)
tree7e1199b4b197ac5facd66b03cbb7e768fa2b6892 /Lib/unittest.py
parentb556452055590c6d8f658d90c6be00aec31f5620 (diff)
downloadcpython-e549ead8263819ac47f60cdd0239592750888f0b.zip
cpython-e549ead8263819ac47f60cdd0239592750888f0b.tar.gz
cpython-e549ead8263819ac47f60cdd0239592750888f0b.tar.bz2
Merged revisions 70554,70588-70589,70598,70605,70611-70621,70623-70624,70626-70627 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70554 | benjamin.peterson | 2009-03-23 16:25:15 -0500 (Mon, 23 Mar 2009) | 1 line complain when there's no last exception ........ r70588 | benjamin.peterson | 2009-03-24 17:56:32 -0500 (Tue, 24 Mar 2009) | 1 line fix newline issue in test summary ........ r70589 | benjamin.peterson | 2009-03-24 18:07:07 -0500 (Tue, 24 Mar 2009) | 1 line another style nit ........ r70598 | benjamin.peterson | 2009-03-25 16:24:04 -0500 (Wed, 25 Mar 2009) | 1 line add shorthands for expected failures and unexpected success ........ r70605 | benjamin.peterson | 2009-03-26 11:32:23 -0500 (Thu, 26 Mar 2009) | 1 line remove uneeded function ........ r70611 | benjamin.peterson | 2009-03-26 13:35:37 -0500 (Thu, 26 Mar 2009) | 1 line add much better tests for python version information parsing ........ r70612 | benjamin.peterson | 2009-03-26 13:55:48 -0500 (Thu, 26 Mar 2009) | 1 line more and more implementations now support sys.subversion ........ r70613 | benjamin.peterson | 2009-03-26 13:58:30 -0500 (Thu, 26 Mar 2009) | 1 line roll old test in with new one ........ r70614 | benjamin.peterson | 2009-03-26 14:09:21 -0500 (Thu, 26 Mar 2009) | 1 line add support for PyPy ........ r70615 | benjamin.peterson | 2009-03-26 14:58:18 -0500 (Thu, 26 Mar 2009) | 5 lines add some useful utilities for skipping tests with unittest's new skipping ability most significantly apply a modified portion of the patch from #4242 with patches for skipping implementation details ........ r70616 | benjamin.peterson | 2009-03-26 15:05:50 -0500 (Thu, 26 Mar 2009) | 1 line rename TestCase.skip() to skipTest() because it causes annoying problems with trial #5571 ........ r70617 | benjamin.peterson | 2009-03-26 15:17:27 -0500 (Thu, 26 Mar 2009) | 1 line apply the second part of #4242's patch; classify all the implementation details in test_descr ........ r70618 | benjamin.peterson | 2009-03-26 15:48:25 -0500 (Thu, 26 Mar 2009) | 1 line remove test_support.TestSkipped and just use unittest.SkipTest ........ r70619 | benjamin.peterson | 2009-03-26 15:49:40 -0500 (Thu, 26 Mar 2009) | 1 line fix naming ........ r70620 | benjamin.peterson | 2009-03-26 16:10:30 -0500 (Thu, 26 Mar 2009) | 1 line fix incorrect auto-translation of TestSkipped -> unittest.SkipTest ........ r70621 | benjamin.peterson | 2009-03-26 16:11:16 -0500 (Thu, 26 Mar 2009) | 1 line must pass argument to get expected behavior ;) ........ r70623 | benjamin.peterson | 2009-03-26 16:30:10 -0500 (Thu, 26 Mar 2009) | 1 line add missing import ........ r70624 | benjamin.peterson | 2009-03-26 16:30:54 -0500 (Thu, 26 Mar 2009) | 1 line ** is required here ........ r70626 | benjamin.peterson | 2009-03-26 16:40:29 -0500 (Thu, 26 Mar 2009) | 1 line update email tests to use SkipTest ........ r70627 | benjamin.peterson | 2009-03-26 16:44:43 -0500 (Thu, 26 Mar 2009) | 1 line fix another name ........
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 13cbfd3..ade806c 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -373,14 +373,14 @@ class TestCase(object):
result.addSkip(self, str(e))
return
except Exception:
- result.addError(self, self._exc_info())
+ result.addError(self, sys.exc_info())
return
success = False
try:
testMethod()
except self.failureException:
- result.addFailure(self, self._exc_info())
+ result.addFailure(self, sys.exc_info())
except _ExpectedFailure as e:
result.addExpectedFailure(self, e.exc_info)
except _UnexpectedSuccess:
@@ -388,14 +388,14 @@ class TestCase(object):
except SkipTest as e:
result.addSkip(self, str(e))
except Exception:
- result.addError(self, self._exc_info())
+ result.addError(self, sys.exc_info())
else:
success = True
try:
self.tearDown()
except Exception:
- result.addError(self, self._exc_info())
+ result.addError(self, sys.exc_info())
success = False
if success:
result.addSuccess(self)
@@ -411,14 +411,7 @@ class TestCase(object):
getattr(self, self._testMethodName)()
self.tearDown()
- def _exc_info(self):
- """Return a version of sys.exc_info() with the traceback frame
- minimised; usually the top level of the traceback frame is not
- needed.
- """
- return sys.exc_info()
-
- def skip(self, reason):
+ def skipTest(self, reason):
"""Skip this test."""
raise SkipTest(reason)
@@ -830,7 +823,8 @@ class _WritelnDecorator(object):
return getattr(self.stream,attr)
def writeln(self, arg=None):
- if arg: self.write(arg)
+ if arg:
+ self.write(arg)
self.write('\n') # text-mode streams translate to \r\n if needed
@@ -899,7 +893,7 @@ class _TextTestResult(TestResult):
if self.showAll:
self.stream.writeln("expected failure")
elif self.dots:
- self.stream.write(".")
+ self.stream.write("x")
self.stream.flush()
def addUnexpectedSuccess(self, test):
@@ -907,7 +901,7 @@ class _TextTestResult(TestResult):
if self.showAll:
self.stream.writeln("unexpected success")
elif self.dots:
- self.stream.write(".")
+ self.stream.write("u")
self.stream.flush()
def printErrors(self):
@@ -964,7 +958,7 @@ class TextTestRunner(object):
if errored:
infos.append("errors=%d" % errored)
else:
- self.stream.writeln("OK")
+ self.stream.write("OK")
if skipped:
infos.append("skipped=%d" % skipped)
if expectedFails:
@@ -973,6 +967,8 @@ class TextTestRunner(object):
infos.append("unexpected successes=%d" % unexpectedSuccesses)
if infos:
self.stream.writeln(" (%s)" % (", ".join(infos),))
+ else:
+ self.stream.write("\n")
return result