Issue #25651: Allow falsy values to be used for msg parameter of subTest()

This commit is contained in:
Berker Peksag 2016-09-21 19:34:15 +03:00
parent 1ddf53d496
commit 16ea19fc66
3 changed files with 15 additions and 2 deletions

View file

@ -323,6 +323,16 @@ class Test_TestResult(unittest.TestCase):
'testGetSubTestDescriptionWithoutDocstringAndParams '
'(' + __name__ + '.Test_TestResult) (<subtest>)')
def testGetSubTestDescriptionForFalsyValues(self):
expected = 'testGetSubTestDescriptionForFalsyValues (%s.Test_TestResult) [%s]'
result = unittest.TextTestResult(None, True, 1)
for arg in [0, None, []]:
with self.subTest(arg):
self.assertEqual(
result.getDescription(self._subtest),
expected % (__name__, arg)
)
def testGetNestedSubTestDescriptionWithoutDocstring(self):
with self.subTest(foo=1):
with self.subTest(bar=2):