Skip to content

Commit 0699e9d

Browse files
committed
Isolate thread logging regressions from application logging setup
1 parent 1473a6f commit 0699e9d

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎test/controller/test_thread_pool.py‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,21 @@
3939
import pytest
4040

4141
from navigate.controller.thread_pool import SelfLockThread, SynchronizedThreadPool
42+
from navigate.controller import thread_pool
4243

4344

4445
@pytest.mark.parametrize("pooled", [False, True])
45-
def test_thread_exceptions_preserve_traceback_and_format_for_queue(caplog, pooled):
46+
def test_thread_exceptions_preserve_traceback_and_format_for_queue(
47+
caplog, monkeypatch, pooled
48+
):
4649
def fail(**kwargs):
4750
raise ZeroDivisionError("invalid acquisition total")
4851

49-
logger = logging.getLogger("controller")
52+
# Controller integration tests configure non-propagating application loggers.
53+
# Use real logging handlers without depending on that global configuration.
54+
logger = logging.Logger("thread-pool-test", level=logging.ERROR)
55+
monkeypatch.setattr(thread_pool, "logger", logger)
56+
logger.addHandler(caplog.handler)
5057
queue = SimpleQueue()
5158
handler = QueueHandler(queue)
5259
logger.addHandler(handler)
@@ -60,10 +67,9 @@ def fail(**kwargs):
6067
)
6168
thread = SelfLockThread(target=target, name="camera", kwargs={})
6269
try:
63-
with caplog.at_level(logging.ERROR, logger="controller"):
64-
thread.start()
65-
thread.join(timeout=2)
66-
assert not thread.is_alive()
70+
thread.start()
71+
thread.join(timeout=2)
72+
assert not thread.is_alive()
6773
finally:
6874
logger.removeHandler(handler)
6975
handler.close()

0 commit comments

Comments
 (0)