Skip to content

pytest broken (run fails on module discovery, debug works) #14579

@schperplata

Description

@schperplata

Issue Type: Bug
With the latest Python extension update (2020.10.332292344), pytests are unable to run tests, while I can debug them normally. This happens only when pytests are run via VS Code. If run via cmd, this is is not the case.
Works on previous version: v2020.9.114305.

I discovered that new plugin has different sys.path list.
Debug (working):

sys.path:
    w:\AsystLib\isys\python
    W:\APPS\PythonModules
    ...

While run (failing):

sys.path:
    c:\Users\domen\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles
    W:\APPS\PythonModules

As you can see, first enty: w:\AsystLib\isys\python is missing and is replaced with VSC extension path. Error:

=================================== ERRORS ====================================
___________________ ERROR collecting isys_tests/test_svn.py ___________________
ImportError while importing test module 'w:\AsystLib\isys\python\isys_tests\test_svn.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
isys_tests\test_svn.py:13: in <module>
    import isys.generic
E   ModuleNotFoundError: No module named 'isys'
- generated xml file: C:\Users\domen\AppData\Local\Temp\tmp-22572SU2jr85kY5KB.xml -
=========================== short test summary info ===========================
ERROR isys_tests/test_svn.py
============================== 1 error in 0.03s ===============================
ERROR: not found: w:\AsystLib\isys\python\isys_tests\test_svn.py::test_getStatus
(no name 'w:\\AsystLib\\isys\\python\\isys_tests\\test_svn.py::test_getStatus' in any of [<Module isys_tests/test_svn.py>])

isys is a folder inside: w:\AsystLib\isys\python where many modules are placed, for example isys.generic. Module is accessible in standard run/debug launch configuratoin, but not in pytest run mode.

I couldn't reproduce this with the most simple single-folder VSC workspace. My workspace merge a couple of folders, some with and some without VSC wks/settings files. There are errors in other workspace folders, but this does not explain this scenario, where debug works while run doesn't.

Let me know how can I help since this is again, major drawback in workflow.

Extension version: 2020.10.332292344
VS Code version: Code 1.50.1 (d2e414d9e4239a252d1ab117bd7067f125afd80a, 2020-10-13T15:06:15.712Z)
OS version: Windows_NT x64 10.0.18363

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz (8 x 2712)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.92GB (6.63GB free)
Process Argv W:\AsystLib\isys\python\VSCodeDevWorkspace_refactor.code-workspace --crash-reporter-id 919e0ed9-46f3-4ad4-9e28-f35755bf8266
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions