You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using pytest 8.3.3 and have encountered unexpected behavior with fixtures scoped at the "package" level in a workspace structured as follows:
Observed Behavior
The setup_teardown_group1 fixture (defined in group1/conftest.py with scope="package") seems to be applied to all test items (tc1, tc2, tc3, and tc4), rather than being limited to only tests in the group1 directory.
Expected Behavior
I expected setup_teardown_group1 to apply exclusively to tests in the group1 directory and setup_teardown_group2 to apply only to tests in group2.
Question
Is this the intended behavior for "package" scoped fixtures in nested directories, or is it a potential issue with scope inheritance in pytest?
Thanks in advance for your assistance in understanding this behavior.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am currently using pytest 8.3.3 and have encountered unexpected behavior with fixtures scoped at the "package" level in a workspace structured as follows:
Test/
├── conftest.py # Fixture with scope="session"
├── group1/
│ ├── conftest.py # Fixture with scope="package" (name: setup_teardown_group1)
│ ├── tc1.py
│ └── tc2.py
└── group2/
├── conftest.py # Fixture with scope="package" (name: setup_teardown_group2)
├── tc3.py
└── tc4.py
Observed Behavior
The setup_teardown_group1 fixture (defined in group1/conftest.py with scope="package") seems to be applied to all test items (tc1, tc2, tc3, and tc4), rather than being limited to only tests in the group1 directory.
Expected Behavior
I expected setup_teardown_group1 to apply exclusively to tests in the group1 directory and setup_teardown_group2 to apply only to tests in group2.
Question
Is this the intended behavior for "package" scoped fixtures in nested directories, or is it a potential issue with scope inheritance in pytest?
Thanks in advance for your assistance in understanding this behavior.
Beta Was this translation helpful? Give feedback.
All reactions