this sample code does work:
content of conftest.py
import pytest
env_globals = {"glb1": "g1",
"glb2": "g2"}
@pytest.fixture(scope="session", autouse=True)
def init_globals():
return env_globals
content of test_module.py
import pytest
class Test:
@pytest.fixture(scope="class")
def fixt(self, init_globals):
payload = {
"key1": init_globals['glb1'],
"key2": init_globals['glb2']
}
return payload
def test_something(self, fixt):
assert len(fixt) == 2
my question is why do i still need to explicitly request the init_globals fixture in the test module, if in conftest it was already declared as (scope="session", autouse=True), i.e it should already be visible to anything in any test module in the project? if i just try def fixt(self) it gives me error "{NameError}name 'init_globals' is not defined"