File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 38
38
FixtureRequest ,
39
39
Function ,
40
40
Item ,
41
+ Mark ,
41
42
Metafunc ,
42
43
Module ,
43
44
Package ,
@@ -738,7 +739,7 @@ def pytest_generate_tests(metafunc: Metafunc) -> None:
738
739
marker = metafunc .definition .get_closest_marker ("asyncio" )
739
740
if not marker :
740
741
return
741
- scope = marker . kwargs . get ( "scope" , "function" )
742
+ scope = _get_marked_loop_scope ( marker )
742
743
if scope == "function" :
743
744
return
744
745
event_loop_node = _retrieve_scope_root (metafunc .definition , scope )
@@ -971,7 +972,7 @@ def pytest_runtest_setup(item: pytest.Item) -> None:
971
972
marker = item .get_closest_marker ("asyncio" )
972
973
if marker is None :
973
974
return
974
- scope = marker . kwargs . get ( "scope" , "function" )
975
+ scope = _get_marked_loop_scope ( marker )
975
976
if scope != "function" :
976
977
parent_node = _retrieve_scope_root (item , scope )
977
978
event_loop_fixture_id = parent_node .stash [_event_loop_fixture_id ]
@@ -990,6 +991,11 @@ def pytest_runtest_setup(item: pytest.Item) -> None:
990
991
)
991
992
992
993
994
+ def _get_marked_loop_scope (asyncio_marker : Mark ) -> _ScopeName :
995
+ assert asyncio_marker .name == "asyncio"
996
+ return asyncio_marker .kwargs .get ("scope" , "function" )
997
+
998
+
993
999
def _retrieve_scope_root (item : Union [Collector , Item ], scope : str ) -> Collector :
994
1000
node_type_by_scope = {
995
1001
"class" : Class ,
You can’t perform that action at this time.
0 commit comments