skip to Main Content

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:

  1. Run the test: pipenv run pytest src/some/path/models.py
  2. The test fails, showing the correct error in traceback.
  3. Modify the method body.
  4. Run the test again.
  5. The test fails again, BUT the traceback shows old code, unmodified.

screen

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


  1. Chosen as BEST ANSWER

    Solved by clearing the local user cache:

    rm -rf ~/.cache/*
    

  2. Had the same issue and figured it out – the pytest i was running via pipenv run pytest ... was not actually part of the venv. I recommend you run it as pipenv run python -m pytest ...

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search