microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.93k stars 29.52k forks source link

ImportError while loading conftest #210036

Closed Akopov4 closed 7 months ago

Akopov4 commented 7 months ago

Type: Bug

In my project I have a folder helpers. There is a python file db.py. There is a class called Database. In the same level as folders helpers i have file conftest.py . In conftest I import Database class. "from .helpers.db import DataBase" . There are no errors shown in the conftest.py file. But when I run tests discovery, I get an error:

Test loading failed: Error: Process exited with code 4: ImportError while loading conftest '/home/akop/PythonProjects/playwright_qa_mamania/conftest.py'.
conftest.py:7: in <module>
    from .helpers.db import DataBase
E   ImportError: attempted relative import with no known parent package

Error: Process exited with code 4: ImportError while loading conftest '/home/akop/PythonProjects/playwright_qa_mamania/conftest.py'.
conftest.py:7: in <module>
    from .helpers.db import DataBase
E   ImportError: attempted relative import with no known parent package

    at ChildProcess.<anonymous> (/home/akop/.vscode/extensions/littlefoxteam.vscode-python-test-adapter-0.8.2/out/src/processRunner.js:27:32)
    at Object.onceWrapper (node:events:632:26)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:517:28)
    at Socket.emit (node:domain:489:12)
    at Pipe.<anonymous> (node:net:350:12)

VS Code version: Code 1.88.0 (5c3e652f63e798a5ac2f31ffd0d863669328dc4c, 2024-04-03T13:25:57.039Z) OS version: Linux x64 5.15.0-102-generic Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (4 x 2899)| |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_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|3, 3, 3| |Memory (System)|11.56GB (2.54GB free)| |Process Argv|--unity-launch --crash-reporter-id 01400cc3-0ed1-484c-a547-9fad9bdfb52d| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|cinnamon| |XDG_CURRENT_DESKTOP|X-Cinnamon| |XDG_SESSION_DESKTOP|cinnamon| |XDG_SESSION_TYPE|x11|
Extensions (65) Extension|Author (truncated)|Version ---|---|--- commit-message-editor|ada|0.25.0 docs-view|bie|0.1.0 markdown-preview-github-styles|bie|2.0.4 path-intellisense|chr|2.8.5 dbclient-jdbc|cwe|1.3.4 vscode-database-client2|cwe|7.2.1 add-to-git-ignore|djl|1.0.1 githistory|don|0.6.20 python-environment-manager|don|1.2.4 python-extension-pack|don|1.7.0 git-cheatsheet|dzh|1.4.4 vscode-html-css|ecm|2.0.9 RunOnSave|eme|0.2.0 vscode-great-icons|emm|2.1.104 pythonsnippets|frh|1.0.2 python-class-autocompletor|ful|0.0.2 vscode-pull-request-github|Git|0.86.1 vscode-test-explorer|hbe|2.21.1 vscode-git-tags|how|1.4.4 path-autocomplete|ion|1.25.0 show-history-for-selection|kan|0.0.1 vsc-python-indent|Kev|1.18.0 vscode-python-test-adapter|lit|0.8.2 MagicPython|mag|1.1.0 auto-save|mcr|1.0.3 rainbow-csv|mec|3.11.0 python-path|mge|0.0.14 git-graph|mhu|1.30.0 prettify-json|moh|0.0.3 vscode-dotnet-runtime|ms-|2.0.3 playwright|ms-|1.0.22 autopep8|ms-|2024.0.0 black-formatter|ms-|2024.2.0 debugpy|ms-|2024.4.0 isort|ms-|2023.10.1 python|ms-|2024.4.0 vscode-pylance|ms-|2024.4.1 remote-containers|ms-|0.354.0 remote-repositories|ms-|0.40.0 test-adapter-converter|ms-|0.1.9 vsliveshare|ms-|1.0.5918 save-all|nan|1.0.0 indent-rainbow|ode|8.3.1 git-file-history|pom|1.0.1 postman-for-vscode|Pos|0.19.3 open-php-html-js-in-browser|Pri|2.5.0 vscode-debug-code|pyc|0.0.5 gitignore-ultimate|que|0.3.0 robotframework-lsp|rob|1.11.0 glassit|s-n|0.2.6 file-git-history|sab|0.0.25 pip-manager|sli|1.1.3 code-spell-checker|str|3.0.1 code-spell-checker-russian|str|2.2.2 code-spell-checker-ukrainian|str|1.2.2 open-in-browser|tec|2.0.0 python-extended-snippets|tus|0.0.1 vscode-gitandgithub-pack|vin|2.0.1 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.3.1 gitblame|wad|10.10.0 jinja|who|0.0.8 JavaScriptSnippets|xab|1.8.0 html-css-class-completion|Zig|1.20.0 vscode-open-in-github|ziy|1.3.6 (5 theme extensions excluded)
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 d6fi2104:30959263 cppperfnew:31000557 d34g3935:30971562 fegfb526:30981948 bg6jg535:30979843 ccp1r3:30993539 dsvsc020:30976470 pythonait:31006305 gee8j676:31009558 dsvsc021:30996838 gd77d436:30999572 ```
IllusionMH commented 7 months ago

/extPython

vscodenpa commented 7 months ago

It looks like this is caused by the Python extension. Please file the issue to the Python extension repository. Make sure to check their issue reporting template and provide them relevant information such as the extension version you're using. See also our issue reporting guidelines for more information.

Happy Coding!