[issue25651] Confusing output for TestCase.subTest(0)
Zachary Ware
report at bugs.python.org
Wed Dec 16 23:37:01 EST 2015
Zachary Ware added the comment:
I think Ezio's suggestion of a sentinel value would be better, allowing None to be using as a legitimate 'message' [1]. That is, somewhere at global scope, define '_subtest_msg_sentinel = object()', change the msg default at Lib/unittest/case.py:500 to be 'msg=_subtest_msg_sentinel', and change the check at Lib/unittest/case.py:1400 to check 'if message is not _subtest_msg_sentinel'.
[1] For example:
class TruthTest(unittest.TestCase):
def test_truth(self):
for o in None, 1, 0, [], (4,):
with self.subTest(o):
self.assertTrue(o)
Should print failure results including '[None]', '[0]', and '[[]]'.
----------
nosy: +zach.ware
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25651>
_______________________________________
More information about the Python-bugs-list
mailing list