I have a fixture that I need to pass a parameter so I can do different things based off of that parameter. Is this possible? For example:
I have this test:
test_can_invite_user_to_collaborate_extension(collaborate_uncollaborate_with_user)
which collaborates an exension with another user. The fixture in the test collaborates and un-collaborates the extension. I need to pass a parameter to the function to say that the collaboration is going to be done in the test_can_invite_user_to_collaborate_extension function and to skip that part so that only the teardown of un-collaborating happens.
Here is what I have tried:
@kit.mark(...)
def test_can_invite_user_to_collaborate_extension(collaborate_uncollaborate_with_user):
"""tests that extension (owner | admin) can invite a user to join an extension
team and they will be assigned the appropriate role
"""
... = collaborate_uncollaborate_with_user(run_collaboration=False)
...
and in the actual fixture:
@pytest.fixture(scope="function")
def collaborate_uncollaborate_with_user(define_assets_and_login):
def _collaborate_uncollaborate_with_user(run_collaboration=None):
... = define_assets_and_login
if run_collaboration:
...
return ...
yield _collaborate_uncollaborate_with_user()
teardown that I want to always occur...
(I got the idea for doing this approach here) But what happens is it runs the fixture before the test itself. Is there a way to do what I am trying to accomplish?
Aucun commentaire:
Enregistrer un commentaire