Is this a correct way to use setup_module? #12353
-
sys info: Here I have two files, #conftest.py
@pytest.fixture(scope="session", autouse=True)
def setup_module(request):
print('start conftest')
yield
print('stop conftest') #test.py
class Test():
@classmethod
def setup_class(cls):
print('setup class')
def test_func(self):
pass after running pytest, here is the output: test.py::Test::test_func start conftest
setup class
PASSEDstop conftest
start conftest
...
test.py::Test::test_func
setup class
PASSED
...
stop conftest |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
its not clear what you are asking for, your example has a fixture using that name while being session scoped a xunit style setup method would be defined in the module where it is wanted a fixture doesnt need to use the xunit names these days using fixtures is recommended over using xunit methods |
Beta Was this translation helpful? Give feedback.
its not clear what you are asking for,
setup_module
as per xunit would be a module level functionyour example has a fixture using that name while being session scoped
a xunit style setup method would be defined in the module where it is wanted
a fixture doesnt need to use the xunit names
these days using fixtures is recommended over using xunit methods