Join GitHub today
Setting a fixture scope of "package" will not teardown the fixture #3796
I am using Windows 10, Python 3.6, and pytest 3.7.1 or 3.7.0 (tested with both).
Here are the libraries I have installed:
It appears as though when a fixture is setup with a scope of package, the teardown code does not execute.
@pytest.fixture(scope="package") def example(): setup_code() yield something teardown_code()
For this example, "teardown_code()" is never executed for me.
Thanks for reporting it. I could not reproduce it with this example though:
import pytest @pytest.fixture(scope='package') def fix(): print('setup') yield 1 print('teardown') def test(fix): assert fix == 1
Can you please provide a reproducible example?
@nicoddemus It appears that the issue I reported is invalid and that this is not the actual issue I am experiencing. My apologies for that. I might need some clarification on the intent/design of the package scope. Here is an explanation of the issue I am experiencing:
If I have multiple packages in my full overall test package, say test_foo; test_bar; test_baz, each with their own conftest.py and test modules, the tests execute in this order when I run the full overall test package:
See attached screenshot. Please advise if this is intended behavior. Thank you very much for your time!