Saving any python file clears user-generated files in the pytest cache #21197
Labels
area-testing
bug
Issue identified by VS Code Team member as probable bug
info-needed
Issue requires more information from poster
triage-needed
Needs assignment to the proper sub-team
Type: Bug
Behaviour
Expected vs. Actual
I'm using a pytest fixture to download and cache some file with the
pytest.Cache
api. In the minimal reproduction below the file is saved in.pytest_cache/d/demo/the_file.txt
. However I noticed that the file gets re-downloaded way more often than expected. It turns out vscode is deleting the.pytest_cache/d/demo
directory any time a python file is saved in the workspace.Steps to reproduce:
Install
pytest
in a new virtualenv and createtest_demo.py
:Run
pytest
once. Notice that the output showscreate the file!
.Open the explorer you should see that
.pytest_cache/d/demo/the_file.txt
was created.Run
pytest
again. Notice that as expected the test no longer outputscreate the file!
.Now make a dummy modification to save the file
test_demo.py
.Immediately after saving the
.pytest_cache/d/demo
directory disappears.The log also shows that vscode is running a command to discover tests, with a suspicious --cache-clear argument:
If you try running
pytest
again you'll notice that the output showscreate the file!
.Diagnostic data
python.languageServer
setting: PylanceUser Settings
Extension version: 2023.8.0
VS Code version: Code 1.78.0 (252e5463d60e63238250799aef7375787f68b4ee, 2023-05-03T20:09:00.748Z)
OS version: Windows_NT x64 10.0.19045
Modes:
Sandboxed: No
Connection to 'wsl+Ubuntu' could not be established
Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2
The text was updated successfully, but these errors were encountered: