Tips for getting coding agents to write good Python tests
AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story. The source provided limited text, so this summary is brief.
Why it matters
Developers using coding agents can directly apply Simon Willison's concrete prompting tactics to get higher-quality Python test suites with less manual cleanup.
Simon Willison, a well-known programmer and writer, shared tips on his blog for getting AI coding assistants like Claude to write good Python tests. His main advice: name specific tools such as pytest-httpx for mocking network calls, and work in a project that already has a clean test suite, because the AI copies existing patterns. He also recommends pointing the agent at an example repository, like his datasette-enrichments project on GitHub, so it can imitate the testing style.
Willison's post argues that AI-written test quality depends mostly on project hygiene rather than clever prompting: agents mirror the patterns already in your codebase. Teams adopting AI coding tools should invest in clean, well-patterned pytest suites before delegating test writing, since duplicated setup code is the main anti-pattern to police. No costs, benchmarks or timelines are given; the value is practical workflow guidance for engineering leads.
Willison works in Python because pytest is heavily represented in model training data, so Claude reliably knows commands like 'use pytest-httpx to mock the endpoints' or 'refactor to pytest.mark.parametrize' and 'extract common setup into a fixture'. The main anti-pattern he flags is duplicated test setup code, which he tolerates less in implementation than tests. His strongest tactic is pasting a prompt telling the agent to clone a reference repo, e.g. datasette/datasette-enrichments, to /tmp and imitate its testing patterns.
Read the original
This summary exists to save you time, not to replace the source.
Key terms
pytest pytest-httpx pytest.mark.parametrize Claude datasette-enrichments GitHub Hacker News
Was this summary useful?
One click, anonymous. It tells us which summaries to re-run.
Related reading
Node graph engine that runs big diffusion models on 4GB VRAM
ComfyUI's asynchronous weight streaming lets large diffusion models run on 4GB VRAM, meaning practitioners with modest GPUs no longer need expensive hardware for local image, video and audio generation.
iCloud apps for Windows, Linux and Android, written in Rust
Skykeep gives Rust-based native iCloud apps for Windows, Linux and Android, ending the iCloud.com-browser workaround for non-Apple-device users.
An open-source video editor covering auto-captions, voice isolation and keyframes
Very little for most professionals: Concat is a free, pre-1.0 open-source video editor that makes basic auto-captions and voice isolation available on mobile and desktop without a subscription.
OpenGame: turn your local coding agent into a full-stack game studio
Developers with a local coding agent can now scaffold full playable 3D games, art, music, testing, publishing, instead of only refactoring code, opening a path from hobby coding to shippable mini-games.
A Flipper Zero CAN bus toolkit for Tesla, from $14
An open-source $14 ESP32/Flipper Zero build replicates $200+ commercial Tesla dongles at the CAN bus level, including FSD region-gate bypass and TLSSC restore, with real VIN-ban risk.