14
14
15
15
16
16
import inspect
17
+ from asyncio import run_coroutine_threadsafe
17
18
from typing import Any , Callable , Mapping , Optional
18
19
from unittest .mock import AsyncMock , Mock , patch
19
- from asyncio import run_coroutine_threadsafe
20
20
21
21
import pytest
22
22
from aioresponses import CallbackResult , aioresponses
28
28
29
29
TEST_BASE_URL = "http://toolbox.example.com"
30
30
31
- # The original `ToolboxSyncClient.close()` is a blocking method because it
32
- # calls `.result()`. In the pytest environment, this blocking call creates a
33
- # deadlock during the test teardown phase when it conflicts with the
34
- # `sync_client_environment` fixture that also manages the background thread.
35
- #
36
- # By replacing `close` with our non-blocking version for the test run,
37
- # we prevent this deadlock and allow the test suite to tear down cleanly.
31
+
32
+ # The original `ToolboxSyncClient.close()` is a blocking method because it
33
+ # calls `.result()`. In the pytest environment, this blocking call creates a
34
+ # deadlock during the test teardown phase when it conflicts with the
35
+ # `sync_client_environment` fixture that also manages the background thread.
36
+ #
37
+ # By replacing `close` with our non-blocking version for the test run,
38
+ # we prevent this deadlock and allow the test suite to tear down cleanly.
38
39
@pytest .fixture (autouse = True )
39
40
def patch_sync_client_for_deadlock (monkeypatch ):
40
41
"""
@@ -52,6 +53,7 @@ def non_blocking_close(self):
52
53
53
54
monkeypatch .setattr (ToolboxSyncClient , "close" , non_blocking_close )
54
55
56
+
55
57
@pytest .fixture
56
58
def sync_client_environment ():
57
59
"""
0 commit comments