September 2017
Intermediate to advanced
222 pages
5h 1m
English
In the previous chapter, you looked at what fixtures are, how to write them, and how to use them for test data as well as setup and teardown code. You also used conftest.py for sharing fixtures between tests in multiple test files. By the end of Chapter 3, pytest Fixtures, the Tasks project had these fixtures: tasks_db_session, tasks_just_a_few, tasks_mult_per_owner, tasks_db, db_with_3_tasks, and db_with_multi_per_owner defined in conftest.py to be used by any test function in the Tasks project that needed them.
Reusing common fixtures is such a good idea that the pytest developers included some commonly needed fixtures with pytest. You’ve already seen tmpdir and tmpdir_factory in use by the Tasks project in
Read now
Unlock full access