I would stay away from pytest fixtures - they're what put me off it for a few years. I use pytest in an xunit style, using unittest.TestCase as a base class.
I don't really like class based unit tests (most of my Python code is already "functionalish")
I've worked on a large code base using pytest fixtures and they can go from cute magic trick to arcane sorcery with very little clue to their origin.
Ah ah that's true, but documentation should help a little bit. The cool thing about pytest fixtures is that they can be interdependent, they can be executed once per test, once per module, once per session and so on. They do speed up setup if used correctly. They can become quite obscure as you said.
A huge advantage of pytest/functional testing with fixtures is that they make dependency injection very explicit and they make for easier refactoring. You can mostly cut and paste tests around
See above for my reasoning on code organisation. I tend to write quite functional code too but I'll have a TestCase class with multiple test_* methods for testing the function.
I stand by my mistrust of pytest fixtures though - sorcery and black magic. (But I will go and take another look at them on your recommendation).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't really like class based unit tests (most of my Python code is already "functionalish")
Ah ah that's true, but documentation should help a little bit. The cool thing about pytest fixtures is that they can be interdependent, they can be executed once per test, once per module, once per session and so on. They do speed up setup if used correctly. They can become quite obscure as you said.
A huge advantage of pytest/functional testing with fixtures is that they make dependency injection very explicit and they make for easier refactoring. You can mostly cut and paste tests around
See above for my reasoning on code organisation. I tend to write quite functional code too but I'll have a
TestCase
class with multipletest_*
methods for testing the function.I stand by my mistrust of pytest fixtures though - sorcery and black magic. (But I will go and take another look at them on your recommendation).