summaryrefslogtreecommitdiff
path: root/Lib/test/test_unittest.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-02-10 15:51:42 +0000
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-02-10 15:51:42 +0000
commit1c3abceb621a29277717722f99777d9a062a416b (patch)
tree9584d3385c5885b18876fd658d79182c817300a8 /Lib/test/test_unittest.py
parent0f2c1e79285cfdbe3e0609f950932ab385fa4305 (diff)
downloadcpython-1c3abceb621a29277717722f99777d9a062a416b.tar.gz
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.py55
1 files changed, 45 insertions, 10 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index e5219fdbcb..0727931fde 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):