Typorithm learning path
pytest: reliable Python tests
Write tests that reject real defects: assertions, boundaries, exception contracts, parameter cases, numerical tolerances, fixture ownership, cleanup, files, terminal output, environment values, injected dependencies, logs, scope, strict expected failures, SQLite transactions and deterministic inputs. 18 topics with six substantial sections, complete runnable modules, controlled mistakes, small independent tasks, two hints and explained native questions. Type focused code on a computer; run actual pytest in the local browser playground or downloadable lab. All examples use synthetic owned data, without live services or production databases.

Study with a practical destination
Use the linked lessons in order, complete the lab and explain the decisions without the reference. Select the path and depth that match your role.
pytest: observable evidence for Python behavior
Before starting: Python functions, collections, exceptions and basic imports. Start with small tests before fixtures and integration boundaries.
Build and explain: Write a deterministic regression suite with owned state, clear failure phases and independently reasoned expected results.
- 1. A test is an observable contract
- 2. Boundaries and test discovery
- 3. Errors are part of the API
- 4. Parameter cases with readable identities
- 5. Numerical assertions with honest tolerances
- 6. Fresh fixtures and visible dependencies
- 7. Yield fixtures and reliable cleanup
- 8. Test files in an owned temporary directory
- 9. Capture stdout and stderr deliberately
- 10. Monkeypatch environment without leaks
- 11. Fake the boundary where it is looked up
- 12. Assert log records, not incidental formatting
- 13. Parameterized fixtures and small matrices
- 14. Fixture scope and conftest ownership
- 15. Skips and strict expected failures
- 16. Owned SQLite integration and rollback
- 17. Deterministic clocks and owned random state
- 18. Capstone: a regression suite that earns its green run
Review evidence: Type focused tests, solve a small new boundary, run real pytest and demonstrate a plausible mutation that the new assertion detects. Native reasoning progress is separate from test execution.
Your learning path
0 of 18 lessons completed
Saved on this device
Module 1 · 1 lessons
A test is an observable contract
Turn a requirement into a named example with an independent expected value.
Module 2 · 1 lessons
Boundaries and test discovery
Test both sides of a decision and make collection visible.
Module 3 · 1 lessons
Errors are part of the API
Check the expected exception and keep the protected block narrow.
Module 4 · 1 lessons
Parameter cases with readable identities
Replace repetition with a small table of independent examples.
Module 5 · 1 lessons
Numerical assertions with honest tolerances
Choose absolute and relative error limits from the quantity being tested.
Module 6 · 1 lessons
Fresh fixtures and visible dependencies
Separate reusable setup from the behavior each test asserts.
Module 7 · 1 lessons
Yield fixtures and reliable cleanup
Own a resource, expose it for a test, and release it even when that test fails.
Module 8 · 1 lessons
Test files in an owned temporary directory
Verify bytes and Unicode using a path supplied for this test.
Module 9 · 1 lessons
Capture stdout and stderr deliberately
Assert user-visible reports without conflating output and return values.
Module 10 · 1 lessons
Monkeypatch environment without leaks
Control present and missing settings for one test at a time.
Module 11 · 1 lessons
Fake the boundary where it is looked up
Inject a small callable instead of contacting a service.
Module 12 · 1 lessons
Assert log records, not incidental formatting
Capture severity and message while keeping diagnostics free of payload data.
Module 13 · 1 lessons
Parameterized fixtures and small matrices
Vary a reusable dependency while keeping the case count understandable.
Module 14 · 1 lessons
Fixture scope and conftest ownership
Reuse stable setup while giving each test its own mutable working copy.
Module 15 · 1 lessons
Skips and strict expected failures
Report limitations honestly and surface an unexpectedly fixed defect.
Module 16 · 1 lessons
Owned SQLite integration and rollback
Exercise a real transaction without using the application database.
Module 17 · 1 lessons
Deterministic clocks and owned random state
Inject time and a random generator instead of sleeping or seeding global state.
Module 18 · 1 lessons
Capstone: a regression suite that earns its green run
Combine validation, boundaries, side-effect checks and a controlled mutation.