File tree 1 file changed +1
-6
lines changed
1 file changed +1
-6
lines changed Original file line number Diff line number Diff line change 21
21
Set ,
22
22
TypeVar ,
23
23
Union ,
24
- cast ,
25
24
overload ,
26
25
)
27
26
@@ -509,19 +508,15 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> Optional[object]:
509
508
"""
510
509
marker = pyfuncitem .get_closest_marker ("asyncio" )
511
510
if marker is not None :
512
- funcargs : Dict [str , object ] = pyfuncitem .funcargs # type: ignore[name-defined]
513
- loop = cast (asyncio .AbstractEventLoop , funcargs ["event_loop" ])
514
511
if _is_hypothesis_test (pyfuncitem .obj ):
515
512
pyfuncitem .obj .hypothesis .inner_test = wrap_in_sync (
516
513
pyfuncitem ,
517
514
pyfuncitem .obj .hypothesis .inner_test ,
518
- _loop = loop ,
519
515
)
520
516
else :
521
517
pyfuncitem .obj = wrap_in_sync (
522
518
pyfuncitem ,
523
519
pyfuncitem .obj ,
524
- _loop = loop ,
525
520
)
526
521
yield
527
522
@@ -533,7 +528,6 @@ def _is_hypothesis_test(function: Any) -> bool:
533
528
def wrap_in_sync (
534
529
pyfuncitem : pytest .Function ,
535
530
func : Callable [..., Awaitable [Any ]],
536
- _loop : asyncio .AbstractEventLoop ,
537
531
):
538
532
"""Return a sync wrapper around an async function executing it in the
539
533
current event loop."""
@@ -559,6 +553,7 @@ def inner(*args, **kwargs):
559
553
)
560
554
)
561
555
return
556
+ _loop = asyncio .get_event_loop ()
562
557
task = asyncio .ensure_future (coro , loop = _loop )
563
558
try :
564
559
_loop .run_until_complete (task )
You can’t perform that action at this time.
0 commit comments