How do I ensure that not only the order is respected, but the execution is performed immediately after? #79
Unanswered
stefanoborini
asked this question in
Q&A
Replies: 1 comment 2 replies
-
If you want to have a clearly defined order, it is probably better to use ordering by ordinal numbers instead of before/after markers, e.g. @pytest.mark.order(0)
def test_1(mod_fixture):
# does something with the fixture, alters its state to StateA
def test_2(mod_fixture):
# also does something with the fixture, alters its state to StateB
@pytest.mark.order(1)
def test_3(mod_fixture):
# assumes it starts from StateA, but in reality fixture is in StateB |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
From my brief experimentation, the order(after) only ensures that a test will be performed after, not necessarily immediately after. If you have a session or module fixture whose state you are relying upon, you might end up starting the "after" test when the fixture state is no longer the one of the original test.
example:
This results in the following execution:
Sure, I can rely on moving the code, but it would be better to be able to specify that I want test_3 immediately after test_1.
Maybe it can already be done, but I could not find how to do so.
Beta Was this translation helpful? Give feedback.
All reactions