diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_unittest/test_runner.py | 12 | ||||
-rw-r--r-- | Lib/unittest/result.py | 6 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_unittest/test_runner.py b/Lib/test/test_unittest/test_runner.py index 1ce42a1..ceb4c8a 100644 --- a/Lib/test/test_unittest/test_runner.py +++ b/Lib/test/test_unittest/test_runner.py @@ -1367,7 +1367,7 @@ class Test_TextTestRunner(unittest.TestCase): self.assertTrue(runner.stream.stream is f) def test_durations(self): - def run(test, expect_durations): + def run(test, *, expect_durations=True): stream = BufferedWriter() runner = unittest.TextTestRunner(stream=stream, durations=5, verbosity=2) result = runner.run(test) @@ -1389,21 +1389,21 @@ class Test_TextTestRunner(unittest.TestCase): def test_1(self): pass - run(Foo('test_1'), True) + run(Foo('test_1'), expect_durations=True) # failure class Foo(unittest.TestCase): def test_1(self): self.assertEqual(0, 1) - run(Foo('test_1'), True) + run(Foo('test_1'), expect_durations=True) # error class Foo(unittest.TestCase): def test_1(self): 1 / 0 - run(Foo('test_1'), True) + run(Foo('test_1'), expect_durations=True) # error in setUp and tearDown @@ -1414,7 +1414,7 @@ class Test_TextTestRunner(unittest.TestCase): def test_1(self): pass - run(Foo('test_1'), True) + run(Foo('test_1'), expect_durations=True) # skip (expect no durations) class Foo(unittest.TestCase): @@ -1422,7 +1422,7 @@ class Test_TextTestRunner(unittest.TestCase): def test_1(self): pass - run(Foo('test_1'), False) + run(Foo('test_1'), expect_durations=False) diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py index fa9bea4..7757dba 100644 --- a/Lib/unittest/result.py +++ b/Lib/unittest/result.py @@ -159,7 +159,11 @@ class TestResult(object): self.unexpectedSuccesses.append(test) def addDuration(self, test, elapsed): - """Called when a test finished to run, regardless of its outcome.""" + """Called when a test finished to run, regardless of its outcome. + *test* is the test case corresponding to the test method. + *elapsed* is the time represented in seconds, and it includes the + execution of cleanup functions. + """ # support for a TextTestRunner using an old TestResult class if hasattr(self, "collectedDurations"): self.collectedDurations.append((test, elapsed)) |