Skip to content
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 tests are never discovered #22828

Closed
alexpf opened this issue Feb 1, 2024 · 14 comments
Closed

Pytest tests are never discovered #22828

alexpf opened this issue Feb 1, 2024 · 14 comments
Assignees
Labels
area-testing triage-needed Needs assignment to the proper sub-team

Comments

@alexpf
Copy link

alexpf commented Feb 1, 2024

Environment data

  • Language Server version: 2023.12.1
  • OS and version: Windows 11
  • Python version: 3.11.4

Code Snippet

Create a project:
folder/
folder/requirements.txt with pytest
folder/test/
folder/test/test_attempt.py with one test, e.g.

def test_attempt():
pass

Repro Steps

  1. Run actions "Create environment", "Select interpreter"
  2. Tests are not auto-discovered
  3. Go to Testing tab, try to configure tests there
  4. Nothing works either

Expected behavior

Tests discovered

Actual behavior

No tests discovered

Logs

2024-02-01 19:41:01.630 [info] Discover tests for workspace name: eldak - uri: c:\Users\Aleksei_Lesnov\_work\projects\codility\eldak
2024-02-01 19:41:01.630 [info] Running discovery for pytest using the new test adapter.
2024-02-01 19:41:01.630 [info] All environment variables set for pytest discovery for workspace c:\Users\Aleksei_Lesnov\_work\projects\codility\eldak: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\Aleksei_Lesnov\\AppData\\Roaming","CHROME_CRASHPAD_PIPE_NAME":"\\\\.\\pipe\\crashpad_31080_MLMKITXVGAPJDMZB","COMPUTERNAME":"EPESMALW0001","EFC_11640":"1","ELECTRON_RUN_AS_NODE":"1","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\Aleksei_Lesnov","JAVA_HOME":"C:\\Program Files\\Amazon Corretto\\jdk17.0.8_7","LOCALAPPDATA":"C:\\Users\\Aleksei_Lesnov\\AppData\\Local","LOGONSERVER":"\\\\EPESMALW0001","NUMBER_OF_PROCESSORS":"8","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","POWERSHELL_DISTRIBUTION_CHANNEL":"MSI:Windows 10 Pro","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 140 Stepping 1, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"8c01","PUBLIC":"C:\\Users\\Public","PYENV":"C:\\Users\\Aleksei_Lesnov\\.pyenv\\pyenv-win\\","PYENV_HOME":"C:\\Users\\Aleksei_Lesnov\\.pyenv\\pyenv-win\\","PYENV_ROOT":"C:\\Users\\Aleksei_Lesnov\\.pyenv\\pyenv-win\\","SESSIONNAME":"Console","TEMP":"C:\\Users\\ALEKSE~1\\AppData\\Local\\Temp","TMP":"C:\\Users\\ALEKSE~1\\AppData\\Local\\Temp","UATDATA":"C:\\Windows\\CCM\\UATData\\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77","USERDNSDOMAIN":"epam.com","USERDOMAIN":"EPAM","USERDOMAIN_ROAMINGPROFILE":"EPAM","USERNAME":"Aleksei_Lesnov","USERPROFILE":"C:\\Users\\Aleksei_Lesnov","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\Aleksei_Lesnov\\AppData\\Roaming\\Code\\CachedData\\05047486b6df5eb8d44b2ecd70ea3bdf775fd937","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\Windows\\system32","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\b715e197-1.86.0-main-sock","VSCODE_L10N_BUNDLE_LOCATION":"","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"31080","ZES_ENABLE_SYSMAN":"1","ComSpec":"C:\\Windows\\system32\\cmd.exe","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","IntelliJ IDEA Community Edition":"C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2023.3.3\\bin;","OneDrive":"C:\\Users\\Aleksei_Lesnov\\OneDrive - EPAM","OneDriveCommercial":"C:\\Users\\Aleksei_Lesnov\\OneDrive - EPAM","PSModulePath":"C:\\Users\\Aleksei_Lesnov\\Documents\\WindowsPowerShell\\Modules;C:\\Users\\Aleksei_Lesnov\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\PowerShell","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","PyCharm Community Edition":"C:\\Program Files\\JetBrains\\PyCharm Community Edition 2023.3.3\\bin;","SystemDrive":"C:","SystemRoot":"C:\\Windows","__PSLockDownPolicy":"0","windir":"C:\\Windows","Path":"C:\\Program Files\\Amazon Corretto\\jdk17.0.8_7\\bin;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\PowerShell\\7\\;C:\\Users\\Aleksei_Lesnov\\.pyenv\\pyenv-win\\bin;C:\\Users\\Aleksei_Lesnov\\.pyenv\\pyenv-win\\shims;C:\\Users\\Aleksei_Lesnov\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\Aleksei_Lesnov\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\Aleksei_Lesnov\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\bin;C:\\Users\\Aleksei_Lesnov\\_software\\apache-maven-3.9.5\\bin;;C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2023.3.3\\bin;;C:\\Program Files\\JetBrains\\PyCharm Community Edition 2023.3.3\\bin;","PYTHONPATH":"c:\\Users\\Aleksei_Lesnov\\.vscode\\extensions\\ms-python.python-2023.22.1\\pythonFiles","TEST_UUID":"1afad0e2-e848-47ae-a881-d3bb8657f03b","TEST_PORT":"60088"} 

2024-02-01 19:41:01.684 [info] > ./.venv/Scripts/activate.bat && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode/extensions/ms-python.python-2023.22.1/pythonFiles/printEnvVariables.py
2024-02-01 19:41:01.684 [info] shell: commandPrompt
2024-02-01 19:41:01.956 [info] > .\.venv\Scripts\python.exe -m pytest -p vscode_pytest --collect-only attempt
2024-02-01 19:41:01.956 [info] cwd: test
@debonte debonte transferred this issue from microsoft/pylance-release Feb 1, 2024
@debonte debonte removed their assignment Feb 1, 2024
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 1, 2024
@eleanorjboyd
Copy link
Member

Hi! Could you send over your settings for the configuration of the tests? Also is that all the log messages you see? Usually there is something more following 2024-02-01 19:41:01.956 [info] > ..venv\Scripts\python.exe -m pytest -p vscode_pytest --collect-only attempt as that is just the call to discover tests.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 1, 2024
@alexpf
Copy link
Author

alexpf commented Feb 2, 2024 via email

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 2, 2024
@eleanorjboyd
Copy link
Member

Can you try removing attempt from the "python.testing.pytestArgs" and try again? From my knowledge this isn't a valid arg for pytest and might be causing and issue.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 2, 2024
@alexpf
Copy link
Author

alexpf commented Feb 2, 2024 via email

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 2, 2024
@eleanorjboyd
Copy link
Member

Are you able to send over your test folder so I could take a look? Might help if I can try configuring it on my machine- thanks

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Feb 2, 2024
@alexpf
Copy link
Author

alexpf commented Feb 2, 2024 via email

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Feb 2, 2024
@alexpf
Copy link
Author

alexpf commented Feb 6, 2024

Was surprised to see that my attachment has been lost on the way,
eldak.zip

@eleanorjboyd
Copy link
Member

eleanorjboyd commented Mar 29, 2024

Thanks for the project! Opened it and promptly got this to open, you are unable to get to this step working right?
Screenshot 2024-03-29 at 1 54 46 PM

Could you try this command in your terminal and see if it works: ..venv\Scripts\python.exe -m vscode_pytest --collect-only? This is the exact command we are running and so if that doesn't work from the terminal that would explain it. I am thinking it is the double '.' at the beginning that might cause the problem. I would check to see if you are setting that anywhere but I will also check how we get the active interpreter since it might be a problem on our side.

Let me know if you can get a command working for discovery just in your terminaI. If not try playing around with the python interpreter path and let me know if you are able to get it working.

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Mar 29, 2024
@alexpf
Copy link
Author

alexpf commented Apr 1, 2024

I already forgot about this issue, switched from VSCode to PyCharm and removed the test project :)
Ok, I downloaded it back from here.
The command ..venv\Scripts\python.exe -m vscode_pytest --collect-only doesn't work at all, probably because of two dots at the beginning instead of 1.
The command .venv\Scripts\python.exe -m vscode_pytest --collect-only results in an error: C:\Users\Aleksei_Lesnov_work\projects\vscode\eldak.venv\Scripts\python.exe: No module named vscode_pytest
Apparently, your command requires a Python module that isn't there.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Apr 1, 2024
@eleanorjboyd
Copy link
Member

Hi! Glad the removal of the extra dot works! My apologies when I sent the command I meant to remove the -m vscode_pytest since this is custom. We use this module to collect the test results. We add the location of the module to the path automatically so when you run through the UI it works seemlessly.

I will check how we select the interpreter to use for the command but if you do have ..venv\Scripts\python.exe in a config somewhere we are likely finding that and selecting it so setting your interpreter path would be the work around.

Ill get back to you about how we do interpreter selection and where exactly we find that path. Thanks

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Apr 2, 2024
@alexpf
Copy link
Author

alexpf commented Apr 2, 2024 via email

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Apr 2, 2024
@eleanorjboyd
Copy link
Member

@karthiknadig, any idea how we are getting the wrong iterpreter? Seems we are selecting ..venv\Scripts\python.exe which is causing a breakage because of an extra . at the beginning. What settings are worth checking for the cwd where this incorrect path might be hiding?

@alexpf if you are able to find anywhere in your settings that references ..venv\Scripts\python.exe , that would be helpful as it might be saved incorrectly somewhere as we are picking it up from your environment somehow. Thanks

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Apr 25, 2024
@alexpf
Copy link
Author

alexpf commented May 1, 2024

No, there are no wrong references. I think you guys are in general moving in a wrong direction. Because whatever changes I made, nothing helped in discovering tests. I even dropped the whole idea of using VS Code, in favor of PyCharm which just works.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label May 1, 2024
@eleanorjboyd
Copy link
Member

Apologies for all the confusion!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

4 participants
@alexpf @debonte @eleanorjboyd and others