unittest: add addDuration function for Python 3.12 support
This commit is contained in:
parent
967bcacb03
commit
ec0e1eba6d
42
1b81d63.patch
Normal file
42
1b81d63.patch
Normal file
@ -0,0 +1,42 @@
|
||||
From 1b81d636e2a086403031909cfb71a397d1ce26de Mon Sep 17 00:00:00 2001
|
||||
From: Ran Benita <ran@unusedvar.com>
|
||||
Date: Tue, 11 Apr 2023 12:53:13 +0300
|
||||
Subject: [PATCH] unittest: add addDuration function for Python 3.12 support
|
||||
|
||||
Fix #10875
|
||||
|
||||
Without this, fails with
|
||||
|
||||
```
|
||||
...
|
||||
E AttributeError: 'TestCaseFunction' object has no attribute 'addDuration'
|
||||
...
|
||||
E RuntimeWarning: TestResult has no addDuration method
|
||||
```
|
||||
---
|
||||
changelog/10875.improvement.rst | 1 +
|
||||
src/_pytest/unittest.py | 3 +++
|
||||
2 files changed, 4 insertions(+)
|
||||
create mode 100644 changelog/10875.improvement.rst
|
||||
|
||||
diff --git a/changelog/10875.improvement.rst b/changelog/10875.improvement.rst
|
||||
new file mode 100644
|
||||
index 0000000000..eeaf046350
|
||||
--- /dev/null
|
||||
+++ b/changelog/10875.improvement.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Python 3.12 support: fixed ``RuntimeError: TestResult has no addDuration method`` when running ``unittest`` tests.
|
||||
diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py
|
||||
index c2df986530..c660aa75db 100644
|
||||
--- a/src/_pytest/unittest.py
|
||||
+++ b/src/_pytest/unittest.py
|
||||
@@ -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
|
||||
|
@ -10,6 +10,9 @@ Source: %{pypi_source pytest %{base_version}%{?prerelease}}
|
||||
# see https://github.com/pytest-dev/pytest/issues/10042#issuecomment-1237132867
|
||||
Patch: pytest-7.1.3-fix-xfails.patch
|
||||
|
||||
# unittest: add addDuration function for Python 3.12 support
|
||||
Patch: https://github.com/pytest-dev/pytest/commit/1b81d63.patch
|
||||
|
||||
# Remove -s from Python shebang,
|
||||
# ensure that packages installed with pip to user locations are testable
|
||||
# https://bugzilla.redhat.com/2152171
|
||||
|
Loading…
Reference in New Issue
Block a user