<div dir="ltr"><div><div><div><div>Hi All,<br><br></div>Recently we switched our test environment from funcargs to fixtures and found unexpected and unwanted behaviour: In case fixture finalizer failed next time fixture won't be set up.<br>
<br></div>Here I have 2 fixtures:<br></div>env_main - module level<br></div>env - functional level (env_main child)<br><div><div><div><br></div><div>In pytest output you can see message that env was created before test_1 ("INIT_ENV" message). Then it failed on finalizer after "DESTROY ENV" message.<br>
</div><div>PROBLEM: test_2 that requires env fixture is launched but without env fixture.<br></div><div>I expect that function level fixture will be recreated for the next test function, or at least all other test functions will fail without launching. I don't see any reason why they have to be launched in case fixture cannot be set up. But it's better to try to recreate fixture for next iteration (e.g. next function if scope is function)<br>
</div><div><br></div><div>I see there was an issue <span class="">#287 which is marked as resolved. But as for me it could be reopened.<br><br></span></div><div><span class="">I see that in case we add more test cases, then the fixture will be created for the 3d test function but again skipped for the 4th test function. <br>
</span></div><div><br></div><div>Is it possible to change current default behaviour?<br></div><div><br></div><div>Thank you in advance!<br>Anton<br><br></div><div>P.S.<br></div><div>Please find code files attached.<br><br>
</div><div>Here is execution log:<br></div><div><br>$ py.test -v -s test_params.py <br>============================ test session starts ============================<br>platform linux2 -- Python 2.7.3 -- py-1.4.20 -- pytest-2.5.2 -- /usr/bin/python<br>
plugins: cov<br>collected 2 items <br><br>test_params.py:4: TestClass.test_1 Create ENV_MAIN<br>INIT ENV<br>PASSEDDESTROY ENV<br><br>test_params.py:4: TestClass.test_1 ERROR<br>test_params.py:7: TestClass.test_2 PASSEDDestroy ENV_MAIN<br>
<br><br>================================== ERRORS ===================================<br>___________________ ERROR at teardown of TestClass.test_1 ___________________<br><br>self = <conftest.EnvTest instance at 0x2025878><br>
<br> def teardown(self):<br> print "DESTROY ENV"<br>> assert 0<br>E assert 0<br><br>conftest.py:30: AssertionError<br>===================== 2 passed, 1 error in 0.01 seconds =====================<br>
</div></div></div></div>