@@ -386,6 +386,7 @@ def _from_function(cls, function: Function, /) -> Function:
386386 Instantiates this specific PytestAsyncioFunction type from the specified
387387 Function item.
388388 """
389+ assert function .get_closest_marker ("asyncio" )
389390 subclass_instance = cls .from_parent (
390391 function .parent ,
391392 name = function .name ,
@@ -422,11 +423,10 @@ def _can_substitute(item: Function) -> bool:
422423 return asyncio .iscoroutinefunction (func )
423424
424425 def runtest (self ) -> None :
425- if self .get_closest_marker ("asyncio" ):
426- self .obj = wrap_in_sync (
427- # https://github.com/pytest-dev/pytest-asyncio/issues/596
428- self .obj , # type: ignore[has-type]
429- )
426+ self .obj = wrap_in_sync (
427+ # https://github.com/pytest-dev/pytest-asyncio/issues/596
428+ self .obj , # type: ignore[has-type]
429+ )
430430 super ().runtest ()
431431
432432
@@ -466,11 +466,10 @@ def _can_substitute(item: Function) -> bool:
466466 )
467467
468468 def runtest (self ) -> None :
469- if self .get_closest_marker ("asyncio" ):
470- self .obj = wrap_in_sync (
471- # https://github.com/pytest-dev/pytest-asyncio/issues/596
472- self .obj , # type: ignore[has-type]
473- )
469+ self .obj = wrap_in_sync (
470+ # https://github.com/pytest-dev/pytest-asyncio/issues/596
471+ self .obj , # type: ignore[has-type]
472+ )
474473 super ().runtest ()
475474
476475
@@ -488,10 +487,9 @@ def _can_substitute(item: Function) -> bool:
488487 ) and asyncio .iscoroutinefunction (func .hypothesis .inner_test )
489488
490489 def runtest (self ) -> None :
491- if self .get_closest_marker ("asyncio" ):
492- self .obj .hypothesis .inner_test = wrap_in_sync (
493- self .obj .hypothesis .inner_test ,
494- )
490+ self .obj .hypothesis .inner_test = wrap_in_sync (
491+ self .obj .hypothesis .inner_test ,
492+ )
495493 super ().runtest ()
496494
497495
0 commit comments