Skip to content

Django test discovering #24991

Open

Description

@Zankroh

Type: Bug

Behaviour

When trying to discover Django unit tests, the command manage.py fails with the error error: argument -v/--verbosity: expected one argument.
I'm using Python 3.12.4 and Django 5.2

Steps to reproduce:

  1. Open a Django project
  2. Go to Testing tab
  3. Click refresh button

Diagnostic data

Output for Python in the Output panel

2025-04-18 11:48:31.360 [info] Discover tests for workspace name: accounting - uri: c:\Users\xxxxx\Projects\accounting
2025-04-18 11:48:31.361 [info] Discovering unittest tests for workspace c:\Users\xxxxx\Projects\accounting with arguments: c:\Users\xxxxx\.vscode\extensions\ms-python.python-2025.5.2025041601-win32-x64\python_files\unittestadapter\discovery.py,--udiscovery,-v,-s,.,-p,*test.py

2025-04-18 11:48:31.367 [info] > .\env\Scripts\python.exe ~\.vscode\extensions\ms-python.python-2025.5.2025041601-win32-x64\python_files\unittestadapter\discovery.py --udiscovery -v -s . -p *test.py
2025-04-18 11:48:31.367 [info] cwd: .
2025-04-18 11:48:31.519 [info] MANAGE_PY_PATH is set, running Django discovery with path to manage.py as: $C:\Users\xxxxx\Projects\accounting\manage.py
Running Django tests with command: ['c:\\Users\\xxxxx\\Projects\\accounting\\env\\Scripts\\python.exe', 'C:\\Users\\xxxxx\\Projects\\accounting\\manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner', '-v', '-s', '.', '-p', '*test.py']

2025-04-18 11:48:34.236 [error] usage: manage.py test [-h] [--noinput] [--testrunner TESTRUNNER] [--failfast]
                      [-t TOP_LEVEL] [-p PATTERN] [--keepdb]
                      [--shuffle [SEED]] [-r] [--debug-mode] [-d]
                      [--parallel [N]] [--tag TAGS]
                      [--exclude-tag EXCLUDE_TAGS] [--pdb] [-b]
                      [--no-faulthandler] [--timing] [-k TEST_NAME_PATTERNS]
                      [--durations N] [--version] [-v {0,1,2,3}]
                      [--settings SETTINGS] [--pythonpath PYTHONPATH]
                      [--traceback] [--no-color] [--force-color]
                      [test_label ...]
manage.py test: error: argument -v/--verbosity: expected one argument

Django test discovery process exited with non-zero error code See stderr above for more details.

2025-04-18 11:48:34.237 [info]

Extension version: 2025.5.2025041601
VS Code version: Code 1.99.3 (17baf841131aa23349f217ca7c570c76ee87b957, 2025-04-15T23:18:46.076Z)
OS version: Windows_NT x64 10.0.26100
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.4
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
  • Value of the python.languageServer setting: Pylance
User Settings


envFile: "<placeholder>"

languageServer: "Pylance"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true

Installed Extensions
Extension Name Extension Id Version
andromeda Eli 1.8.2
auto-close-tag for 0.5.15
auto-rename-tag for 0.1.10
ayu tea 1.0.5
beardedicons Bea 1.18.0
beardedtheme Bea 10.0.0
better-comments aar 3.0.2
change-case wma 1.0.0
color-info bie 0.7.2
copilot Git 1.303.0
copilot-chat Git 0.26.5
Cyberpunk max 1.2.14
dbml-erd-visualizer boc 0.5.0
debugpy ms- 2025.6.0
deepdark-material Nim 3.3.1
dotenv mik 1.0.1
dynstat-midnight dyn 1.9.6
emoji Per 1.0.1
errorlens use 3.25.0
even-better-toml tam 0.21.2
explorer-exclude Pet 1.3.2
font-awesome-codes-html med 0.0.7
git-graph mhu 1.30.0
gitignore cod 0.10.0
hackthebox sil 0.2.9
henna htt 0.11.0
highlight-matching-tag vin 0.11.0
html-css-class-completion Zig 1.20.0
indent-nested-dictionary mge 0.0.4
intellicode-api-usage-examples Vis 0.2.9
intellij-idea-keybindings k-- 1.7.4
js-debug ms- 1.97.1
js-debug-companion ms- 1.1.3
json-tools eri 1.0.2
learn-with-sumit-theme Sum 11.1.0
live-server ms- 0.4.15
material-icon-theme PKi 5.21.2
monokai-plusplus dca 2.0.4
night-owl sdr 2.1.1
pdf tom 1.2.2
postman-for-vscode Pos 1.11.2
powershell ms- 2025.0.0
python ms- 2025.5.2025041601
python-docstring-highlighter rod 0.2.4
python-theme est 2.4.0
remote-explorer ms- 0.4.3
remote-ssh ms- 0.119.0
remote-ssh-edit ms- 0.87.0
ruff cha 2025.22.0
RunOnSave eme 0.2.7
selectline-statusbar tom 0.0.2
shades-of-purple ahm 7.3.2
sqltools mtx 0.28.4
sqltools-driver-mysql mtx 0.6.4
stats-bar njz 0.5.2
synthwave-vscode Rob 0.1.18
test-adapter-converter ms- 0.2.1
theme-bluloco-dark ulo 3.7.6
theme-dracula dra 2.25.1
theme-panda tin 1.4.0
tokyo-night enk 1.1.2
tokyo-panda-theme eff 1.12.0
vetur oct 0.37.3
vsc-python-indent Kev 1.21.0
vscode-ansi ili 1.1.7
vscode-commandbar gsp 0.3.1
vscode-commands fab 2.0.2
vscode-coverage-gutters rya 2.13.0
vscode-dbml mat 0.4.1
vscode-django bat 1.15.0
vscode-eslint dba 3.0.10
vscode-html-css ecm 2.0.13
vscode-intelephense-client bme 1.14.4
vscode-js-profile-table ms- 1.0.10
vscode-language-pack-fr MS- 1.99.2025041609
vscode-log-viewer ber 0.14.1
vscode-phpfmt kok 1.2.41
vscode-pylance ms- 2025.4.1
vscode-sort-json ric 1.20.0
vscode-sqlite ale 0.14.1
vscode-test-explorer hbe 2.22.1
vscode-yaml red 1.17.0
vscodeintellicode Vis 1.3.2
vue znc 0.12.0
xml Dot 2.5.1
System Info
Item Value
CPUs 12th Gen Intel(R) Core(TM) i7-1260P (16 x 2496)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.70GB (12.40GB free)
Process Argv --crash-reporter-id 96bbfc2b-23da-4f22-8267-b6ead6cf47ab
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscod805:30301674
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyonecf:30548226
962ge761:30959799
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
9064b325:31222308
copilot_t_ci:31222730
e5gg6876:31282496
cp15370_t:31280197
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
31787653:31262186
3e8i5726:31271747
996jf627:31283433
usemplatestapi:31288272
7bj51361:31289155
747dc170:31275177
aj496949:31278748
aj953862:31281341

Activity

  1. eleanorjboyd commented on May 27, 2025

    @eleanorjboyd

    what are in the arguments in the setting for python. If you open your settings look for python.testing.unittest and there there might be an incorrect argument?

  2. mygzi commented on May 27, 2025

    @mygzi

    Not OP, but I observe this error specifically when python.testing.unittest is unspecified. Including the setting (e.g. as below) can be used to work around the error, presumably as it replaces the default arguments including -v.

        "python.testing.unittestArgs": [
            "-p",
            "*test*.py"
        ]
    
  3. eleanorjboyd commented on May 27, 2025

    @eleanorjboyd

    huh very interesting! I will give this a try on my end

  4. github-actions commented on Jun 27, 2025

    @github-actions

    Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

    Happy Coding!

  5. eleanorjboyd commented on Jul 11, 2025

    @eleanorjboyd

    Tried this and it worked fine for me if I didn't include any args. Do you see something similar to this in your output logs? Can you see the -v in there:

    2025-07-11 14:33:11.169 [info] MANAGE_PY_PATH is set, running Django discovery with path to manage.py as: $manage.py
    Running Django tests with command: ['/Users/eleanorboyd/testingFiles/django-polls-demo/.venv/bin/python', 'manage.py', 'test', '--testrunner=django_test_runner.CustomDiscoveryTestRunner']
    
  6. Zankroh commented on Jul 13, 2025

    @Zankroh
    Author

    According to Yuval Koren (@mygzi), indeed, by adding "python.testing.unittestArgs": [] in the config, I no longer have any errors. It seems default values are not compatible with django tests
    Thank you !

  7. mh-firouzjah commented on Sep 15, 2025

    @mh-firouzjah

    Same issue here.

    Proposed fix:
    After detecting MANAGE_PY_PATH, either:

    • skip passing the default discovery flags (-s, -p, and -v), or
    • provide a valid verbosity argument (-v 2 for example, allowed values are {0,1,2,3}).
  8. added
    help wantedIssues identified as good community contribution opportunities
    needs PRReady to be worked on
    bugIssue identified by VS Code Team member as probable bug
    on Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-testingbugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunitiesneeds PRReady to be worked on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions