@@ -386,6 +386,7 @@ def _from_function(cls, function: Function, /) -> Function:
386
386
Instantiates this specific PytestAsyncioFunction type from the specified
387
387
Function item.
388
388
"""
389
+ assert function .get_closest_marker ("asyncio" )
389
390
subclass_instance = cls .from_parent (
390
391
function .parent ,
391
392
name = function .name ,
@@ -422,11 +423,10 @@ def _can_substitute(item: Function) -> bool:
422
423
return asyncio .iscoroutinefunction (func )
423
424
424
425
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
+ )
430
430
super ().runtest ()
431
431
432
432
@@ -466,11 +466,10 @@ def _can_substitute(item: Function) -> bool:
466
466
)
467
467
468
468
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
+ )
474
473
super ().runtest ()
475
474
476
475
@@ -488,10 +487,9 @@ def _can_substitute(item: Function) -> bool:
488
487
) and asyncio .iscoroutinefunction (func .hypothesis .inner_test )
489
488
490
489
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
+ )
495
493
super ().runtest ()
496
494
497
495
0 commit comments