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

@pytest.mark.asyncio(forbid_global_loop=True) has been removed in pytest-asyncio-0.6.0 #3339

Open
mgorny opened this issue Jul 31, 2024 · 3 comments

Comments

@mgorny
Copy link
Contributor

mgorny commented Jul 31, 2024

Version: redis-py 5.0.8, redis n/a

Platform: Gentoo Linux amd64, Python 3.12.4

Description:

The tests are using @pytest.mark.asyncio(forbid_global_loop=True), e.g.:

@pytest.mark.asyncio(forbid_global_loop=True)

However, this parameter has been removed in 0.6.0 (back in 2017), and pytest-asyncio 0.24.0 (currently alpha) actually errors when it is specified:

=============================================================== ERRORS ================================================================
________________________________________ ERROR collecting tests/test_asyncio/test_scripting.py ________________________________________
[…]
/usr/lib/python3.12/site-packages/pytest_asyncio/plugin.py:742: in pytest_generate_tests
    scope = _get_marked_loop_scope(marker)
        marker     = Mark(name='asyncio', args=(), kwargs={'forbid_global_loop': True})
        metafunc   = <_pytest.python.Metafunc object at 0x7f10dbfd8c80>
/usr/lib/python3.12/site-packages/pytest_asyncio/plugin.py:1010: in _get_marked_loop_scope
    raise ValueError("mark.asyncio accepts only a keyword argument 'scope'.")
E   ValueError: mark.asyncio accepts only a keyword argument 'scope'.
        asyncio_marker = Mark(name='asyncio', args=(), kwargs={'forbid_global_loop': True})

Note that htere are some other deprecation warnings too:

tests/test_asyncio/test_lock.py:107
  tests/test_asyncio/test_lock.py:107: PytestDeprecationWarning: test_blocking_timeout[single] is asynchronous and explicitly requests 
the "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.
    async def test_blocking_timeout(self, r, event_loop):

tests/test_asyncio/test_lock.py:107
  tests/test_asyncio/test_lock.py:107: PytestDeprecationWarning: test_blocking_timeout[pool] is asynchronous and explicitly requests th
e "event_loop" fixture. Asynchronous fixtures and test functions should use "asyncio.get_running_loop()" instead.
    async def test_blocking_timeout(self, r, event_loop):
@pravo23
Copy link

pravo23 commented Jul 31, 2024

Hi, how to reproduce this issue?

@mgorny
Copy link
Contributor Author

mgorny commented Jul 31, 2024

Ah, sorry for not making this clear. You can test against the prerelease using:

pip install pytest-asyncio==0.24.0a0

@MeggyCal
Copy link

MeggyCal commented Oct 9, 2024

Just adding that the reason for this misleading error is pytest-dev/pytest-asyncio#886. It was probably silently ignored before.

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