Let's explain my question with an example:
import pytest
@pytest.fixture(scope="session", autouse=True)
def print_session():
print("session fixture")
yield
def setup_function(funtion):
print("function setup")
def test_printer1():
print("test test_printer1")
def test_printer2():
print("test test_printer2")
Currently, I am getting this:
example3.py::test_printer1
session fixture
function setup
test test_printer1
example3.py::test_printer2
function setup
test test_printer2
But, I want to get this:
example3.py::test_printer1
function setup
session fixture
test test_printer1
example3.py::test_printer2
function setup
test test_printer2
Notice that setup_function must be executed prior to every single test case.
¿Is there any way to achieve such an aim? I mean to have a setup_function
that gets executed prior to any fixture disregarding its scope on Pytest.