pytest broken (run fails on module discovery, debug works)
See original GitHub issueIssue 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® Core™ 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% |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:16
- Comments:13
Adding an
__init__.py
in the test suite folder also seemed to “fix” this particular issue for me without requiring a downgrade. You really shouldn’t need it there for the test suite to work though thus the cautious use of the word fix.Thanks all for the info! Should be fixed as part of https://github.com/microsoft/vscode-python/issues/14570 which is planned for the next release.