-
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
Test Discovery fails with ModuleNotFoundError while command is working on console #19486
Comments
I'm having a very similar problem. I believe the root cause may be similar to what's described here: https://medium.com/@dirk.avery/pytest-modulenotfounderror-no-module-named-requests-a770e6926ac5
This all follows from the article linked above ; however, I don't know how to fix it. This Stackoverflow thread is also relevant: https://stackoverflow.com/questions/10253826/path-issue-with-pytest-importerror-no-module-named-yadayadayada |
@dovahgab Can you confirm that the python used to launch the test is the same as the one used by @srobertjames We are working a designing a more robust test runner that works like how you expect pytest to work. Currently we import pytest first and then do discovery, but when running we use pytest directly. This creates mismatch between discovery and running. So, we have plans to make both work the same way. |
@karthiknadig Thanks! Is there a workaround in the meantime? I'd like to be able to run pytest from vscode so that I can use its interactive debugging features (eg set breakpoints). |
You can always create a launch configuration that can launch your tests. But you may have to edit the args to filter tests you want to focus on, but it should get you all the debugging capabilities. |
I have resolved this by adding a pyproject.toml in the Workspace root folder with the following data:
give it a try |
@g1augusto Works perfectly!!! Thank you! How can I see the test output? |
You can run the test in debug mode and look at the VScode debug output
window
…On Wed, Jul 27, 2022, 03:14 srobertjames ***@***.***> wrote:
@g1augusto <https://github.com/g1augusto> Works perfectly!!! Thank you!
How can I see the test output?
—
Reply to this email directly, view it on GitHub
<#19486 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGJVDEA4LLDGWX4IZ5RCPNTVWCEODANCNFSM53VZVUTQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@g1augusto To clarify: The
This suggests to me that the |
Thank you. While I'm not able to get all the output, this is still a huge step forward. |
hi, sorry for lagging, and thanks for your answer I was looking for a solution on this for the same reason, debugging tests - at first I worked it out invoking pytest in a python script, such as
and then debugging it. |
I've been hitting this error, which is super annoying. And all the mechanisms to configure this via the Just by running The reason for this is that the |
I'm having the exact same problems described above, but with unittest instead of pytest. |
Hello! We have just finished our testing rewrite and are beginning the roll out to users. If you are able, it would be very helpful to know if your issue still exists on the rewrite! To try it yourself, add this setting to your users You can confirm you have the rewrite enabled by setting Let me know if the rewrite fixes your issue. Thanks! |
Thanks, the repo I was working on has changed quite a lot. |
@dovahgab that is great news! I am going to close this to try and reduce our backlog of issues but if it isn't working for anyone still please comment to reopen this issue or create a new one. Thanks! |
Issue Type: Bug
Behaviour
Expected vs. Actual
note: issue similar to #10005
Tests discovery should detect tests, while it does not.
Steps to reproduce:
Project setup, in a basic pipenv environment:
Test discovery on the testing extension fails with
ModuleNotFoundError: No module named 'mymodule'
Manual run with
pipenv run python3 -m pytest tests/test_*.py
works well.
setting.json content:
no pytest config file or so.
Diagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2022.10.1
VS Code version: Code 1.69.1 (b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a, 2022-07-12T08:28:29.328Z)
OS version: Linux x64 5.15.0-41-generic
Restricted Mode: No
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_renderer: enabled_on
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: