Я решил это с помощью параметризации и косвенного = True
conftest.py
@pytest.fixture
def generate_random_user(_db, request):
user_type = request.param
if user_type == "no-subscription":
# Create User
yield _db
_db.drop_all()
elif user_type == "with-subscription":
pass
test.py
@pytest.mark.usefixtures("live_server", "client", "firefox_headless", "_db")
@pytest.mark.parametrize("generate_random_user", ["no-subscription"], indirect=True)
def test_checkout_new_customer(selenium, generate_random_user):
# Check if user has been created successfully
user5 = models.User.query.get(5)
print(user5)