Skip to content

Commit 83db5ae

Browse files
committed
unittest: add addDuration function for Python 3.12 support
Fix pytest-dev#10875 Without this, fails with ``` ... E AttributeError: 'TestCaseFunction' object has no attribute 'addDuration' ... E RuntimeWarning: TestResult has no addDuration method ```
1 parent 1392d55 commit 83db5ae

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

changelog/10875.improvement.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Python 3.12 support: fixed ``RuntimeError: TestResult has no addDuration method`` when running ``unittest`` tests.

src/_pytest/unittest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ def addSuccess(self, testcase: "unittest.TestCase") -> None:
298298
def stopTest(self, testcase: "unittest.TestCase") -> None:
299299
pass
300300

301+
def addDuration(self, testcase: "unittest.TestCase", elapsed: float) -> None:
302+
pass
303+
301304
def runtest(self) -> None:
302305
from _pytest.debugging import maybe_wrap_pytest_function_for_tracing
303306

0 commit comments

Comments
 (0)