Dealing with fixtures is one of the areas where pytest really shines.
This is rather an incredible understatement.
The xunit style of test fixtures that is used in both unittest and nose is of course supported with with pytest. And pytest rocks at this.
But there is another way to deal with fixtures. It’s to think of fixtures as a set of resources that need to be set up before a test starts, and cleaned up after. Test functions, methods, classes, name wich fixtures they need. This way, fixtures aren’t set up for tests that don’t need them.
This focus on the fixture as a modular resource, possibly set up once for many tests, or perhaps for each test, is a really cool way to treat fixtures.
However, it took me a while to really get my head around it.
I’ve been thinking about it for months, and have started many, many attempts at a ‘pytest fixture’ post.