Skip to content

pytest doubles %PYTHONPATH% in a debug run #13689

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

Closed
schperplata opened this issue Aug 31, 2020 · 6 comments
Closed

pytest doubles %PYTHONPATH% in a debug run #13689

schperplata opened this issue Aug 31, 2020 · 6 comments
Labels
area-debugging area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on

Comments

@schperplata
Copy link

Issue Type: Bug

If %PYTHONPATH% is set, VSC test (pytest) plugin double %PYTHONPATH% in debug configuration. Not the case with run configuration.

Example (run):

test_example.py::test_printPythonPath 
%PYTHONPATH%:
	 PYTHONPATH_ENV_VAR
PASSED

Example (debug):

test_example.py::test_printPythonPath 
%PYTHONPATH%:
	 PYTHONPATH_ENV_VAR
	 PYTHONPATH_ENV_VAR
PASSED

Doesn't really affect my use case, but I consider this as a bug.

Extension version: 2020.8.105045
VS Code version: Code 1.48.2 (a0479759d6e9ea56afa657e454193f72aef85bd0, 2020-08-25T10:13:11.295Z)
OS version: Windows_NT x64 10.0.19041

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz (4 x 3193)
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
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.89GB (6.95GB free)
Process Argv vsCodeTest.code-workspace
Screen Reader no
VM 0%
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Aug 31, 2020
@karthiknadig karthiknadig added triage bug Issue identified by VS Code Team member as probable bug labels Aug 31, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Aug 31, 2020
@karrtikr karrtikr added info-needed Issue requires more information from poster and removed info-needed Issue requires more information from poster labels Sep 1, 2020
@karrtikr
Copy link

karrtikr commented Sep 1, 2020

@schperplata I can reproduce this when I set environment variables using .env file, and print environment variables to file, thanks! Btw how were you setting environment variables?

@schperplata
Copy link
Author

In this specific case, I have a .bat file that set PYTHONPATH and open VSC workspace. I figured out this is the simplest way of configuring VSC workspace without mulitplying source paths for pylint, pylance, autocomplete, ...
Anyway, I don't know if that happened before when we also used .env files.

@karrtikr
Copy link

karrtikr commented Sep 2, 2020

Can you please elaborate on what you mean by multiplying source paths?

In this specific case, I have a .bat file that set PYTHONPATH and open VSC workspace.

Does this issue happen when you set PYTHONPATH using a .bat file as well?

@schperplata
Copy link
Author

Can you please elaborate on what you mean by multiplying source paths?

This is a problem when multiroot workspaces/projects are used or modules anywhere in the project tree must be runnable. If %PYTHONPATH% is set globaly, for example by .bat file, all extensions /VSCode tools can make use of it (Pylance, Pylint, Pytest, ...). All paths are defined at one single place (.bat/.env). Otherwise, user must configure these paths for extensions, for example Pylance "python.analysis.extraPaths". This was already a discussion on a couple of other places, here is one example. Anyway, don't be bothered with this, as it is not the problem here (at least I think so) :)

Does this issue happen when you set PYTHONPATH using a .bat file as well?

Yes. In fact, this is the way I initially discovered (and reported) the issue.

@github-actions github-actions bot removed the needs PR label Aug 9, 2022
@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@eleanorjboyd
Copy link
Member

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, you need to be on the most recent release of the Python extension and add this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"].

You can confirm you have the rewrite enabled by setting "python.analysis.logLevel": "Trace", in your user settings then check for Experiment 'pythonTestAdapter' is active in your python logs.

Let me know if the rewrite fixes your issue. Thanks!

@luabud luabud added info-needed Issue requires more information from poster ghc-osd labels Sep 19, 2023
@github-actions
Copy link

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

Happy Coding!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging area-testing bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

5 participants