diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-10 15:51:42 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-02-10 15:51:42 (GMT) |
commit | 34c9462d713275762803f102a68f23dd2bb7460a (patch) | |
tree | b56e5520cce62534e26f55285f1ded54de3caa06 /Lib/test/test_unittest.py | |
parent | 99f69ee7a1cf4d032d420ad69d22bd44b8cf6cc8 (diff) | |
download | cpython-34c9462d713275762803f102a68f23dd2bb7460a.zip cpython-34c9462d713275762803f102a68f23dd2bb7460a.tar.gz cpython-34c9462d713275762803f102a68f23dd2bb7460a.tar.bz2 |
Merged revisions 78130 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78130 | michael.foord | 2010-02-10 14:25:12 +0000 (Wed, 10 Feb 2010) | 1 line
Issue 7893 and Issue 7588
........
Diffstat (limited to 'Lib/test/test_unittest.py')
-rw-r--r-- | Lib/test/test_unittest.py | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py index e5219fd..0727931 100644 --- a/Lib/test/test_unittest.py +++ b/Lib/test/test_unittest.py @@ -2044,6 +2044,35 @@ class Test_TestResult(TestCase): self.assertTrue(test_case is test) self.assertIsInstance(formatted_exc, str) + def testGetDescriptionWithoutDocstring(self): + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + 'testGetDescriptionWithoutDocstring (' + __name__ + + '.Test_TestResult)') + + def testGetDescriptionWithOneLineDocstring(self): + """Tests getDescription() for a method with a docstring.""" + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + ('testGetDescriptionWithOneLineDocstring ' + '(' + __name__ + '.Test_TestResult)\n' + 'Tests getDescription() for a method with a docstring.')) + + def testGetDescriptionWithMultiLineDocstring(self): + """Tests getDescription() for a method with a longer docstring. + The second line of the docstring. + """ + result = unittest.TextTestResult(None, True, None) + self.assertEqual( + result.getDescription(self), + ('testGetDescriptionWithMultiLineDocstring ' + '(' + __name__ + '.Test_TestResult)\n' + 'Tests getDescription() for a method with a longer ' + 'docstring.')) + + ### Support code for Test_TestCase ################################################################ @@ -2458,18 +2487,13 @@ class Test_TestCase(TestCase, TestEquality, TestHashing): self.assertEqual(events, expected) def testShortDescriptionWithoutDocstring(self): - self.assertEqual( - self.shortDescription(), - 'testShortDescriptionWithoutDocstring (' + __name__ + - '.Test_TestCase)') + self.assertIsNone(self.shortDescription()) def testShortDescriptionWithOneLineDocstring(self): """Tests shortDescription() for a method with a docstring.""" self.assertEqual( self.shortDescription(), - ('testShortDescriptionWithOneLineDocstring ' - '(' + __name__ + '.Test_TestCase)\n' - 'Tests shortDescription() for a method with a docstring.')) + 'Tests shortDescription() for a method with a docstring.') def testShortDescriptionWithMultiLineDocstring(self): """Tests shortDescription() for a method with a longer docstring. @@ -2480,10 +2504,8 @@ class Test_TestCase(TestCase, TestEquality, TestHashing): """ self.assertEqual( self.shortDescription(), - ('testShortDescriptionWithMultiLineDocstring ' - '(' + __name__ + '.Test_TestCase)\n' 'Tests shortDescription() for a method with a longer ' - 'docstring.')) + 'docstring.') def testAddTypeEqualityFunc(self): class SadSnake(object): @@ -3472,6 +3494,19 @@ class Test_TextTestRunner(TestCase): # StringIO objects never compare equal, a cheap test instead. self.assertEqual(obj.stream.getvalue(), stream.getvalue()) + def test_resultclass(self): + def MockResultClass(*args): + return args + STREAM = object() + DESCRIPTIONS = object() + VERBOSITY = object() + runner = unittest.TextTestRunner(STREAM, DESCRIPTIONS, VERBOSITY, + resultclass=MockResultClass) + self.assertEqual(runner.resultclass, MockResultClass) + + expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY) + self.assertEqual(runner._makeResult(), expectedresult) + class TestDiscovery(TestCase): |