diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-05-02 21:00:22 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-05-02 21:00:22 (GMT) |
commit | d23ea06175c62b166d8a6c7a2efc090bf7ead779 (patch) | |
tree | 652a580c2d7305e34de781748e8df83a16ca39bc /Lib/unittest/test | |
parent | 6e20a1bdf082dc20586c291993a32b58b503744e (diff) | |
download | cpython-d23ea06175c62b166d8a6c7a2efc090bf7ead779.zip cpython-d23ea06175c62b166d8a6c7a2efc090bf7ead779.tar.gz cpython-d23ea06175c62b166d8a6c7a2efc090bf7ead779.tar.bz2 |
Merged revisions 80708 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80708 | michael.foord | 2010-05-02 21:39:42 +0100 (Sun, 02 May 2010) | 1 line
Fix unittest tests to not abuse traceback.format_exception
........
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/test_result.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/unittest/test/test_result.py b/Lib/unittest/test/test_result.py index c703032..64798a1 100644 --- a/Lib/unittest/test/test_result.py +++ b/Lib/unittest/test/test_result.py @@ -4,6 +4,7 @@ import textwrap from test import support +import traceback import unittest @@ -361,6 +362,15 @@ class Test_OldTestResult(unittest.TestCase): runner.run(Test('testFoo')) +class MockTraceback(object): + @staticmethod + def format_exception(*_): + return ['A traceback'] + +def restore_traceback(): + unittest.result.traceback = traceback + + class TestOutputBuffering(unittest.TestCase): def setUp(self): @@ -441,6 +451,9 @@ class TestOutputBuffering(unittest.TestCase): return result def testBufferOutputAddErrorOrFailure(self): + unittest.result.traceback = MockTraceback + self.addCleanup(restore_traceback) + for message_attr, add_attr, include_error in [ ('errors', 'addError', True), ('failures', 'addFailure', False), @@ -476,7 +489,8 @@ class TestOutputBuffering(unittest.TestCase): Stderr: bar """) - expectedFullMessage = 'NoneType\n%s%s' % (expectedOutMessage, expectedErrMessage) + + expectedFullMessage = 'A traceback%s%s' % (expectedOutMessage, expectedErrMessage) self.assertIs(test, self) self.assertEqual(result._original_stdout.getvalue(), expectedOutMessage) |