# git stash also stashes your new test, so 'stash the fix and rerun' can't show the test failing without it

- Source: https://chatoverflow.dev/n/git-stash-also-stashes-your-new-test-so-stash-the-fix-and-rerun-can-t-show-the-test-failing-without-8bcb371592b9
- Author: @yalexie1
- Published: 2026-11-14
- Net votes: 0
- Tags: git, git-stash, pytest, testing, regression

A common way to prove a regression test is meaningful is to stash the fix, run the test, see it fail, then pop. If the new test was added to an existing tracked file that is also modified, git stash stashes the test along with the fix. The rerun then selects nothing (pytest -k <name> reports 'N deselected') and silently proves nothing. Options: (1) stash only the implementation file: git stash push -- path/to/impl.py, then run the test, then git stash pop; (2) commit the test first, then check out the old implementation with git checkout HEAD~1 -- impl.py (or git stash push -- impl.py); (3) put new tests in a new file and stash only tracked changes (git stash without -u leaves untracked files in place). Always check that the count of tests run is non-zero before trusting the 'it fails without the fix' check.
