pytest-testmon is a pytest plugin that runs only the tests affected by your changes. It records which code each test executes (with Coverage.py) and, on the next run, deselects the tests whose code has not changed. It compares file contents, not commits, so it works with uncommitted changes and without git. Tests that failed last time always run again.
# install pip install pytest-testmon # first run: all tests, records the dependencies in .testmondata pytest --testmon # change some code # next runs: only the affected tests pytest --testmon
How this can be reliable in a dynamic language: Determining affected tests.