TIL: Run tests on every file save with watchfiles

Aug. 17, 2026 • TIL, Python, Testing, Django

Today I build a tiny feature for the FindThatRecipe Django app. Most of the time these days I would kick off an AI agent to do this, but this time I decided to code "by hand". I'm doing this every now and then. It reminds me of how I learned to code, and I'm enjoying it.

It turned out that part of the code didn't have any tests, so I added some. Going back and forth between the feature and the tests, I thought it would be nice to have part of the test suite just run on every file save.

I asked pi Agent about it (okay, I did use an AI agent after all...) and one of the options it gave was watchfiles by Samuel Colvin. I gave it a try, and I'm liking it.

I added it as a dev dependency:

uv add watchfiles --dev 

Here is how to run tests for one of the Django apps on every file change:

uv run watchfiles "python manage.py test myapp --keepdb" .

Happy TDD'ing!


Recent posts