VSCode pytest test discovery fails

后端 未结 10 716
南方客
南方客 2020-12-15 16:25

Pytest test discovery is failing. The UI states:

Test discovery error, please check the configuration settings for the tests

The output window s

10条回答
  •  忘掉有多难
    2020-12-15 17:22

    Before begin the tests discovery, check that python.testing.cwd points correctly to your tests dir and your python.testing.pytestEnabled is set to true.

    Once those requirements are set correctly, run tests discovery and its output (see OUTPUT window). You should see something like this:

    python $HOME/.vscode/extensions/ms-python.python-$VERSION/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir $ROOT_DIR_OF_YOUR_PROJECT -s --cache-clear
    Test Discovery failed: 
    Error: ============================= test session starts ==============================
    
    collected N items / M errors
    ...
    

    It's important to highlight here the last line: collected N items / M errors. The following lines will contain info about the tests discovered by pytest. So your tests are discoverable but there are errors related to their correct execution.

    The following lines will contain the errors which in most of the cases will be related to an incorrect import.

    Check that all your dependencies have been downloaded previously. If you are working with specific versions of dependencies (on therequirements.txt file you have something like your_package == X.Y.Z) be sure that it's the right version that you need to.

提交回复
热议问题