Skip to content

Commit

Permalink
unittest: add addDuration function for Python 3.12 support
Browse files Browse the repository at this point in the history
Fix pytest-dev#10875

Without this, fails with

```
...
E           AttributeError: 'TestCaseFunction' object has no attribute 'addDuration'
...
E           RuntimeWarning: TestResult has no addDuration method
```
  • Loading branch information
bluetech committed Apr 11, 2023
1 parent cc963aa commit 056152e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/_pytest/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ def addSuccess(self, testcase: "unittest.TestCase") -> None:
def stopTest(self, testcase: "unittest.TestCase") -> None:
pass

def addDuration(self, testcase: "unittest.TestCase", elapsed: float) -> None:
pass

def runtest(self) -> None:
from _pytest.debugging import maybe_wrap_pytest_function_for_tracing

Expand Down

0 comments on commit 056152e

Please sign in to comment.