Repository navigation
Pytest discovery fails on RHEL8 due to symlink #21373
Description
Type: Bug
Behaviour
Expected vs. Actual
My company controlled workstation is being upgraded from CentOS7 to RHEL8 and I've been beta testing the RHEL8 workstation this week. I'm using the Remote SSH plugin to open Python projects on the Linux workstation from a Windows 10 desktop.
On CentOS7, VSCode has no problems discovering and running my test suites in pytest. On RHEL8, it shows all the containing modules but no tests in the tree beneath them. I've tried with both the release channel and insiders versions of VSCode (with All expriments enabled and the test server started for insiders) and get the same result.
Steps to reproduce:
- Open Python project with pytest tests
- Switch to Test Explorer
- Tests are not discovered; no errors or anything beyond "info" messages in logs, even with
python.analysis.logLevel = TRACE. - Refresh Tests; same behavior
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.16
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServersetting: Default
Output for Python in the Output panel
2023-06-06 14:06:31.749 [info] Experiment 'pythonPromptNewFormatterExt' is active
2023-06-06 14:06:31.749 [info] Experiment 'pythonPromptNewToolsExt' is active
2023-06-06 14:06:31.749 [info] Test server listening.
2023-06-06 14:06:31.749 [info] Python interpreter path: ./.venv/bin/python
2023-06-06 14:06:40.405 [info] Starting Pylance language server.
2023-06-06 14:22:46.295 [info] > . ./.venv/bin/activate && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python /alt/.vscode-server/extensions/ms-python.python-2023.8.0/pythonFiles/printEnvVariables.py
2023-06-06 14:22:46.295 [info] shell: bash
2023-06-06 14:22:46.336 [info] > ./.venv/bin/python /alt/.vscode-server/extensions/ms-python.python-2023.8.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
2023-06-06 14:22:46.336 [info] cwd: .
User Settings
languageServer: "Pylance"
linting
• flake8Args: "<placeholder>"
• flake8Enabled: true
formatting
• provider: "black"
testing
• cwd: "<placeholder>"
• pytestEnabled: true
terminal
• activateEnvironment: false
Extension version: 2023.8.0
VS Code version: Code 1.78.2 (b3e4e68a0bc097f0ae7907b217c1119af9e03435, 2023-05-10T14:39:26.248Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: Yes
Remote OS version: Linux x64 4.18.0-425.19.2.el8_7.x86_64
Remote OS version: Linux x64 3.10.0-1160.88.1.el7.x86_64
Remote OS version: Linux x64 4.18.0-425.19.2.el8_7.x86_64
Remote OS version: Linux x64 4.18.0-425.19.2.el8_7.x86_64
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931:30280409
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vscaat:30438848
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
pyind779:30671433
89544117:30613380
pythonsymbol12:30671437
showlangstatbar:30737416
vsctsb:30748421
pythonms35:30701012
03d35959:30757346
pythonfmttext:30731395
pythoncmv:30756943
fixshowwlkth:30730052
hidesbindicator:30730055
pythongtdpathcf:30739705
pythonnosmt12:30757131
Activity
karthiknadig commentedon Jun 6, 2023
Gordon Shankman (@mrburrito) To get detailed logs, use
Developer: Set Log Level...command and select the log level for Python extension there.mrburrito commentedon Jun 7, 2023
Karthik Nadig (@karthiknadig) giving that a shot now. Is that not controlled by the
python.analysis.logLevelconfiguration setting?mrburrito commentedon Jun 7, 2023
Trace logs from a manual test refresh:
mrburrito commentedon Jun 7, 2023
This is the output from the test discovery command if I run it from
/home/mrburrito/source/org/project.eleanorjboyd commentedon Jun 8, 2023
when you run pytest from the integrated terminal does it work? We are specifically running the command:
pytest -- --rootdir . -s --cache-clearmrburrito commentedon Jun 9, 2023
That command does not appear to work, on either RHEL8 or CentOS7.
However, if I remove the
--, it works just fine.mrburrito commentedon Jun 9, 2023
Is the
--just in place to tell the VSCoderun_adapter.py discovercommand to stop processing arguments and pass the remainder topytest?The JSON block above is the output from running that
run_adapter.py discover pytest -- --rootdir . -s --cache-clearcommand from the integrated terminal.eleanorjboyd commentedon Jun 9, 2023
What do you have in your pytest args in your workspace settings? Might look something like this:
"python.testing.pytestArgs": []mrburrito commentedon Jun 9, 2023
pytest args are empty (
[])27 remaining items
adrshm91 commentedon Jul 25, 2023
I have the same problem working with VScode on AzureML. I have my python project in azure ml file share. I connect to the Azure ML compute with vscode by navigating to open with VSCode option in Azure ML. The tests are not discovered and there are no error logs. After struggling with this problem i came across this issue here. Please let me know my problem is related to the issue here.
eleanorjboyd commentedon Jul 25, 2023
yes this is likely related adrshm91, will update this issue with progress and I work towards a fix and then you can try it once again. Thanks
MartinCura commentedon Aug 5, 2023
Spent over an hour trying and giving up solving the tests being discovered but not being run no matter what i did, no logs anywhere giving any hints, until because of mrburrito i tried just opening
codedirectly from the same folder (code .instead ofcode coding/org/project) and now it just works. Thank you 😭eleanorjboyd commentedon Aug 18, 2023
Hi! Looking to fix this but having trouble getting a minimal repro that produces the error. I have tried to replicate it via symlinks on a single disk (but it works) so I think it might only occur when you have symlinks across two different disks. Is that how everyone's setup is?
eleanorjboyd commentedon Aug 18, 2023
Was attempting this repro, copied message from #21576
'''
Hi Jonathan Hawkins (@jonodhawkins) thank you for the info! Looks like an issue with symlinks, which is something we know is broken. I am currently trying to fix it but having trouble repro-ing the behavior. To clarify your steps Jonathan Hawkins (@jonodhawkins),
create "Test Project Structure" as described at a local path /mnt/storage/[project_name]
create "test_simple.py" as described
create symlink ln -s /mnt/storage/[project_name] /home/jono/storage/[project_name]
cd to /home/jono/storage/[project_name]
run code . to open vscode
try to find tests and they are not being discovered
Thanks for your help!
jonodhawkins commentedon Aug 18, 2023
Hi Eleanor Boyd (@eleanorjboyd),
Following the steps above using vscode version:
I also cannot reproduce the behaviour. However, if instead of using
to open the directory, I use the
File > Open Folder ...dialog, then the tests are identified, but they cannot be run (0/0 tests passed when attempting to run any tests or all tests).eleanorjboyd commentedon Aug 18, 2023
great thank you!
I tried it as described but with symlinks on the same disk and it didn't work so I think the paths being on separate disks is necessary. Currently figuring out how to configure a similar setup for myself to test on. Thanks!
eleanorjboyd commentedon Aug 22, 2023
Hello! I got a setup working on a parallels VM. I have a windows VM with parallels then have WSL on that machine to a Ubuntu machine. These are the steps I took and am still not able to repro. Any steps I am missing / did incorrectly?
New-Item -ItemType SymbolicLink -Path "C:\Users\eleanorboyd\Documents\python-tester-files\tiger_alias" -Target "\\wsl$\Ubuntu\home\linux_user\linux_root\purple_tiger"cd "C:\Users\eleanorboyd\Documents\python-tester-files\tiger_alias"code .jonodhawkins commentedon Aug 22, 2023
Hi Eleanor Boyd (@eleanorjboyd) - if in the same setup, replacing step 9 with the below, can you reproduce? Opening the folder from the UI vs. directly instantiating an instance of
codealready in the folder seemed to be crucial for me to reproduce.code .9.1 in code GUI use File > Open Folder... to open
C:\Users\eleanorboyd\Documents\python-tester-files\tiger_alias10... etc as above
eleanorjboyd commentedon Aug 23, 2023
I tried it via the open folder command (from the vscode UI) and that resulted in the same successful behavior. To specify you open the alias folder as the root and see the issue correct? I think I have tried opening both the parent folder of
tiger_aliasand checking and a subfolder oftiger_aliasand saw the same results but if this might be a deciding factor I can dive into it further.github-actions commentedon Sep 23, 2023
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!