VScode unittest configuration

Viewed 1306

I generally use this command to run my python (3.6) unittests from my project root directory

python -m unittest discover -v -s . -p "test_*.py"

However, I am not able to set it up using vscode. My configuration is

  "python.testing.unittestArgs": ["-v", "-s", ".", "-p", "test_*.py"],
  "python.testing.pytestEnabled": false,
  "python.testing.nosetestsEnabled": false,
  "python.testing.unittestEnabled": true

And I get the message

No tests discovered, please check the configuration settings for the tests.

How do I correct my vscode settings to run the unittests.

2 Answers

You could try changing "." in the configuration to the direct parent folder location of the test file.

like this:

"python.testing.unittestArgs": [
        "-v",
        "-s",
        "./A/a",
        "-p",
        "test_*.py"
    ],

Specify the exact location of the test file and it will be found.

Reference:This.

Setting

 "python.testing.unittestArgs": ["-v", "-s", ".", "-p", "test*.py"],

worked.

Related