-
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
Cannot import any module from folder called "tests" using vscode #8840
Comments
This means your |
I'm not manipulating the sys.path but you're right the url for site-packages is shadowing my repo. I can switch the order of it but does it really solve the issue? In pycharm it works perfectly fine for the same project. Only wondering :) |
It might have to do with how pytest sets things up based on how we invoke it (we don't manipulate |
well when invoking pytest there is no difference really. The problem is when I want to use a script that is not a test. Then the import doesn't work - I found a workaround using the PYTHONPATH in the .evn file in the project but still would expect to work as it does in different tools:) |
Hi @xSupasx 👋 Could you provide a sample project and steps to reproduce your issue so that we can take a look? Thanks :) |
@xSupasx please provide a reproducer as @kimadeline requested, but if this is due to running code as a script then it will most likely be due to the directory you're executing from (i.e. PyCharm may be changing your current working directory for you implicitly while we are not unless you ask us to). |
I will, don't have the possibility now. Will provide the structure later today. |
During the creation of a repo to reproduce the bug I found actually another thing. During running the file the PYTHONPATH simply isn't enriched with the workspace folder hence the imports fail. Is the only solution for this adding the .env file with pythonpath modification within it? Maybe as an addition to the current file location that is bein ran (this path is added) would be good to also add the workspace folder(it is like this in pycharm i.e) if this is some known issue/feature then please close the bug. |
@xSupasx we don't touch your So it seems like your folder structure is such you need to specify |
Issue Type: Bug
when project has "tests" folder in the folder structure and there are modules that reside within it (python modules) then modules cannot be imported. If the name of the folder is changed everything works as expected.
VS Code version: Code 1.40.2 (f359dd69833dd8800b54d458f6d37ab7c78df520, 2019-11-25T14:54:45.096Z)
OS version: Windows_NT x64 10.0.18362
System Info
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled
Extensions (38)
The text was updated successfully, but these errors were encountered: