File tree Expand file tree Collapse file tree 2 files changed +14
-14
lines changed
pytest_asyncio_cooperative Expand file tree Collapse file tree 2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change 11import asyncio
22import inspect
3- from typing import List , Union
4-
5- from _pytest .fixtures import (
6- FixtureDef ,
7- FixtureRequest ,
8- FuncFixtureInfo ,
9- resolve_fixture_function ,
10- )
3+ from typing import List
4+ from typing import Union
5+
6+ from _pytest .fixtures import FixtureDef
7+ from _pytest .fixtures import FixtureRequest
8+ from _pytest .fixtures import FuncFixtureInfo
9+ from _pytest .fixtures import resolve_fixture_function
1110from _pytest .nodes import Item
1211
1312
Original file line number Diff line number Diff line change 1- import threading
21import asyncio
32import collections .abc
43import functools
54import inspect
5+ import threading
66import time
77from sys import version_info as sys_version_info
88
99import pytest
10-
11- from _pytest .runner import call_and_report
12- from _pytest .skipping import Skip , evaluate_skip_marks
10+ from _pytest .skipping import Skip
11+ from _pytest .skipping import evaluate_skip_marks
1312
1413from .assertion import activate_assert_rewrite
1514from .fixtures import fill_fixtures
@@ -297,23 +296,25 @@ async def run_tests(tasks, max_tasks: int):
297296 def wrap_in_sync ():
298297 def sync_wrapper ():
299298 new_task = item_to_task (item )
300-
299+
301300 # We use a new thread because we can't block for an async function
302301 # in the same thread as the current running event loop, nor
303302 # we can nest event loops
304303 result = None
304+
305305 def run_in_thread ():
306306 nonlocal result
307307 try :
308308 result = asyncio .run (new_task )
309309 except Exception as e :
310310 result = e
311+
311312 thread = threading .Thread (target = run_in_thread )
312313 thread .start ()
313314 thread .join ()
314315
315316 if isinstance (result , Exception ):
316- raise result # type: ignore
317+ raise result # type: ignore
317318
318319 return result
319320
You can’t perform that action at this time.
0 commit comments