pytest run only the changed file?

To add to @The Compiler's answer above, you can get pytest-testmon and pytest-watch to play together by using pytest-watch's --runner option:

ptw --runner "pytest --testmon"

Or simply:

ptw -- --testmon

One possibility is using pytest-testmon together with pytest-watch.

It uses coverage.py to track which test touches which lines of code, and as soon as you change a line of code, it re-runs all tests which execute that line in some way.

Tags:

Python

Pytest