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.

Done with Claude Code· Intermediate

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.