Closed
Description
If we have session fixture customer
and redefine it with module scope, It can run after module fixtures.
tests/conftest.py
import pytest
@pytest.fixture(scope='session')
def customer():
return 1
@pytest.fixture(scope='module')
def module_transaction():
yield
tests/test_1.py
import pytest
@pytest.fixture(scope='module')
def customer(customer):
return customer + 1
def test_1(module_transaction, customer):
assert customer == 2
$ pytest tests --setup-only
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/voronin/projects/sintez_addons, configfile: setup.cfg
collected 1 item
test-module/test_1.py
SETUP M module_transaction
SETUP S customer
SETUP M customer (fixtures used: customer)
tests/test_1.py::test_1 (fixtures used: customer, module_transaction)
TEARDOWN M customer
TEARDOWN M module_transaction
TEARDOWN S customer
============================ no tests ran in 0.01s =============================