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

Fixes pytest-asyncio warning for event_loop fixture #1760

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

waketzheng
Copy link
Contributor

Unittest of blacksheep example print the following warnings:

/Users/mac10.12/Library/Caches/pypoetry/virtualenvs/tortoise-orm-iT379CwK-py3.11/lib/python3.11/site-packages/pytest_asyncio/plugin.py:208: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
====================================================== test session starts =======================================================
platform darwin -- Python 3.11.9, pytest-8.3.3, pluggy-1.5.0
rootdir: /Users/mac10.12/github/tortoise-orm
configfile: pyproject.toml
plugins: asyncio-0.24.0, cov-5.0.0, anyio-4.5.2, xdist-3.6.1
asyncio: mode=Mode.STRICT, default_loop_scope=None
collected 4 items

examples/blacksheep/_tests.py ....                                                                                         [100%]

======================================================== warnings summary ========================================================
examples/blacksheep/_tests.py::test_get_uses_list
  /Users/mac10.12/Library/Caches/pypoetry/virtualenvs/tortoise-orm-iT379CwK-py3.11/lib/python3.11/site-packages/pytest_asyncio/plugin.py:783: DeprecationWarning: The event_loop fixture provided by pytest-asyncio has been redefined in
  /Users/mac10.12/github/tortoise-orm/examples/blacksheep/_tests.py:18
  Replacing the event_loop fixture with a custom implementation is deprecated
  and will lead to errors in the future.
  If you want to request an asyncio event loop with a scope other than function
  scope, use the "scope" argument to the asyncio mark when marking the tests.
  If you want to return different types of event loops, use the event_loop_policy
  fixture.

    warnings.warn(

examples/blacksheep/_tests.py::test_get_uses_list
examples/blacksheep/_tests.py::test_create_user
examples/blacksheep/_tests.py::test_update_user
  /Users/mac10.12/Library/Caches/pypoetry/virtualenvs/tortoise-orm-iT379CwK-py3.11/lib/python3.11/site-packages/pydantic/main.py:1114: PydanticDeprecatedSince20: The `dict` method is deprecated; use `model_dump` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.9/migration/
    warnings.warn('The `dict` method is deprecated; use `model_dump` instead.', category=PydanticDeprecatedSince20)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

How to reproduce:

TORTOISE_TEST_DB=sqlite://:memory: PYTHONPATH=examples/blacksheep pytest examples/blacksheep/_tests.py

Since pytest-asyncio>=0.24, the loop_scope argument was supported, so I upgrade the package and apply this argument.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11721656067

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.074%

Totals Coverage Status
Change from base Build 11660093686: 0.0%
Covered Lines: 6025
Relevant Lines: 6650

💛 - Coveralls

@abondar abondar merged commit 9e392e4 into tortoise:develop Nov 9, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

3 participants