coroutine '_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup' was never awaited RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Hi all
I am trying to debug async pytest in pycharm and I have the following error messages:

============================= test session starts ==============================
collecting ... collected 1 item

test_main.py::test_duplicate_user ERROR                                  [100%]
test setup failed
request = <SubRequest 'client' for <Coroutine test_duplicate_user>>, kwargs = {}
func = <function client at 0x1033cccc0>
setup = <function _wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup at 0x1050cb380>
finalizer = <function _wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.finalizer at 0x1028b9760>

   @functools.wraps(fixture)
   def _asyncgen_fixture_wrapper(request: SubRequest, **kwargs: Any):
       func = _perhaps_rebind_fixture_func(
           fixture, request.instance, fixturedef.unittest
       )
       event_loop = kwargs.pop(event_loop_fixture_id)
       gen_obj = func(
           **_add_kwargs(func, kwargs, event_loop_fixture_id, event_loop, request)
       )
   
       async def setup():
           res = await gen_obj.__anext__()
           return res
   
       def finalizer() -> None:
           """Yield again, to finalize."""
   
           async def async_finalizer() -> None:
               try:
                   await gen_obj.__anext__()
               except StopAsyncIteration:
                   pass
               else:
                   msg = "Async generator fixture didn't stop."
                   msg += "Yield only once."
                   raise ValueError(msg)
   
           event_loop.run_until_complete(async_finalizer())
   
>       result = event_loop.run_until_complete(setup())

../../Library/Caches/pypoetry/virtualenvs/dobotsvc-OMB4I0Ix-py3.12/lib/python3.12/site-packages/pytest_asyncio/plugin.py:347: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/Applications/PyCharm.app/Contents/plugins/python/helpers-pro/pydevd_asyncio/pydevd_nest_asyncio.py:202: in run_until_complete
   self._run_once()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <_UnixSelectorEventLoop running=False closed=False debug=False>

   def _run_once(self):
       """
       Simplified re-implementation of asyncio's _run_once that
       runs handles as they become ready.
       """
       ready = self._ready
       scheduled = self._scheduled
       while scheduled and scheduled[0]._cancelled:
           heappop(scheduled)
   
       timeout = (
           0 if ready or self._stopping
           else min(max(
               scheduled[0]._when - self.time(), 0), 86400) if scheduled
           else None)
       event_list = self._selector.select(timeout)
       self._process_events(event_list)
   
       end_time = self.time() + self._clock_resolution
       while scheduled and scheduled[0]._when < end_time:
           handle = heappop(scheduled)
           ready.append(handle)
   
>       if self._compute_internal_coro:
E       AttributeError: '_UnixSelectorEventLoop' object has no attribute '_compute_internal_coro'

/Applications/PyCharm.app/Contents/plugins/python/helpers-pro/pydevd_asyncio/pydevd_nest_asyncio.py:236: AttributeError


========================= 2 warnings, 1 error in 1.60s =========================
sys:1: RuntimeWarning: coroutine '_wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Here is how I run the test in the debug mode:

What am I doing wrong?

Best regards,
Anu

0

Hi Anujit Marty !

Which version is it? Does it help to update to recent 2023.3.4 version which has PY-64542 fixed?

0

请先登录再写评论。