-
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
Pytest - Run test from test explorer fail with uppercase test folder name #6410
Comments
I am not getting similar errors, but I can confirm the tests in directory with uppercase test folder name are not being run. |
I have a very similar issue. After updating to 2019.6.22090, every capital letter in the test module's path will be turned to lowercase when displayed in the test explorer. A quick fix could be to avoid any capital letter in any source file and folder names, but that would go against our naming convention. When using "Run All Tests" or "Debug All Tests" buttons in the test explorer, I see in the Python Test Log output window that tests are executed (and whether they pass or not), and the status bar icon reflects the correct result. However, pass/fail results are not reported in the test explorer. However, when I try to run or debug tests using the green "Play" arrow next to the lowercase test module name, I get a test collection error. Interestingly, when I look at the log message, it correctly capitalizes paths outside of the current workspace, but not paths inside the current workspace. For example, a test module in a workspace located in C:\Sources\ProjectName would have the following path: C:\Sources\ProjectName\TestModules\test_SomeModule.py, but when called from the test explorer, the log displays that PyTest tries to import c:\Sources\ProjectName\testmodules\test_somemodule.py The test explorer also returns an "all lowercase" version of the file path (from "c:" to ".py") when trying to access the code from the test explorer view. I can't have any code lens on tests if there is a capital letter anywhere in the test module's full path. Reverting to 2019.5.18875 fixes all these issues.
|
Is this windows only ? |
I observe the same behaviour reported by PhilMacKay above #6410 (comment)
|
After thorough investigation, I realized this happens with pytest version 5.0.0 and upper, and the extension's TestCollector (in pythonFiles/testing_tools/adapter/pytest/_discovery.py) which applies os.path.normcase on every path. Basically, the workarounds I found was:
|
This should be resolved now due to #6781 and #6877. Those changes are already in the insiders build of the extension and will be part of the September release. |
@PhilMacKay indicated that this is resolved. See #6820 (comment) |
Environment data
"python.jediEnabled"
set to; more info How to update the language server to the latest stable version #3977): JediExpected behaviour
Test file could be run from test explorer in activity bar.
Actual behaviour
Test file could not run from test explorer in activity bar.
CodeLens adornments disappear from the test file.
Steps to reproduce:
Logs
Python Test Log say that:
Additional Information
All the setting work for the vscode-python for previous release (2019.5.18875).
When I change the folder name containing the test file from Test to test, with python.testing.pytestArgs setting in setting.json to ["test"], test file could be run from test explorer. However, codeLens adornments still disappear.
It seems for the current release, vscode-python change the uppercase letter for folder name to lowercase before they import the test module. This change to letter case cause the problem.
The text was updated successfully, but these errors were encountered: