@@ -442,30 +442,15 @@ def _can_substitute(item: Function) -> bool:
442
442
"""Returns whether the specified function can be replaced by this class"""
443
443
raise NotImplementedError ()
444
444
445
- @functools .cached_property
446
- def loop_scope (self ) -> _ScopeName :
447
- """
448
- Return the scope of the asyncio event loop this item is run in.
449
-
450
- The effective scope is determined lazily. It is identical to to the
451
- `loop_scope` value of the closest `asyncio` pytest marker. If no such
452
- marker is present, the the loop scope is determined by the configuration
453
- value of `asyncio_default_test_loop_scope`, instead.
454
- """
455
- marker = self .get_closest_marker ("asyncio" )
456
- assert marker is not None
457
- default_loop_scope = _get_default_test_loop_scope (self .config )
458
- return _get_marked_loop_scope (marker , default_loop_scope )
459
-
460
445
def setup (self ) -> None :
461
446
fixturenames = self .fixturenames
462
- runner_fixture_id = f"_{ self .loop_scope } _scoped_runner"
447
+ runner_fixture_id = f"_{ self ._loop_scope } _scoped_runner"
463
448
if runner_fixture_id not in fixturenames :
464
449
fixturenames .append (runner_fixture_id )
465
450
return super ().setup ()
466
451
467
452
def runtest (self ) -> None :
468
- runner_fixture_id = f"_{ self .loop_scope } _scoped_runner"
453
+ runner_fixture_id = f"_{ self ._loop_scope } _scoped_runner"
469
454
runner = self ._request .getfixturevalue (runner_fixture_id )
470
455
context = contextvars .copy_context ()
471
456
synchronized_obj = _synchronize_coroutine (
@@ -475,6 +460,21 @@ def runtest(self) -> None:
475
460
c .setattr (* self ._synchronization_target_attr , synchronized_obj )
476
461
super ().runtest ()
477
462
463
+ @functools .cached_property
464
+ def _loop_scope (self ) -> _ScopeName :
465
+ """
466
+ Return the scope of the asyncio event loop this item is run in.
467
+
468
+ The effective scope is determined lazily. It is identical to to the
469
+ `loop_scope` value of the closest `asyncio` pytest marker. If no such
470
+ marker is present, the the loop scope is determined by the configuration
471
+ value of `asyncio_default_test_loop_scope`, instead.
472
+ """
473
+ marker = self .get_closest_marker ("asyncio" )
474
+ assert marker is not None
475
+ default_loop_scope = _get_default_test_loop_scope (self .config )
476
+ return _get_marked_loop_scope (marker , default_loop_scope )
477
+
478
478
@property
479
479
def _synchronization_target_attr (self ) -> tuple [object , str ]:
480
480
"""
0 commit comments