Skip to content

Commit 3af6415

Browse files
committed
Fix test_uvloop.py fixture resetting flags that shouldn't be reset
1 parent daa7fb7 commit 3af6415

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/test_uvloop.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
pytest.skip("uvloop not supported on Windows", allow_module_level=True)
2424

2525
import aiocop # noqa: E402
26-
from aiocop.core import audit_patcher, blocking_io, slow_tasks, state # noqa: E402
26+
from aiocop.core import slow_tasks, state # noqa: E402
2727
from aiocop.types.events import SlowTaskEvent # noqa: E402
2828

2929
# =============================================================================
@@ -37,13 +37,17 @@ def reset_aiocop_state():
3737
3838
This is critical for uvloop tests since we need fresh state
3939
for each test to properly test loop patching.
40+
41+
Note: _detect_slow_tasks_configured is reset since it gates a fresh event
42+
loop object created every test. _patch_audit_functions_configured and
43+
_start_blocking_io_detection_configured are NOT reset - they guard
44+
permanent, process-wide state with no teardown, so resetting them would
45+
re-wrap functions and re-register the audit hook each test.
4046
"""
4147
# Reset before test
4248
state._monitoring_active = False
4349
state._on_activate_hooks.clear()
4450
slow_tasks._detect_slow_tasks_configured = False
45-
audit_patcher._patch_audit_functions_configured = False
46-
blocking_io._start_blocking_io_detection_configured = False
4751
aiocop.clear_slow_task_callbacks()
4852
aiocop.clear_context_providers()
4953

@@ -53,8 +57,6 @@ def reset_aiocop_state():
5357
state._monitoring_active = False
5458
state._on_activate_hooks.clear()
5559
slow_tasks._detect_slow_tasks_configured = False
56-
audit_patcher._patch_audit_functions_configured = False
57-
blocking_io._start_blocking_io_detection_configured = False
5860
aiocop.clear_slow_task_callbacks()
5961
aiocop.clear_context_providers()
6062

0 commit comments

Comments
 (0)