I have a Django 4.0.6 project, Python 3.9.15, Ubuntu 22.10, pipenv 2022.10.25, pytest 7.1.2
The test output was cached somewhere and now any modification is ignored unless I delete the method.
The steps I performed:
- Run the test:
pipenv run pytest src/some/path/models.py
- The test fails, showing the correct error in traceback.
- Modify the method body.
- Run the test again.
- The test fails again, BUT the traceback shows old code, unmodified.
Removing the method solves the problem, but any modification made to the method source makes it appear again in traceback, UNMODIFIED.
Does pipenv/pytest/whatever cache the source somewhere?
pipenv run pytest src/some/path/models.py --cache-clear
did not help.
As well as removing the .pytest_cache/
.
I tried removing the venv/some/path/__pycache__/models.cpython-39.pyc
file (and all compiled *.pyc files in venv)
But nothing seem to help. The same traceback appears every time I run tests.
2
Answers
Solved by clearing the local user cache:
Had the same issue and figured it out – the
pytest
i was running viapipenv run pytest ...
was not actually part of the venv. I recommend you run it aspipenv run python -m pytest ...