You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This results in the following warning/error when using it in an async test:
Task exception was never retrieved
future: <Task finished coro=<test_database_sync_to_async() done, defined at …/Vcs/channels/tests/test_db.py:6> exception=could not import 'psycopg2xx'>
Traceback (most recent call last):
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/_pytest/runner.py", line 226, in from_call
result = func()
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/_pytest/runner.py", line 198, in <lambda>
lambda: ihook(item=item, **kwds), when=when, reraise=reraise
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 62, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/_pytest/runner.py", line 123, in pytest_runtest_call
item.runtest()
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/_pytest/python.py", line 1464, in runtest
self.ihook.pytest_pyfunc_call(pyfuncitem=self)
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/hooks.py", line 289, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 68, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/manager.py", line 62, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "…/Vcs/pytest-asyncio/pytest_asyncio/plugin.py", line 158, in pytest_pyfunc_call
pyfuncitem.obj(**testargs), loop=event_loop))
File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
self.run_forever()
File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
self._run_once()
File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
handle._run()
File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "…/Vcs/channels/tests/test_db.py", line 15, in test_database_sync_to_async
pytest.importorskip("psycopg2xx")
File "…/Vcs/channels/.venv/lib/python3.7/site-packages/_pytest/outcomes.py", line 172, in importorskip
raise Skipped(reason, allow_module_level=True)
Skipped: could not import 'psycopg2xx'
The text was updated successfully, but these errors were encountered:
Asyncio doesn't get the results of tasks that fail with exceptions that
don't subclass `Exception` (like pytest's `Skipped`) in
`run_until_complete`. This leads to asyncio logging noisily warnings when
pytest's skip functionality is mixed with this plugin.
This fixes this error, and adds a test.
Fixes#123.
Co-Authored-By: Daniel Hahler <[email protected]>
Co-Authored-By: Andrew Svetlov <[email protected]>
The
Skipped
exception used by pytest (e.g.pytest.importorskip
) is derived fromBaseException
, and therefore is not caught byasyncio.events
's_run
:Ref: https://github.com/pytest-dev/pytest/blob/865e84d206581f77640cfbc1516aff7a0d7316c6/src/_pytest/outcomes.py#L36
https://github.com/blueyed/cpython/blob/443fe5a52a3d6a101795380227ced38b4b5e0a8b/Lib/asyncio/events.py#L79-L94
This results in the following warning/error when using it in an async test:
The text was updated successfully, but these errors were encountered: