-
Notifications
You must be signed in to change notification settings - Fork 1.2k
python.unitTest.cwd no effect? #5252
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
Comments
What version of python are you using? |
Python 3.7.3
If I try to read from the subdir as intended (with python.unittests.cwd set to the absolute path or ${workspaceFolder}/Tests), I get:
|
I'm unable to replicate this issue at my end, please could you:
|
I have the same thing with Pytest. Setting |
Got it, thanks |
Not clear if you need more info on this, but I am back to the project now and can report that the public repo biopython exhibits the problem for me. A specific example is Tests/test_PDB_parse_pdb_header.py where the test test_parse_header_line() tries to read a file from the Tests/PDB subdirectory. I have updated VSCode to 1.34.0 and the python extension reports 2019.4.12954. I have added |
FYI, I ran into this while working on #6548. |
I have the same issue.
|
I have been able to replicate this issue only when I have python.testing.pytestEnabled enabled. It however works properly with python.testing.unittestEnabled and python.testing.nosetestsEnabled. |
I also have this issue with python.testing.unittestEnabled. |
Having the same problem python.testing.unittestEnabled. When I enter
|
I recently investigated this probably briefly and found that anytime that python.testing.cwd is changed, the window needs to be reloaded for the setting to be picked up. With that method, I have found that it works as expected. |
@jaron-l Thank you very much, that worked. I just realized that Can anyone confirm this? And to make matters worse: Doesn't seem to get used when debugging a unittest. |
It does work for test discovery too, which I'm pretty sure is intentional lest code would likely crash on discovery and not when running (or vice-versa) as you'd be running in different environments with different python paths. The second issue you are referencing can be found here: #8678 |
Funny, I tested the reloading and that did indeed fix running the tests through the Test Explorer UI and Python Test explorer (which use the python settings) but not through the normal python extension, it finds the tests, but then running the tests gives me a file or directory not found with a path relative to the workspace folder but not the testing cwd. This is with pytest btw. |
@hvdklauw, what do you mean by "the normal python extension"? Are you talking about the CodeLens buttons? What's your workflow? |
What I mean is the vscode-python test explorer, it doesn't run the tests correctly, but the Test Explorer UI (which is now deprecated but you can still use) with the python text explorer extension actually works for me, so they must be doing something right that the python extension is doing wrong, because it uses the same settings. |
Hello! I have reviewed this issue and given the architectural changes of the testing rewrite, this issue should no longer exist on the rewrite. Therefore I am going to close this issue but please comment or open a new issue if you are still seeing a problem when you try this yourself! To use the rewrite yourself just add Thanks! |
Issue Type: Bug
I am working on a repository with unit tests in a Tests subfolder, and the specific test needs to read a file from a subdirectory of Tests. The read fails with 'file not found', and when I print os.getcwd() before the read it reports ${workspaceFolder} regardless of what I put into python.unittest.cwd. I am using Python unittest (python.unitTest.unittestEnabled is true) framework.
Apologies if I am not understanding how this is supposed to work! Thanks
Extension version: 2019.3.6558
VS Code version: Code 1.33.1 (51b0b28134d51361cf996d2f0a1c698247aeabd8, 2019-04-11T08:22:55.268Z)
OS version: Darwin x64 18.5.0
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: unavailable_off
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: