Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkdl committed Nov 1, 2024
1 parent 5c41d50 commit 8e100ea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,16 @@ def _get_active_fixturedef(
raise FixtureLookupError(argname, self)
fixturedef = fixturedefs[index]

if not inspect.iscoroutinefunction(self.function) and (
inspect.iscoroutinefunction(fixturedef.func)
or inspect.isasyncgenfunction(fixturedef.func)
# Check for attempted use of an async fixture by a sync test
# `self.scope` here is not the scope of the requested fixture, but the scope of
# the requester.
if (
self.scope == "function"
and not inspect.iscoroutinefunction(self._pyfuncitem.obj)
and (
inspect.iscoroutinefunction(fixturedef.func)
or inspect.isasyncgenfunction(fixturedef.func)
)
):
if fixturedef._autouse:
warnings.warn(

Check warning on line 610 in src/_pytest/fixtures.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/fixtures.py#L610

Added line #L610 was not covered by tests
Expand Down

0 comments on commit 8e100ea

Please sign in to comment.