Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: "@coroutine" decorator is deprecated #161

Open
ylassoued opened this issue Mar 24, 2022 · 3 comments
Open

DeprecationWarning: "@coroutine" decorator is deprecated #161

ylassoued opened this issue Mar 24, 2022 · 3 comments

Comments

@ylassoued
Copy link

Module mock.py, function proxy, declared in line 599, uses decorator @asyncio.coroutine.
It seems that the asyncio @coroutine decorator is deprecated since Python 3.8.
Please use async def instead.
Source code should be modified to look something like:

           async def proxy():
            try:
                if inspect.isawaitable(result):
                    return (yield from result)
                else:
                    return result
            finally:
                _mock_self.await_count += 1
                _mock_self.await_args = _call
                _mock_self.await_args_list.append(_call)
                yield from _mock_self.awaited._notify()
@RemiCardona
Copy link
Contributor

Asynctest partially works on 3.8 but fails almost completely on 3.9, see #132 and #144. So it's much bigger than just the use of @coroutine.

@ylassoued
Copy link
Author

Thanks @RemiCardona! Hmmm, this is really disappointing! Does this mean that I should just avoid using this API for Python 3.8 and above? Or is a new version, with full support for Python 3.8+, planned?

@WolfgangFahl
Copy link

In my case python 3.11 complains:

    import asynctest
  File "/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/asynctest/__init__.py", line 22, in <module>
    from .case import *
  File "/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/asynctest/case.py", line 54, in <module>
    import asynctest.selector
  File "/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/asynctest/selector.py", line 29, in <module>
    from . import mock
  File "/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/asynctest/mock.py", line 428, in <module>
    class _AwaitEvent:
  File "/opt/hostedtoolcache/Python/3.11.0/x64/lib/python3.11/site-packages/asynctest/mock.py", line 433, in _AwaitEvent
    @asyncio.coroutine
     ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants