mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #25651: Allow falsy values to be used for msg parameter of subTest()
This commit is contained in:
parent
1ddf53d496
commit
16ea19fc66
3 changed files with 15 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue