Skip to content

Pytest discovery fails #21576

Closed as not planned
Closed as not planned
@kjohnsen

Description

@kjohnsen

Type: Bug

Behaviour

Expected vs. Actual

I expect discovery to work, for the explorer to populate with tests. Instead I get pytest discovery error (see Output > Python)

Steps to reproduce:

  1. Click the 'refresh tests' button on the testing pane

Diagnostic data

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

2023-07-06 19:06:05.076 [info] Discover tests for workspace name: cleo - uri: /home/kyle/dbgt/projects/cleo
2023-07-06 19:06:05.076 [info] Running discovery for pytest using the new test adapter.
2023-07-06 19:06:05.093 [info] > conda run -n cleo10 --no-capture-output python ~/.vscode-server-insiders/extensions/ms-python.python-2023.11.11801006/pythonFiles/get_output_via_markers.py -m pytest -p vscode_pytest --collect-only tests
2023-07-06 19:06:05.093 [info] cwd: .
2023-07-06 19:06:07.783 [info] Test server connected to a client.
2023-07-06 19:06:07.785 [info] Using result resolver for discovery
2023-07-06 19:06:07.785 [error] pytest test discovery error 
 Error Occurred, traceback: Traceback (most recent call last):
  File "/home/kyle/.vscode-server-insiders/extensions/ms-python.python-2023.11.11801006/pythonFiles/vscode_pytest/__init__.py", line 218, in pytest_sessionfinish
    session_node: Union[TestNode, None] = build_test_tree(session)
  File "/home/kyle/.vscode-server-insiders/extensions/ms-python.python-2023.11.11801006/pythonFiles/vscode_pytest/__init__.py", line 259, in build_test_tree
    session_node = create_session_node(session)
  File "/home/kyle/.vscode-server-insiders/extensions/ms-python.python-2023.11.11801006/pythonFiles/vscode_pytest/__init__.py", line 404, in create_session_node
    "path": session.path,
AttributeError: 'Session' object has no attribute 'path'

User Settings


languageServer: "Pylance"

formatting
• provider: "none"

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

Extension version: 2023.13.11871009
VS Code version: Code - Insiders 1.80.0-insider (5b7440441bbd2548a862f7321cafdfa1597132e5, 2023-06-30T21:12:14.732Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2

System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.73GB (9.47GB free)
Process Argv --crash-reporter-id 13862219-8062-4bb8-969d-b654fdb7b5e1
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.10.16.3-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
Memory (System) 15.50GB (12.88GB free)
VM 0%
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythontb:30258533
pythonptprofiler:30281269
vshan820:30294714
vscod805cf:30301675
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30404738
py29gd2263:30776702
vsclangdf:30492506
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30618038
pylantcb52:30590116
pyind779:30611226
pythonsymbol12:30651887
showlangstatbar:30737417
pythonms35:30671666
57b77579:30687741
pythonfmttext:30716741
pythoncmvfstr:30726892
fixshowwlkth:30771523
showindicator:30766888
pythongtdpath:30726887
i26e3531:30780429
gsofb:30778559
pythonnosmt12:30779711
pythonidxpt:30768918
pythondjangots:30768917
pythonnoceb:30776497
copilotsettingt:30767686
e537b577:30772214
h0f32768:30779712
synctok:30783813
dsvsc013:30777762
dsvsc014:30777825

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions