File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -595,9 +595,16 @@ def _get_active_fixturedef(
595595 raise FixtureLookupError (argname , self )
596596 fixturedef = fixturedefs [index ]
597597
598- if not inspect .iscoroutinefunction (self .function ) and (
599- inspect .iscoroutinefunction (fixturedef .func )
600- or inspect .isasyncgenfunction (fixturedef .func )
598+ # Check for attempted use of an async fixture by a sync test
599+ # `self.scope` here is not the scope of the requested fixture, but the scope of
600+ # the requester.
601+ if (
602+ self .scope == "function"
603+ and not inspect .iscoroutinefunction (self ._pyfuncitem .obj )
604+ and (
605+ inspect .iscoroutinefunction (fixturedef .func )
606+ or inspect .isasyncgenfunction (fixturedef .func )
607+ )
601608 ):
602609 if fixturedef ._autouse :
603610 warnings .warn (
You can’t perform that action at this time.
0 commit comments