summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/test
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-09-21 16:34:15 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-09-21 16:34:15 (GMT)
commit16ea19fc6653ee4ec1be7cd0206073962119ac08 (patch)
tree79f3750b60bd421f707f13232b475ca3b642a5e5 /Lib/unittest/test
parent1ddf53d496a3b7bd09fe8672daa2f07a4d240f2c (diff)
downloadcpython-16ea19fc6653ee4ec1be7cd0206073962119ac08.zip
cpython-16ea19fc6653ee4ec1be7cd0206073962119ac08.tar.gz
cpython-16ea19fc6653ee4ec1be7cd0206073962119ac08.tar.bz2
Issue #25651: Allow falsy values to be used for msg parameter of subTest()
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r--Lib/unittest/test/test_result.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_result.py b/Lib/unittest/test/test_result.py
index e39e2ea..0a61553 100644
--- a/Lib/unittest/test/test_result.py
+++ b/Lib/unittest/test/test_result.py
@@ -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):