Skip to content

Commit

Permalink
Update makr.asyncio usage
Browse files Browse the repository at this point in the history
  • Loading branch information
uriyyo committed Sep 10, 2024
1 parent 79a30b3 commit ff6db62
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async def run_pagination_test(
*[f"limit-offset-{key}" for key in _params_desc],
],
)
@mark.asyncio
@mark.asyncio(loop_scope="session")
async def test_pagination(
self,
client,
Expand Down
2 changes: 1 addition & 1 deletion tests/ext/test_cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def route():
return add_pagination(app)


@mark.asyncio
@mark.asyncio(loop_scope="session")
async def test_cursor(app, client, entities):
entities = sorted(parse_obj_as(List[UserOut], entities), key=(lambda it: (it.id, it.name)))

Expand Down
6 changes: 3 additions & 3 deletions tests/ext/test_sqlalchemy_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def route_on_order(db: Session = Depends(get_db)):


@sqlalchemy20
@mark.asyncio
@mark.asyncio(loop_scope="session")
async def test_cursor(app, client, entities):
entities = sorted(parse_obj_as(List[UserOut], entities), key=(lambda it: (it.id, it.name)))

Expand Down Expand Up @@ -90,7 +90,7 @@ async def test_cursor(app, client, entities):


@sqlalchemy20
@mark.asyncio
@mark.asyncio(loop_scope="session")
async def test_cursor_refetch(app, client, entities, postgres_url):
entities = sorted(parse_obj_as(List[UserOut], entities), key=(lambda it: (it.id, it.name)))
first_85_entities = entities[:85]
Expand Down Expand Up @@ -180,7 +180,7 @@ async def test_cursor_refetch(app, client, entities, postgres_url):


@sqlalchemy20
@mark.asyncio
@mark.asyncio(loop_scope="session")
async def test_no_order(app, client, entities):
with raises(
ValueError,
Expand Down
14 changes: 14 additions & 0 deletions tests/patch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import asyncio
from functools import lru_cache

from pydantic import generics

# https://github.com/pydantic/pydantic/issues/4483
generics._generic_types_cache = {}
generics._assigned_parameters = {}


@lru_cache()
def _get_event_loop_no_warn(*_):
loop = asyncio.new_event_loop()
loop.__pytest_asyncio = True

return loop


# plugin._get_event_loop_no_warn = _get_event_loop_no_warn

0 comments on commit ff6db62

Please sign in to comment.