-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError while loading conftest #23218
Comments
@Akopov4 Relative imports work differently based on where you are running from and what you are using to run. Wehn you open conftest.py, it is as if you are running that file, from the context of that file, the imports can get resolved. But, typically conftest gets loaded into Please provide how you have organized your code, so we can help with this. |
@karthiknadig please look my gif |
@eleanorjboyd please look my gif |
Does it work if you run pytest from terminal? Just run |
i don't run pytest. I just hit the button to discover tests |
I understand that you use the run button. But I want to know if it works from the terminal. When you run it from terminal does it execute as expected or do you get error? |
I don't use run button. I use button - Test Explorer: Reload Tests |
There problem was in "dot":
|
We should reopen this bug because is genuine. I was able to encounter it myself while my python environment is fine and I suspect that I found some of the causes. This is output from Extension Host and it surprisingly includes ANSI escapes, reason for likely being the fact that I have
Note: the file does not really have a syntax error, python runs it quite fine. Still, the way vscode is trying to load it makes it throw this weird error. I suspect that the import at the beginning of the file does not work and that is later causing a syntax error when trying to call. |
Hi! The issue with the syntax error and coloration will be fixed as part of this issue: #21845 it is a known problem that it works in the test result panel (during run) but not in the python output panel (output for error / discovery) Secondly I am seeing you are using the old testing architecture: |
@eleanorjboyd @ssbarnea I have created new defect, because this one was closed. I attached there gif file. I hope it will make issue clear #23328 |
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:
Extension version: 2024.4.0
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
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
A/B Experiments
The text was updated successfully, but these errors were encountered: