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

backwards compatible hookwrapper for pytest_xdist_auto_num_workers doesn't work #23816

Closed
DetachHead opened this issue Jul 15, 2024 · 14 comments · Fixed by #23791 or #23866
Closed

backwards compatible hookwrapper for pytest_xdist_auto_num_workers doesn't work #23816

DetachHead opened this issue Jul 15, 2024 · 14 comments · Fixed by #23791 or #23866
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on verified Verification succeeded
Milestone

Comments

@DetachHead
Copy link

DetachHead commented Jul 15, 2024

Type: Bug

Behaviour

the change in #23781 now causes the pytest plugin to crash

2024-07-16 09:27:28.042 [error]   File "c:\Users\user\.vscode\extensions\ms-python.python-2024.11.2024071501-win32-x64\python_files\vscode_pytest\__init__.py", line 894, in pytest_xdist_auto_num_workers

2024-07-16 09:27:28.042 [error]     return min((yield), len(config.option.file_or_dir))

2024-07-16 09:27:28.042 [error]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError
2024-07-16 09:27:28.042 [error] : '<' not supported between instances of 'int' and 'Result'

the fix i suggested here will fix the crash, but for some reason using hookwrapper instead of wrapper causes the hook to not work at all, and i can't figure out why. i will do some more investigating and see i can figure it out

Steps to reproduce:

  1. run pytest collection by clicking the refresh button in the test explorer
  2. click "Show output" on the error message

environment information

pytest version: 8.2.2
pluggy version: 1.5.0

Extension version: 2024.11.2024071501 (i manually updated the pytest plugin with the change from #23781)
VS Code version: Code 1.91.0 (ea1445cc7016315d0f5728f8e8b12a45dc0a7286, 2024-07-01T18:52:22.949Z)
OS version: Windows_NT x64 10.0.22621
Modes:

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jul 15, 2024
@DetachHead
Copy link
Author

fixed in #23791

@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on area-testing and removed triage-needed Needs assignment to the proper sub-team labels Jul 16, 2024
@eleanorjboyd eleanorjboyd added this to the July 2024 milestone Jul 22, 2024
@DonJayamanne
Copy link

@eleanorjboyd Are there any specific steps to verify this.
Or should we just test discovery and running of py test tests

@eleanorjboyd
Copy link
Member

Steps:

  1. setup a venv, install pytest
  2. now install pluggy version 1.1.0, python -m pip install pluggy==1.1.0
  3. attempt test discovery again
  4. ensure it is successful and no logs are in the python output about "wrapper" being unknown / incompatible

@andreamah
Copy link

andreamah commented Jul 24, 2024

@eleanorjboyd I see this after step 3:

Image

I don't see anything in the python output about wrapper though. Is this the correct behavior? My log level is at info.

@eleanorjboyd
Copy link
Member

@andreamah can you reload? What do the logs say? Also does the dropdown work with the ones with the correct tests

@andreamah
Copy link

andreamah commented Jul 24, 2024

Here are the logs:

logs
2024-07-24 13:48:04.155 [info] Discover tests for workspace name: pytest-test - uri: c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test
2024-07-24 13:48:04.155 [info] Running discovery for pytest using the new test adapter.
2024-07-24 13:48:04.156 [warning] The cwd resolves to a different path, checking if it has a symbolic link somewhere in its path.
2024-07-24 13:48:04.158 [info] All environment variables set for pytest discovery: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\andreamah\\AppData\\Roaming","CHROME_CRASHPAD_PIPE_NAME":"\\\\.\\pipe\\crashpad_29360_MNUNTWKRKQHTSGDE","COMPUTERNAME":"DESKTOP-956ATPJ","EFC_12304":"1","ELECTRON_RUN_AS_NODE":"1","FPS_BROWSER_APP_PROFILE_STRING":"Internet Explorer","FPS_BROWSER_USER_PROFILE_STRING":"Default","GIT_LFS_PATH":"C:\\Program Files\\Git LFS","GOPATH":"C:\\Users\\andreamah\\go","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\andreamah","LOCALAPPDATA":"C:\\Users\\andreamah\\AppData\\Local","LOGONSERVER":"\\\\DESKTOP-956ATPJ","NUMBER_OF_PROCESSORS":"8","NVM_HOME":"C:\\Users\\andreamah\\AppData\\Roaming\\nvm","NVM_SYMLINK":"C:\\Program Files\\nodejs","OPENAI_API_KEY":"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","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","POSH_INSTALLER":"winget","POSH_THEMES_PATH":"C:\\Users\\andreamah\\AppData\\Local\\Programs\\oh-my-posh\\themes","POWERSHELL_DISTRIBUTION_CHANNEL":"MSI:Windows 10 Enterprise","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 140 Stepping 1, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"8c01","PUBLIC":"C:\\Users\\Public","SESSIONNAME":"Console","TEMP":"C:\\Users\\ANDREA~1\\AppData\\Local\\Temp","TMP":"C:\\Users\\ANDREA~1\\AppData\\Local\\Temp","UATDATA":"C:\\windows\\CCM\\UATData\\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77","USERDNSDOMAIN":"redmond.corp.microsoft.com","USERDOMAIN":"REDMOND","USERDOMAIN_ROAMINGPROFILE":"REDMOND","USERNAME":"andreamah","USERPROFILE":"C:\\Users\\andreamah","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\andreamah\\AppData\\Roaming\\Code - Insiders\\CachedData\\3873c58c47cb9690cda5f8e22f4f81b040c35891","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\Users\\andreamah\\AppData\\Local\\Programs\\Microsoft VS Code Insiders","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\087f3e47-1.92.0-insider-main-sock","VSCODE_NLS_CONFIG":"{\"userLocale\":\"en\",\"osLocale\":\"en-us\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"C:\\\\Users\\\\andreamah\\\\AppData\\\\Local\\\\Programs\\\\Microsoft VS Code Insiders\\\\resources\\\\app\\\\out\\\\nls.messages.json\",\"locale\":\"en\",\"availableLanguages\":{}}","VSCODE_PID":"29360","ChocolateyInstall":"C:\\ProgramData\\chocolatey","ChocolateyLastPathUpdate":"132997026502554380","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","OneDrive":"C:\\Users\\andreamah\\OneDrive - Microsoft","OneDriveCommercial":"C:\\Users\\andreamah\\OneDrive - Microsoft","PSModulePath":"C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules;C:\\Program Files (x86)\\Microsoft Azure Information Protection\\Powershell","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","SystemDrive":"C:","SystemRoot":"C:\\WINDOWS","windir":"C:\\WINDOWS","Path":"C:\\Program Files\\Common Files\\Oracle\\Java\\javapath;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\ProgramData\\chocolatey\\bin;C:\\Program Files\\dotnet\\;C:\\Program Files\\Git LFS;C:\\Program Files\\GitHub CLI\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Microsoft VS Code Exploration\\bin;C:\\Users\\andreamah\\AppData\\Roaming\\nvm;C:\\Program Files\\nodejs;C:\\Users\\andreamah\\AppData\\Local\\anaconda3\\Scripts;C:\\Program Files\\Microsoft VS Code\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Go\\bin;C:\\Program Files (x86)\\Go\\bin;C:\\Program Files (x86)\\Gpg4win\\..\\GnuPG\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Program Files\\Microsoft VS Code Insiders\\bin;C:\\Users\\andreamah\\.cargo\\bin;C:\\Users\\andreamah\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\andreamah\\AppData\\Roaming\\npm;C:\\Users\\andreamah\\.dotnet\\tools;C:\\Users\\andreamah\\.vscode-server-launcher\\bin;C:\\Users\\andreamah\\.vscode-cli\\bin;C:\\Users\\andreamah\\.dotnet\\tools;C:\\Users\\andreamah\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\andreamah\\.vscode-server-launcher\\bin;C:\\Users\\andreamah\\.dotnet\\tools;C:\\Users\\andreamah\\AppData\\Roaming\\nvm;C:\\Program Files\\nodejs;C:\\Users\\andreamah\\AppData\\Local\\Programs\\oh-my-posh\\bin;C:\\Users\\andreamah\\AppData\\Local\\anaconda3\\Scripts;C:\\Users\\andreamah\\Documents\\vscode;C:\\Users\\andreamah\\AppData\\Local\\Programs\\Microsoft VS Code Insiders\\bin;C:\\Users\\andreamah\\go\\bin;","PYTHONPATH":"c:\\Users\\andreamah\\.vscode-insiders\\extensions\\ms-python.python-2024.11.2024072402-win32-x64\\python_files","TEST_RUN_PIPE":"\\\\.\\pipe\\python-test-discovery-71a00bb12ef195408897-sock"}
2024-07-24 13:48:04.159 [warning] could not find a pixi interpreter for the interpreter at c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Scripts\python.exe
2024-07-24 13:48:04.184 [info] > "~/OneDrive - Microsoft/Documents/for-testing/pytest-test/venv/Scripts/activate.bat" && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python ~/.vscode-insiders/extensions/ms-python.python-2024.11.2024072402-win32-x64/python_files/printEnvVariables.py
2024-07-24 13:48:04.184 [info] shell: commandPrompt
2024-07-24 13:48:04.525 [warning] could not find a pixi interpreter for the interpreter at c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Scripts\python.exe
2024-07-24 13:48:04.538 [info] > "~\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Scripts\python.exe" -m pytest -p vscode_pytest --collect-only .
2024-07-24 13:48:04.539 [info] cwd: ~\OneDrive - Microsoft\Documents\for-testing\pytest-test
2024-07-24 13:48:05.510 [error] Traceback (most recent call last):
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 781, in import_plugin

2024-07-24 13:48:05.514 [error]     __import__(importspec)

2024-07-24 13:48:05.515 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\assertion\rewrite.py", line 186, in exec_module

2024-07-24 13:48:05.520 [error]     exec(co, module.__dict__)

2024-07-24 13:48:05.520 [error]   File "c:\Users\andreamah\.vscode-insiders\extensions\ms-python.python-2024.11.2024072402-win32-x64\python_files\vscode_pytest\__init__.py", line 22, in <module>

2024-07-24 13:48:05.524 [error]     from pluggy import Result
ImportError: cannot import name 'Result' from 'pluggy' (c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\__init__.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pytest\__main__.py", line 5, in <module>

2024-07-24 13:48:05.528 [error]     raise SystemExit(pytest.console_main())

2024-07-24 13:48:05.528 [error]                      ^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 192, in console_main

2024-07-24 13:48:05.532 [error]     code = main()
           ^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 150, in main

2024-07-24 13:48:05.535 [error]     config = _prepareconfig(args, plugins)
             ^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24 13:48:05.536 [error] ^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 331, in _prepareconfig

2024-07-24 13:48:05.538 [error]     config = pluginmanager.hook.pytest_cmdline_parse(
        
2024-07-24 13:48:05.539 [error]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\_hooks.py", line 424, in __call__

2024-07-24 13:48:05.541 [error]     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
      
2024-07-24 13:48:05.542 [error]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\_manager.py", line 122, in _hookexec

2024-07-24 13:48:05.545 [error]     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)

2024-07-24 13:48:05.546 [error]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\_callers.py", line 133, in _multicall

2024-07-24 13:48:05.548 [error]     teardown[0].send(outcome)

2024-07-24 13:48:05.548 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\helpconfig.py", line 104, in pytest_cmdline_parse

2024-07-24 13:48:05.550 [error]     config: Config = outcome.get_result()
                
2024-07-24 13:48:05.551 [error]      ^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\_result.py", line 108, in get_result

2024-07-24 13:48:05.553 [error]     raise exc.with_traceback(exc.__traceback__)

2024-07-24 13:48:05.554 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\_callers.py", line 80, in _multicall

2024-07-24 13:48:05.555 [error]     res = hook_impl.function(*args)

2024-07-24 13:48:05.555 [error]           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 1075, in pytest_cmdline_parse

2024-07-24 13:48:05.557 [error]     self.parse(args)

2024-07-24 13:48:05.558 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 1425, in parse

2024-07-24 13:48:05.559 [error]     self._preparse(args, addopts=addopts)

2024-07-24 13:48:05.560 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 1301, in _preparse

2024-07-24 13:48:05.562 [error]     self.pluginmanager.consider_preparse(args, exclude_only=False)

2024-07-24 13:48:05.563 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 709, in consider_preparse

2024-07-24 13:48:05.564 [error]     self.consider_pluginarg(parg)
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 735, in consider_pluginarg

2024-07-24 13:48:05.566 [error]     self.import_plugin(arg, consider_entry_points=True)
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 783, in import_plugin

2024-07-24 13:48:05.568 [error]     raise ImportError(
  File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\config\__init__.py", line 781, in import_plugin

2024-07-24 13:48:05.570 [error]     __import__(importspec)

2024-07-24 13:48:05.570 [error]   File "c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\_pytest\assertion\rewrite.py", line 186, in exec_module

2024-07-24 13:48:05.572 [error]     exec(co, module.__dict__)

2024-07-24 13:48:05.572 [error]   File "c:\Users\andreamah\.vscode-insiders\extensions\ms-python.python-2024.11.2024072402-win32-x64\python_files\vscode_pytest\__init__.py", line 22, in <module>

2024-07-24 13:48:05.573 [error]     from pluggy import Result
ImportError: Error importing plugin "vscode_pytest": cannot import name 'Result' from 'pluggy' (c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy\__init__.py)

2024-07-24 13:48:05.617 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test.
2024-07-24 13:48:05.617 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test. Creating and sending error discovery payload
2024-07-24 13:48:05.617 [error] pytest test discovery error for workspace:  c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test 
  
 The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test

It also might be a bad environment- it was left over from testing something else.

@eleanorjboyd
Copy link
Member

yeah this errored, need to re-open:

ImportError: Error importing plugin "vscode_pytest": cannot import name 'Result' from 'pluggy' (c:\Users\andreamah\OneDrive - Microsoft\Documents\for-testing\pytest-test\venv\Lib\site-packages\pluggy_init_.py)

@eleanorjboyd eleanorjboyd reopened this Jul 24, 2024
@DetachHead
Copy link
Author

what version of pluggy are you using?

@andreamah
Copy link

what version of pluggy are you using?

1.1.0

Image

@DetachHead
Copy link
Author

fixed in #23866

@eleanorjboyd
Copy link
Member

@andreamah what version of python are you running into this on?

@andreamah
Copy link

3.11.9

@rzhao271 rzhao271 added verified Verification succeeded and removed verified Verification succeeded labels Jul 26, 2024
@eleanorjboyd eleanorjboyd added the verified Verification succeeded label Jul 26, 2024
@eleanorjboyd
Copy link
Member

I was able to verify, @DetachHead are you able to try it with the most recent version of the python pre-release extension to confirm it works with what we shipped out? Thanks!

@DetachHead
Copy link
Author

yep it works

eleanorjboyd pushed a commit to eleanorjboyd/vscode-python that referenced this issue Jul 30, 2024
- Don't use xdist when only running one test. this makes it slightly
faster when running one test, because instead of creating a single
worker it just runs the test in the same process
- fix microsoft#23816
- fix issue where the plugin was being registered multiple times

---------

Co-authored-by: detachhead <[email protected]>
eleanorjboyd added a commit to eleanorjboyd/vscode-python that referenced this issue Jul 30, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on verified Verification succeeded
Projects
None yet
6 participants