Ask Claude Code to write tests for an old Python app change
A developer used Claude Code to generate tests for an update in a legacy Python SaaS project and specified the mocks and assertion style they wanted.
- What they did
- After shipping a code change in an older Python SaaS system, the developer had Claude Code generate the related test coverage. They told it which API client methods to fake and asked for comparisons against complete expected results instead of checking values one by one. Even so, the agent added more mocks than requested, later tests drifted back to item-level checks, and it only repaired some missed call assertions after the developer called them out.
- How it went
- The developer came away unimpressed, saying it did not seem better than Cursor or JetBrains’ assistant and felt less dependable in places. There were no reported speed gains or test pass counts.
- Tips
- If you want consistent tests, name the exact dependencies to stub and specify the assertion style up front. Review the generated cases for extra mocking and for any switch back to narrower checks.
Try it yourself with Claude Code
I’ve updated [feature or behavior] in [file or module] of a legacy Python SaaS codebase. First inspect the current implementation and the nearby tests so you can follow the project’s patterns. Then create or revise tests for the new behavior, likely edge cases, and anything this change could affect. Use only these dependencies as mocks: [list the API client methods or other dependencies to mock]. Compare the full expected output structure wherever possible instead of asserting each element separately. Before making any application-code edits, show me the proposed change and wait for my approval. Once the test work is done, run the relevant tests and summarize what passed and what failed.
Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.
Get 3 agent uses like this every morning
With the day's top AI news. Free, and one click to unsubscribe.
Related agent uses
Turn GitHub issues into draft PRs with a long-running agent
A developer used Dots to read GitHub issues and produce rough pull request drafts, mostly as a starting point for later work.
Use Claude Code from a phone with a remote VM
They accessed Claude Code on an iPhone by pairing a Tailscale-only Vultr VM with Termius, mosh, and tmux.
Use Claude Code to control Windows apps in the background
A developer made an MCP server that lets Claude Code operate some Windows apps without taking over the desktop.
Create a Claude Code agent that can host its own MCP server
A developer assembled a custom agent with Claude Code and a few small scripts, then used it to generate an MCP server for later chats.
Match a pull request to repo style
A developer used Claude Code to bring a pull request in line with a repo’s style, but it only altered comments and left the code unchanged.
Use Claude Code to plan and run a legacy stack migration
An engineer used Claude Code to map, split, and execute a multi-repo migration while keeping each step tied to docs, tickets, and review.