The pytest fixture implementation is flexible enough to use fixtures like building blocks to build up test setup and teardown, and to swap in and out different chunks of the system (like swapping in Mongo for TinyDB). Because fixtures are so flexible, I use them heavily to push as much of the setup of my tests into fixtures as I can.
In this chapter, you looked at pytest fixtures you write yourself, as well as a couple of builtin fixtures, tmpdir and tmpdir_factory. You’ll take a closer look at the builtin fixtures in the next chapter.