简体   繁体   中英

How to prevent vscode/ms-python from clearing test results?

The results of python tests are cached for only a short time in the VSCode MS python extension. Whether they succeeded or failed is only cached for a short while, and then they revert back to question marks again.

How to retain the results of the tests?


I think it has to do with this some logs that I see in the Output for "Python Test Log", which shows many (~30) of these lines:

python /home/.../.vscode/extensions/ms-python.python-2020.6.89148/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /home/projectdir --cache-clear -s

In particular the --cache-clear is suspicious, however I don't know what is triggering these outputs.

So my question is: how to remove --cache-clear from the call? Or maybe something else is going on entirely?

I too found myself in need of disabling this vscode behaviour.

I'm using pytest with the pytest-html plugin, and after all tests have run, as soon as i change a test file and save, this command is automatically run by vscode:

python c:\Users\username\.vscode\extensions\ms-python.python-2021.6.944021595\pythonFiles\testing_tools\run_adapter.py discover pytest -- --rootdir c:\Users\username\app\app-test-automation -s --cache-clear --html=report.html --self-contained-html tests

Which inevitably overwrite the.html test report.

I haven't found a way to remove the --cache-clear from the call.

BUT

You can disable the auto discovery of test (guilty of rerunning the command with the --cache-clear flag) by changing the following vscode setting:

Picture of the setting from the vscode settings menu

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM