pytest-trio icon indicating copy to clipboard operation
pytest-trio copied to clipboard

"nursery was never yielded from" warnings

Open smurfix opened this issue 7 years ago • 3 comments

Yes, asyncio's CoroWrapper is loud and annoying. However …

tests/python/test_events.py::TrioEventLoopTests::test_create_unix_server_ssl_verify_failed ERROR:asyncio:<CoroWrapper nursery() running at /usr/lib/python3/dist-packages/pytest_trio/plugin.py:245, created at /usr/lib/python3.6/asyncio/coroutines.py:85> was never yielded from
Coroutine object created at (most recent call last, truncated to 10 last lines):
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 248, in _wrapped_call
    call_outcome = _CallOutcome(func)
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
    self.result = func()
  File "/usr/lib/python3/dist-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File "/usr/lib/python3/dist-packages/_pytest/fixtures.py", line 818, in pytest_fixture_setup
    result = call_fixture_func(fixturefunc, request, kwargs)
  File "/usr/lib/python3/dist-packages/_pytest/fixtures.py", line 712, in call_fixture_func
    res = fixturefunc(**kwargs)
  File "/usr/lib/python3.6/asyncio/coroutines.py", line 85, in debug_wrapper
    return CoroWrapper(gen, None)

smurfix avatar Jan 30 '18 08:01 smurfix

Sorry, I don't understand what's going on here. Can you elaborate? :-)

njsmith avatar Jan 30 '18 10:01 njsmith

Basically I'm running the asyncio testsuite. It installs a CoroWrapper (via sys.set_coroutine_wrapper()) to warn about not awaiting async procedures after calling them:

async def foo():
    pass
foo()

Thus, pytest-trio's nursery fixture is called (but not used) even if the testcase in question doesn't require it. This happens for every test, more or less. I'd like that to not happen, if at all possible.

I have just pushed the asyncio tests to trio-asyncio. They don't all work yet (I'm having an issue with SIGCHLD not getting where it's supposed to go, which is surprising … NOT) but running them spews a ton of these stack traces.

smurfix avatar Jan 30 '18 11:01 smurfix

In theory CoroWrapper shouldn't generate any new warnings, it should just add some extra detail to the regular Warning: coroutine '...' was never awaited warnings.

Definitely there's something weird going on here – we shouldn't be calling the nursery coroutine and not awaiting it. But we need to understand why that's happening.

(You aren't requesting the nursery fixture in a test that's not marked as pytest.mark.trio, are you?)

njsmith avatar Jan 30 '18 19:01 njsmith