VScode unittest test discovery settings for django app

Viewed 164

I have a django app with some unittests. I want to run\debug them in VScode v.1.59.1.

My ./vscode/settings.json looks like this:

{
    "python.testing.unittestArgs": [
        "-v",
        "-s",
        "./routes/tests",
        "-p",
        "test*.py"
    ],
    "python.testing.pytestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.unittestEnabled": true,
}

When I try to run\discover tests I have this output:

ImportError: Failed to import test module: test_utils
...
django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

When I try to run tests in regular django way with command:

python manage.py test

the tests working fine.

Please help me setup my VScode to run django unittests.

P.S: I can not install pytest, this should be done without installation of any new modules.

0 Answers
Related