right now I'm trying to convert some API tests from Nose to Pytest. When I tried to do that I faced a little problem: Pytest doesnt support the "setup_package()" functionality. The "setup_package()" is in the __init__.py file of where the tests are.
This is the directory structure:
tests/__init__.py
test_001.py
test_002.py
...
A easy solution would be to give the setup_package() function a fixture, but the problem here is, that my setup_package() is accessing a global counter in the __init__.py. So that the __ini__.py file looks like that:
counter_id = 0
def setup_package():
global counter
counter = some_function()
def teardown_package():
global counter
clear_object(counter_id)
Im pretty sure, that there is very easy solution to migrate this but as I'm new to Pytest I want to know the "pytestian" way of migrating this particular example to Pytest! My first idea was to use a fixture with params functionality, but I'm not sure if it's a good way to migrate at all.