Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1172.added.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compatibility with the `Pyright` type checker
1 change: 1 addition & 0 deletions changelog.d/1177.fixed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``RuntimeError: There is no current event loop in thread 'MainThread'`` when any test unsets the event loop (such as when using ``asyncio.run`` and ``asyncio.Runner``).
9 changes: 4 additions & 5 deletions pytest_asyncio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def _asyncgen_fixture_wrapper(
gen_obj = fixture_function(*args, **kwargs)

async def setup():
res = await gen_obj.__anext__() # type: ignore[union-attr]
res = await gen_obj.__anext__()
return res

context = contextvars.copy_context()
Expand All @@ -324,7 +324,7 @@ def finalizer() -> None:

async def async_finalizer() -> None:
try:
await gen_obj.__anext__() # type: ignore[union-attr]
await gen_obj.__anext__()
except StopAsyncIteration:
pass
else:
Expand Down Expand Up @@ -353,8 +353,7 @@ def _wrap_async_fixture(
runner: Runner,
request: FixtureRequest,
) -> Callable[AsyncFixtureParams, AsyncFixtureReturnType]:

@functools.wraps(fixture_function) # type: ignore[arg-type]
@functools.wraps(fixture_function)
def _async_fixture_wrapper(
*args: AsyncFixtureParams.args,
**kwargs: AsyncFixtureParams.kwargs,
Expand Down Expand Up @@ -782,7 +781,7 @@ def _get_marked_loop_scope(
return scope


def _get_default_test_loop_scope(config: Config) -> _ScopeName:
def _get_default_test_loop_scope(config: Config) -> Any:
return config.getini("asyncio_default_test_loop_scope")


Expand Down
Loading
Loading