Summary
In this chapter, we delved into one of pytest's most famous features: fixtures. We have seen how they can be used to provide resources and test functionality, and how to concisely express setup/teardown code. We learned how to share fixtures, using conftest.py files; to use fixture scopes, to avoid creating expensive resources for every test; and to autouse fixtures that are executed for all tests in the same module or hierarchy. Then, we learned how to parametrize fixtures and use marks from them. We took an overview of various built-in fixtures, and closed the chapter with some short discussions about fixtures in general. I hope you enjoyed the ride!
In the next chapter, we will explore a little of the vast pytest plugin ecosystem ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access