mardi 3 mai 2016

Call the same fixture multiple time in py.test

I'm using py.test 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 didn't find any topic on that point (or maybe I'm not using the rights keywords :/)

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.

Any ideas on what direction I should be looking on ?

Thanks a lot !

Aucun commentaire:

Enregistrer un commentaire