Repository navigation
Pytest times out in debug mode with Pycharm 2023.2.1 #152
Copy link
Copy link
Open
Description
I am getting the timeout error below when running a test in debug mode with pytest under Pycharm 2023.2.1.
This timeout depends on the timeout value pytest is configured with. I am not getting this issue with older versions of Pycharm. So basically, Pycharm does not ignore the timeout in debug mode.
Note: this issue is similar to this one
Connected to pydev debugger (build 232.9559.58)
/Users/williamafonso/Programming/sara/.venv/bin/python3.11 /Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 55298 --file /Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py --target test_banned_passwords.py::test_is_password_banned
Testing started at 14:34 ...
Launching pytest with arguments test_banned_passwords.py::test_is_password_banned --no-header --no-summary -q in /Users/williamafonso/Programming/sara/tests/unittests/utils
============================= test session starts ==============================
collecting ... collected 1 item
test_banned_passwords.py::test_is_password_banned
+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++
~~~~~~~~~~~~~~~~~~ Stack of pydevd.CommandThread (6153744384) ~~~~~~~~~~~~~~~~~~
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 995, in _bootstrap
self._bootstrap_inner()
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 219, in run
self._on_run()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 150, in _on_run
self._py_db_command_thread_event.wait(0.3)
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 622, in wait
signaled = self._cond.wait(timeout)
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 324, in wait
gotit = waiter.acquire(True, timeout)
~~~~~~~~~~~~~~~~~~~~~ Stack of pydevd.Reader (6136918016) ~~~~~~~~~~~~~~~~~~~~~~
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 995, in _bootstrap
self._bootstrap_inner()
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 219, in run
self._on_run()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 293, in _on_run
r = self.sock.recv(1024)
~~~~~~~~~~~~~~~~~~~~~ Stack of pydevd.Writer (6120091648) ~~~~~~~~~~~~~~~~~~~~~~
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 995, in _bootstrap
self._bootstrap_inner()
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 219, in run
self._on_run()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 368, in _on_run
cmd = self.cmdQueue.get(1, 0.1)
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/queue.py", line 180, in get
self.not_empty.wait(remaining)
File "/Users/williamafonso/.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 324, in wait
gotit = waiter.acquire(True, timeout)
~~~~~~~~~~~~~~~~~~~~~~~ Stack of MainThread (8016781440) ~~~~~~~~~~~~~~~~~~~~~~~
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 2199, in <module>
main()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 2181, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1493, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1500, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py", line 60, in <module>
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/config/__init__.py", line 168, in main
ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 493, in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 115, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 77, in _multicall
res = hook_impl.function(*args)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/main.py", line 317, in pytest_cmdline_main
return wrap_session(config, _main)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/main.py", line 270, in wrap_session
session.exitstatus = doit(config, session) or 0
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/main.py", line 324, in _main
config.hook.pytest_runtestloop(session=session)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 493, in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 115, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 77, in _multicall
res = hook_impl.function(*args)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/main.py", line 349, in pytest_runtestloop
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 493, in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 115, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 77, in _multicall
res = hook_impl.function(*args)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 114, in pytest_runtest_protocol
runtestprotocol(item, nextitem=nextitem)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 133, in runtestprotocol
reports.append(call_and_report(item, "call", log))
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 222, in call_and_report
call = call_runtest_hook(item, when, **kwds)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 261, in call_runtest_hook
return CallInfo.from_call(
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 341, in from_call
result: Optional[TResult] = func()
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 262, in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 493, in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 115, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 77, in _multicall
res = hook_impl.function(*args)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/runner.py", line 169, in pytest_runtest_call
item.runtest()
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/python.py", line 1792, in runtest
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_hooks.py", line 493, in __call__
return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_manager.py", line 115, in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/pluggy/_callers.py", line 77, in _multicall
res = hook_impl.function(*args)
File "/Users/williamafonso/Programming/sara/.venv/lib/python3.11/site-packages/_pytest/python.py", line 194, in pytest_pyfunc_call
result = testfunction(**testargs)
File "/Users/williamafonso/Programming/sara/tests/unittests/utils/test_banned_passwords.py", line 8, in test_is_password_banned
banned_passwords = BannedPasswords()
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1160, in do_wait_suspend
self._do_wait_suspend(thread, frame, event, arg, suspend_type, from_this_thread)
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1175, in _do_wait_suspend
time.sleep(0.01)
+++++++++++++++++++++++++++++++++++ Timeout ++++++++++++++++++++++++++++++++++++
Process finished with exit code 1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
flub commentedon Oct 9, 2023
pycharm probably changed things. Could you figure out how to update the heuristic to detect the pycharm debugger and make a PR?
pytest-timeout/pytest_timeout.py
Line 50 in 78cc24f
I'm afraid I don't have pycharm so rely on its users to keep supporting this.