8000 gh-48330: address review comments to PR-12271 (#103209) · python/cpython@ff3303e · GitHub
[go: up one dir, main page]

Skip to content

Commit ff3303e

Browse files
authored
gh-48330: address review comments to PR-12271 (#103209)
address review comments to PR-12271 Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
1 parent a210cac commit ff3303e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

Doc/library/unittest.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,10 +2191,6 @@ Loading and running tests
21912191
.. versionadded:: 3.12
21922192
Added *durations* keyword argument.
21932193

2194-
.. versionchanged:: 3.12
2195-
Subclasses should accept ``**kwargs`` to ensure compatibility as the
2196-
interface changes.
2197-
21982194
.. data:: defaultTestLoader
21992195

22002196
Instance of the :class:`TestLoader` class intended to be shared. If no

Lib/test/test_unittest/test_runner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ def testSpecifiedStreamUsed(self):
13671367
self.assertTrue(runner.stream.stream is f)
13681368

13691369
def test_durations(self):
1370-
def run(test, expect_durations):
1370+
def run(test, *, expect_durations=True):
13711371
stream = BufferedWriter()
13721372
runner = unittest.TextTestRunner(stream=stream, durations=5, verbosity=2)
13731373
result = runner.run(test)
@@ -1389,21 +1389,21 @@ class Foo(unittest.TestCase):
13891389
def test_1(self):
13901390
pass
13911391

1392-
run(Foo('test_1'), True)
1392+
run(Foo('test_1'), expect_durations=True)
13931393

13941394
# failure
13951395
class Foo(unittest.TestCase):
13961396
def test_1(self):
13971397
self.assertEqual(0, 1)
13981398

1399-
run(Foo('test_1'), True)
1399+
run(Foo('test_1'), expect_durations=True)
14001400

14011401
# error
14021402
class Foo(unittest.TestCase):
14031403
def test_1(self):
14041404
1 / 0
14051405

1406-
run(Foo('test_1'), True)
1406+
run(Foo('test_1'), expect_durations=True)
14071407

14081408

14091409
# error in setUp and tearDown
@@ -1414,15 +1414,15 @@ def setUp(self):
14141414
def test_1(self):
14151415
pass
14161416

1417-
run(Foo('test_1'), True)
1417+
run(Foo('test_1'), expect_durations=True)
14181418

14191419
# skip (expect no durations)
14201420
class Foo(unittest.TestCase):
14211421
@unittest.skip("reason")
14221422
def test_1(self):
14231423
pass
14241424

1425-
run(Foo('test_1'), False)
1425+
run(Foo('test_1'), expect_durations=False)
14261426

14271427

14281428

Lib/unittest/result.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def addUnexpectedSuccess(self, test):
159159
self.unexpectedSuccesses.append(test)
160160

161161
def addDuration(self, test, elapsed):
162-
"""Called when a test finished to run, regardless of its outcome."""
162+
"""Called when a test finished to run, regardless of its outcome.
163+
*test* is the test case corresponding to the test method.
164+
*elapsed* is the time represented in seconds, and it includes the
165+
execution of cleanup functions.
166+
"""
163167
# support for a TextTestRunner using an old TestResult class
164168
if hasattr(self, "collectedDurations"):
165169
self.collectedDurations.append((test, elapsed))

0 commit comments

Comments
 (0)
0