[Python] Python Unittest: No tests discovered in Visual Studio Code

Discussão em 'Python' iniciado por Stack, Abril 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to make the self-running feature of Visual Studio Code unit tests work. I recently made a change in the directory structure of my Python project that was previously like this:

    myproje\
    domain\
    __init__.py
    repositories\
    tests\
    __init__.py
    guardstest.py
    utils\
    __init__.py
    guards.py
    web\


    And my setup for unittest was like this:

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


    After the changes, the structure of the project was as follows:

    myprojet\
    app\
    controllers\
    __init__.py
    models\
    __init__.py
    entities.py
    enums.py
    tests\
    res\
    image1.png
    image2.png
    __init__.py
    guardstest.py
    utils\
    __init__.py
    guards.py
    views\
    static\
    templnates\
    __init__.py
    uml\


    After that the extension does not discover my tests anymore. I've tried to change the '-s' parameter to "./app/tests", ".tests", "./tests", "app/tests", "/app/tests", "app.tests", unsuccessfully .

    [​IMG]

    Continue reading...

Compartilhe esta Página