I'm using Pytest to write some tests in Python.
I'm using the following fixture in order to create a user and user it in my test, then delete it after the test (finalizer):
@pytest.fixture(scope='function')
def test_user(request):
def finalizer():
delete_the_user()
request.addfinalizer(finalizer)
return user()
with delete_the_user()
and user()
two functions not detailed here.
The problem is: I'd like to use 2 users for some of my tests.
I've tried to call the fixture like that:
def test_function(test_user_1 = test_user, test_user_2 = test_user):
# Test here
without success.
How can I use the same fixture more than once in a test?
The only ways to do this I can think of are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With