Closed
Description
The Skipped
exception used by pytest (e.g. pytest.importorskip
) is derived from BaseException
, and therefore is not caught by asyncio.events
's _run
:
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'
Metadata
Metadata
Assignees
Labels
No labels