unittest fixtures behave the same regardless if you run them from python -m unittest or pytest.
There used to be more of a story here.
Way back in 2013 with pytest 2.3.5 (when this post was originally written) there was an issue that the behavior of whether or not to run the teardown for unittest fixtures if the setup failed was different.
However, that’s been fixed A LONG TIME AGO.
We’re now at pytest 8.4.1, and it’s been working the same for a long time.
And that’s a good thing.
We want people to be able to:
- take an existing unittest test suite
- start using pytest to run it
- switch to pytest style testing
- (optionally) re-write older unittests in pytest style as time permits and as the team finds it useful