← All learning paths

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.

18Focused modules
18Lessons to explore
54Typing drills
pytest: reliable Python tests course illustration

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. 1. A test is an observable contract
  2. 2. Boundaries and test discovery
  3. 3. Errors are part of the API
  4. 4. Parameter cases with readable identities
  5. 5. Numerical assertions with honest tolerances
  6. 6. Fresh fixtures and visible dependencies
  7. 7. Yield fixtures and reliable cleanup
  8. 8. Test files in an owned temporary directory
  9. 9. Capture stdout and stderr deliberately
  10. 10. Monkeypatch environment without leaks
  11. 11. Fake the boundary where it is looked up
  12. 12. Assert log records, not incidental formatting
  13. 13. Parameterized fixtures and small matrices
  14. 14. Fixture scope and conftest ownership
  15. 15. Skips and strict expected failures
  16. 16. Owned SQLite integration and rollback
  17. 17. Deterministic clocks and owned random state
  18. 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

01

Module 1 · 1 lessons

A test is an observable contract

Turn a requirement into a named example with an independent expected value.

0/1 complete
02

Module 2 · 1 lessons

Boundaries and test discovery

Test both sides of a decision and make collection visible.

0/1 complete
03

Module 3 · 1 lessons

Errors are part of the API

Check the expected exception and keep the protected block narrow.

0/1 complete
04

Module 4 · 1 lessons

Parameter cases with readable identities

Replace repetition with a small table of independent examples.

0/1 complete
05

Module 5 · 1 lessons

Numerical assertions with honest tolerances

Choose absolute and relative error limits from the quantity being tested.

0/1 complete
06

Module 6 · 1 lessons

Fresh fixtures and visible dependencies

Separate reusable setup from the behavior each test asserts.

0/1 complete
07

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.

0/1 complete
08

Module 8 · 1 lessons

Test files in an owned temporary directory

Verify bytes and Unicode using a path supplied for this test.

0/1 complete
09

Module 9 · 1 lessons

Capture stdout and stderr deliberately

Assert user-visible reports without conflating output and return values.

0/1 complete
10

Module 10 · 1 lessons

Monkeypatch environment without leaks

Control present and missing settings for one test at a time.

0/1 complete
11

Module 11 · 1 lessons

Fake the boundary where it is looked up

Inject a small callable instead of contacting a service.

0/1 complete
12

Module 12 · 1 lessons

Assert log records, not incidental formatting

Capture severity and message while keeping diagnostics free of payload data.

0/1 complete
13

Module 13 · 1 lessons

Parameterized fixtures and small matrices

Vary a reusable dependency while keeping the case count understandable.

0/1 complete
14

Module 14 · 1 lessons

Fixture scope and conftest ownership

Reuse stable setup while giving each test its own mutable working copy.

0/1 complete
15

Module 15 · 1 lessons

Skips and strict expected failures

Report limitations honestly and surface an unexpectedly fixed defect.

0/1 complete
16

Module 16 · 1 lessons

Owned SQLite integration and rollback

Exercise a real transaction without using the application database.

0/1 complete
17

Module 17 · 1 lessons

Deterministic clocks and owned random state

Inject time and a random generator instead of sleeping or seeding global state.

0/1 complete
18

Module 18 · 1 lessons

Capstone: a regression suite that earns its green run

Combine validation, boundaries, side-effect checks and a controlled mutation.

0/1 complete