Python programs operate on objects with explicit input, ownership and failure contracts.
Learning roadmap
This section contains 16 written lessons or quiz banks. Programs are verified on CPython 3.14.6. Standard-library lessons target 3.11+ syntax; lessons using data, web, machine-learning or testing packages state their tested dependencies separately. Framework programs use local test clients, not a deployed service. Read the stated limits before adapting a fixture into an application.
Owned tests and static checking
Read the contract, run its program and inspect the failure case.
- Pytest fixtures: isolated files and parameterized rejection tests
- Mypy static checks: annotations do not validate runtime payloads
- Python unittest.mock: inject a collaborator failure before publication
Generated cases and measured branches
Read the contract, run its program and inspect the failure case.
- Hypothesis property tests: compare generated cases with an independent contract
- Coverage.py branch coverage: execution paths are not correctness assertions
Selected mutation detection and explicit compatibility evidence
Read the contract, run its program and inspect the failure case.
- Python mutation testing: prove a suite rejects selected wrong implementations
- Python compatibility checks: parse syntax and execute contracts as separate evidence
Owned allocation observations
Read the contract, run its program and inspect the failure case.
Deterministic tests and doubles
Read the contract, run its program and inspect the failure case.
- Python testing: inject a clock to test expiry at the exact boundary
- Python testing: check a reconciliation relation without copying the implementation
- Python unittest.mock: patch the name the caller actually resolves
- Python testing: autospec catches a changed call signature
- Python testing: assert temporary cleanup after a failure
Grouped and asynchronous test cases
Read the contract, run its program and inspect the failure case.
- Python unittest subTest: label several cases without aborting the method
- Python IsolatedAsyncioTestCase: own async setup and cleanup per test
Await assertions
Read the contract, run its program and inspect the failure case.
Continue learning
Move between tutorial, collections, advanced material and practice using the subject tabs. The sidebar changes with each section; related examples keep one canonical lesson URL.
