Skip to content

run a test more than once with pytest.main([]) #10932

Answered by jgzzzz
jgzzzz asked this question in Q&A
Discussion options

You must be logged in to vote

the pure pytest solution was to add fixtures to the tests on the input arguments, and no longer use/passed init and deinit as tests as on my post above:

@pytest.fixture
def init_system():
    print("This is init_system")


@pytest.fixture
def deinit_system():
    yield
    print("this is deinit_system ")

I have explain how I added the fixtureas after test collection on this post: https://stackoverflow.com/questions/76079122/run-a-test-more-than-onces-with-pytest-main/76140534#76140534

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jgzzzz
Comment options

@jgzzzz
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jgzzzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants