TIL: Subtests in pytest 9.0.0+
AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.
Why it matters
pytest 9.0.0's new subtests give Python developers a faster, more flexible alternative to @pytest.mark.parametrize, changing how parameterized tests can be written.
pytest, a popular tool for testing Python code, added a feature called subtests in version 9.0.0, released November 5, 2025. Instead of writing one test that repeats with different inputs using the old 'parametrize' decorator, developers can now loop inside the test and check each case separately. This is marginally faster and lets tests be built dynamically after setup code runs.
pytest 9.0.0 shipped on November 5, 2025 with a subtests feature as an alternative to the widely used parametrize decorator. Willison reports it runs faster and allows test cases to be generated after setup code executes. Teams doing Python testing could cut test runtime slightly, though nothing breaks immediately; adoption is optional. He used Claude Code to port Datasette tests to the new pattern.
pytest 9.0.0 (released 2025-11-05) introduces subtests via a 'subtests' fixture: wrap assertions in 'with subtests.test()' to get per-case pass/fail reporting. Willison shows a @pytest.mark.parametrize test over app.SETTINGS rewritten as a for-loop with subtests.test(setting=setting.name). Benefits cited: slightly faster execution and programmatic creation of subtests after setup code. He had Claude Code port several Datasette tests (PR #2609) to the pattern.
Read the original
This summary exists to save you time, not to replace the source.
Key terms
Was this summary useful?
One click, anonymous. It tells us which summaries to re-run.
Related reading
Code-driven AI illustrations are more useful than images from dedicated image models
Code-driven AI illustrations let designers edit assets directly in code, saving time on iteration and ensuring consistency, which is a game-changer for teams that need rapid, reusable visual content.
A hierarchical note-taking app for building large personal knowledge bases
Trilium lets users build and navigate massive personal knowledge bases without duplicating content, saving time on organization and retrieval.
Desktop apps in Go with native UI or web frontend
Go developers can now ship cross-platform desktop and mobile apps in a single small binary without cgo or heavy runtimes, cutting build complexity and deployment size.
OpenBitFun: an agent workspace with four harness modes and phone remote control
OpenBitFun lets agents run on any machine and be controlled from a phone, eliminating the need to choose between local power and remote access, saving developers time switching contexts.
Intel One Mono: a monospaced font designed with low-vision developers
Developers with low vision or eye fatigue can read code more clearly, reducing errors and improving productivity.