Skip to content

pytest arg parsing bug #21176

@philippun1

Description

@philippun1

Type: Bug

Behaviour

Expected vs. Actual

Running a pytest test with pytestArgs results in the error

Error while running tests: test_example
TypeError: Cannot read properties of null (reading 'testsuites')

After removing the pytestArgs from the settings.json, everything runs as expected.

Steps to reproduce:

  1. Open a project with a pytest (i.e. https://github.com/philippun1/pytest-vscode-parameters which I created specifically to reproduce this bug)
  2. Let VS Code create a settings.json (or use the one from my repo)
  3. Add pytestArgs (or use the one from my repo), i.e.
"python.testing.pytestArgs": [
    ".",
    "--test_option",
    "somevalue"
  ],
  1. Go to the testing tab and run the test
  2. Test Results tab shows the type error
  3. Run from the terminal instead gives no error: pytest . --test_option somevalue

Diagnostic data

This test report was made on an Ubuntu machine, but can also be reproduced on a Windows system with the latest VS Code and python extension.

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.2
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

[output is empty]

User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true

Extension version: 2023.6.1
VS Code version: Code 1.77.3 (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:16:52.732Z)
OS version: Linux x64 6.2.0-20-generic
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz (8 x 2804)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 1, 1, 1
Memory (System) 15.35GB (8.29GB free)
Process Argv --unity-launch --crash-reporter-id 2d6dab3d-7a47-4211-935d-970af4709a92
Screen Reader no
VM 0%
DESKTOP_SESSION ubuntu
XDG_CURRENT_DESKTOP Unity
XDG_SESSION_DESKTOP ubuntu
XDG_SESSION_TYPE wayland
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
3biah626:30602489
pyind779:30671433
f6dab269:30613381
vscrpc:30673769
pythonsymbol12:30671437
6233i204:30730053
vsctsb:30705553
azdwalk:30721579
pythonms35:30701012
pythonfmttextcf:30716743
pythonclientmvcf:30725893
fixshowwlkth:30730052

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bugneeds spikeLabel for issues that need investigation before they can be worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions