POC for dynamically defining the scope of a fixture based on a cli parameter.
pytest -s -v --scope=session
========================================= test session starts ==========================================
platform linux -- Python 3.6.5, pytest-5.0.0, py-1.5.2, pluggy-0.12.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/pytest
collected 5 items
test_1.py::test_1
In some_resource()
In test_1()
PASSED
test_1.py::test_2
In test_2()
PASSED
test_1.py::test_alpha_3
In other_resource()
In test_3()
PASSED
test_1.py::test_alpha_4
In test_4()
PASSED
test_1.py::test_alpha_5
In test_5()
PASSED
In other_resource_fin()
In some_resource_fin()
======================================= 5 passed in 0.02 seconds =======================================
pytest -s -v --scope=function
========================================= test session starts ==========================================
platform linux -- Python 3.6.5, pytest-5.0.0, py-1.5.2, pluggy-0.12.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /tmp/pytest
collected 5 items
test_1.py::test_1
In some_resource()
In test_1()
PASSED
test_1.py::test_2
In test_2()
PASSED
test_1.py::test_alpha_3
In other_resource()
In test_3()
PASSED
In other_resource_fin()
test_1.py::test_alpha_4
In other_resource()
In test_4()
PASSED
In other_resource_fin()
test_1.py::test_alpha_5
In other_resource()
In test_5()
PASSED
In other_resource_fin()
In some_resource_fin()
======================================= 5 passed in 0.02 seconds =======================================