[8.2.x] unittest: fix assertion errors on unittest reruns (#12438)
Co-authored-by: Ran Benita <ran@unusedvar.com>
This commit is contained in:
parent
36f0ea10b4
commit
eb8721d387
|
@ -0,0 +1 @@
|
||||||
|
Fix crash with `assert testcase is not None` assertion failure when re-running unittest tests using plugins like pytest-rerunfailures. Regressed in 8.2.2.
|
|
@ -216,7 +216,7 @@ class TestCaseFunction(Function):
|
||||||
self._explicit_tearDown()
|
self._explicit_tearDown()
|
||||||
self._explicit_tearDown = None
|
self._explicit_tearDown = None
|
||||||
self._obj = None
|
self._obj = None
|
||||||
self._instance = None
|
del self._instance
|
||||||
super().teardown()
|
super().teardown()
|
||||||
|
|
||||||
def startTest(self, testcase: "unittest.TestCase") -> None:
|
def startTest(self, testcase: "unittest.TestCase") -> None:
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class MyTestCase(unittest.TestCase):
|
||||||
|
first_time = True
|
||||||
|
|
||||||
|
def test_fail_the_first_time(self) -> None:
|
||||||
|
"""Regression test for issue #12424."""
|
||||||
|
if self.first_time:
|
||||||
|
type(self).first_time = False
|
||||||
|
self.fail()
|
|
@ -1,9 +1,7 @@
|
||||||
anyio[curio,trio]==4.3.0
|
anyio[curio,trio]==4.4.0
|
||||||
django==5.0.4
|
django==5.0.6
|
||||||
pytest-asyncio==0.23.6
|
pytest-asyncio==0.23.7
|
||||||
# Temporarily not installed until pytest-bdd is fixed:
|
pytest-bdd==7.1.2
|
||||||
# https://github.com/pytest-dev/pytest/pull/11785
|
|
||||||
# pytest-bdd==7.0.1
|
|
||||||
pytest-cov==5.0.0
|
pytest-cov==5.0.0
|
||||||
pytest-django==4.8.0
|
pytest-django==4.8.0
|
||||||
pytest-flakes==4.0.5
|
pytest-flakes==4.0.5
|
||||||
|
@ -11,7 +9,7 @@ pytest-html==4.1.1
|
||||||
pytest-mock==3.14.0
|
pytest-mock==3.14.0
|
||||||
pytest-rerunfailures==14.0
|
pytest-rerunfailures==14.0
|
||||||
pytest-sugar==1.0.0
|
pytest-sugar==1.0.0
|
||||||
pytest-trio==0.7.0
|
pytest-trio==0.8.0
|
||||||
pytest-twisted==1.14.1
|
pytest-twisted==1.14.1
|
||||||
twisted==24.3.0
|
twisted==24.3.0
|
||||||
pytest-xvfb==3.0.0
|
pytest-xvfb==3.0.0
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -143,7 +143,7 @@ commands =
|
||||||
pytest --cov=. simple_integration.py
|
pytest --cov=. simple_integration.py
|
||||||
pytest --ds=django_settings simple_integration.py
|
pytest --ds=django_settings simple_integration.py
|
||||||
pytest --html=simple.html simple_integration.py
|
pytest --html=simple.html simple_integration.py
|
||||||
pytest --reruns 5 simple_integration.py
|
pytest --reruns 5 simple_integration.py pytest_rerunfailures_integration.py
|
||||||
pytest pytest_anyio_integration.py
|
pytest pytest_anyio_integration.py
|
||||||
pytest pytest_asyncio_integration.py
|
pytest pytest_asyncio_integration.py
|
||||||
pytest pytest_mock_integration.py
|
pytest pytest_mock_integration.py
|
||||||
|
|
Loading…
Reference in New Issue