简体   繁体   中英

VScode python unittest test discover issue

I can run all my tests from cmd

(venv) PS D:\13_projects\xxx> python -m unittest discover -s .\tests\ -p 'test*.py' -b
...................................
----------------------------------------------------------------------
Ran 35 tests in 0.426s

OK

but no tests are discovered by the VScode (the same test configuration settings and virtual environment is used)

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

I'm sure it worked in past. As far as I realize I didn't change any settings.

This is my version of VScode

在此处输入图片说明

Do you have any hints what to check?

A couple of things to try:

  1. Go through the process of configuring the tests in VSCode. Type ctrl+shift+p, then search "Python: Configure Tests". 配置测试
  2. See what the test output in VSCode shows when discovering the tests. 测试日志
  3. Ensure __init__.py files are included in your project folders, and possibly even the tests folder (even though testing doesn't usually require this). I've noticed strange behavior here before but don't recall exactly what the fix was.

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