Skip to main content
Loading page…
Python Mastery
Chapter 26
Lesson 2 of 4
Fixtures, Factories & Fake Data
Contents
Notes
Tutor
Note
Building on Pytest Fixtures
Loading activity…
Previous
1 / 11
Continue
Contents
Notes
Discussion
Tutor
38 min
11 activities
0 of 11 done
In this lesson
1
Building on Pytest Fixtures
2
conftest.py: Sharing Fixtures Across Test Files
3
Faker: Realistic Fake Data at Scale
4
Lab: Run a Faker Fixture Test
5
factory_boy: Model Factories
6
Parametrize: Run One Test with Many Inputs
7
Monkeypatching and Mocking in pytest
8
Fixture Scope: Which Scope for a Database Connection?
9
factory_boy Concepts
10
conftest.py: What Problem Does It Solve?
11
Keep Factories Minimal — Override in Tests
Objectives
Write pytest fixtures with appropriate scope (function/class/module/session)
Use yield fixtures for setup and teardown
Use conftest.py to share fixtures across test files
Generate realistic fake data with Faker
Define model factories with factory_boy
Parametrize tests and combine fixtures with parameters
Chapter 26 · Advanced Testing: Hypothesis, Faker & Coverage
Property-Based Testing with Hypothesis
Fixtures, Factories & Fake Data
Coverage & Test Quality
Multi-Env Testing with tox, nox & CI
Previous: Property-Based Testing with Hypothesis
Next: Coverage & Test Quality