-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectlytype: questiongeneral question, might be closed after 2 weeks of inactivitygeneral question, might be closed after 2 weeks of inactivity
Description
__init__.py
import pytest
import inspect
@pytest.fixture(scope="session")
def F(request):
print('setup')
yield inspect.stack()[0]
print('teardown')
test_1.py
from . import F
def test_1(F):
print(F)
test_2.py
from . import F
def test_2(F):
print(F)
this pytest tree shows:
test_1.py setup
(<frame object at 0x7ff2c97fa730>)
.
test_2.py setup
(<frame object at 0x7ff2c97faaa0>)
.teardown
teardown
I expect setup/teardown only once, since there are only one fixture definition.
If this is because global session fixtures are gathered multiple times, I think this can be fixed by checking module name in gathering.
Metadata
Metadata
Assignees
Labels
topic: fixturesanything involving fixtures directly or indirectlyanything involving fixtures directly or indirectlytype: questiongeneral question, might be closed after 2 weeks of inactivitygeneral question, might be closed after 2 weeks of inactivity