Merge pull request #12436 from bluetech/unittest-rerun-assertion
unittest: fix assertion errors on unittest reruns
This commit is contained in:
		
						commit
						f85289ba87
					
				| 
						 | 
				
			
			@ -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.
 | 
			
		||||
| 
						 | 
				
			
			@ -223,7 +223,7 @@ class TestCaseFunction(Function):
 | 
			
		|||
            self._explicit_tearDown()
 | 
			
		||||
            self._explicit_tearDown = None
 | 
			
		||||
        self._obj = None
 | 
			
		||||
        self._instance = None
 | 
			
		||||
        del self._instance
 | 
			
		||||
        super().teardown()
 | 
			
		||||
 | 
			
		||||
    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()
 | 
			
		||||
							
								
								
									
										2
									
								
								tox.ini
								
								
								
								
							
							
						
						
									
										2
									
								
								tox.ini
								
								
								
								
							| 
						 | 
				
			
			@ -141,7 +141,7 @@ commands =
 | 
			
		|||
    pytest --cov=. simple_integration.py
 | 
			
		||||
    pytest --ds=django_settings 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_asyncio_integration.py
 | 
			
		||||
    pytest pytest_mock_integration.py
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue