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
When using indirect parameterization with a module-scoped fixture, the fixture is invoked multiple times instead of once per module. This behavior seems incorrect, as it defeats the purpose of having a module-scoped fixture.
Code to Reproduce:
import pytest
@pytest.fixture(scope='module')
def setup_environment():
print("Setting up environment")
yield
print("Tearing down environment")
@pytest.fixture(scope='module')
def config(request):
print("Setting up config")
return request.param
@pytest.mark.parametrize('config', ['config1', 'config2'], indirect=True)
def test_example(setup_environment, config):
print(f"Running test with config: {config}")
Output:
$ pytest -s
Setting up config
Setting up environment
Running test with config: config1
.Tearing down environment
Setting up config
Setting up environment
Running test with config: config2
.Tearing down environment
Expected Behavior:
The setup_environment fixture should be invoked only once per module, not once per test function.
Additional Context:
This issue disrupts test isolation and setup efficiency, especially in cases where the environment setup is costly.
tests.py Setting up environment
Setting up config
Running test with config: config1
.Setting up config
Running test with config: config2
.Tearing down environment
Description:
When using indirect parameterization with a module-scoped fixture, the fixture is invoked multiple times instead of once per module. This behavior seems incorrect, as it defeats the purpose of having a module-scoped fixture.
Code to Reproduce:
Output:
Expected Behavior:
The setup_environment fixture should be invoked only once per module, not once per test function.
Additional Context:
This issue disrupts test isolation and setup efficiency, especially in cases where the environment setup is costly.
Pip list:
OS and version:
The text was updated successfully, but these errors were encountered: