
pytest fixtures: explicit, modular, scalable
For the course ‘Real World Test Automation with Pytest (Django app)’ by Eden Marco, in the section fixtures, I decided to get an in-depth understanding of this subject and completed on pytest website tutorial called “pytest fixtures: explicit, modular, scalable”. o In this tutorial, I learned: • What fixtures are • Requesting fixtures • Fixtures can request other fixtures • Fixtures are reusable • A test/fixture can request more than one fixture at a time • Fixtures can be requested more than once per test (return values are cached) • Autouse fixtures (fixtures you don’t have to request) • Scope: sharing fixtures across classes, modules, packages or session • Fixture scopes • Dynamic scope • Fixture errors • Teardown/Cleanup - yield fixtures • Fixture availability • conftest.py: sharing fixtures across multiple files • Fixtures from third-party plugins • Fixture instantiation order • Higher-scoped fixtures are executed first • Fixtures of the same order execute based on dependencies • Autouse fixtures are executed first within their scope • Using markers to pass data to fixtures • Factories as fixtures • Parametrizing fixtures • Using marks with parametrized fixtures • Automatic grouping of tests by fixture instances • Use fixtures in classes and modules with usefixtures • Using fixtures from other projects You can find this tutorial at https://docs.pytest.org/en/6.2.x/fixture.html#pytest-fixtures-explicit-modular-scalable