cpython: ddbf92168a44 (original) (raw)
Mercurial > cpython
changeset 103999:ddbf92168a44 3.6
Issue #25651: Merge from 3.5 [#25651]
Berker Peksag berker.peksag@gmail.com | |
---|---|
date | Wed, 21 Sep 2016 19:35:28 +0300 |
parents | b995b1f52975(current diff)ba743894e793(diff) |
children | e5888f5b9cf8 b3114b382e87 |
files | Misc/NEWS |
diffstat | 3 files changed, 15 insertions(+), 2 deletions(-)[+] [-] Lib/unittest/case.py 5 Lib/unittest/test/test_result.py 10 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -17,6 +17,7 @@ from .util import (strclass, safe_repr, __unittest = True +_subtest_msg_sentinel = object() DIFF_OMITTED = ('\nDiff is %s characters long. ' 'Set self.maxDiff to None to see it.') @@ -497,7 +498,7 @@ class TestCase(object): result.addSuccess(test_case) @contextlib.contextmanager
- def subTest(self, msg=_subtest_msg_sentinel, **params): """Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters. A failure in the subtest marks the test
@@ -1397,7 +1398,7 @@ class _SubTest(TestCase): def _subDescription(self): parts = []
if self._message:[](#l1.24)
if self._message is not _subtest_msg_sentinel:[](#l1.25) parts.append("[{}]".format(self._message))[](#l1.26) if self.params:[](#l1.27) params_desc = ', '.join([](#l1.28)
--- 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) ()')
- def testGetSubTestDescriptionForFalsyValues(self):
expected = 'testGetSubTestDescriptionForFalsyValues (%s.Test_TestResult) [%s]'[](#l2.8)
result = unittest.TextTestResult(None, True, 1)[](#l2.9)
for arg in [0, None, []]:[](#l2.10)
with self.subTest(arg):[](#l2.11)
self.assertEqual([](#l2.12)
result.getDescription(self._subtest),[](#l2.13)
expected % (__name__, arg)[](#l2.14)
)[](#l2.15)
+ def testGetNestedSubTestDescriptionWithoutDocstring(self): with self.subTest(foo=1): with self.subTest(bar=2):
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -35,6 +35,8 @@ Core and Builtins Library ------- +- Issue #25651: Allow falsy values to be used for msg parameter of subTest(). +