From 21a8f52893ca9f99a81f6c31f74bcc5ef64d16c7 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 22 Jun 2026 14:09:01 -0400 Subject: [PATCH] Use patch.object to satisfy type checker --- tests/test_chunker.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_chunker.py b/tests/test_chunker.py index 3debf339..192bc0f9 100644 --- a/tests/test_chunker.py +++ b/tests/test_chunker.py @@ -59,6 +59,7 @@ async def test_local_chunker(qa_corpus: list[dict[str, str]]): async def test_local_chunker_runs_off_event_loop_thread(): """Chunking is CPU-bound; verify it runs in a worker thread.""" import threading + from unittest.mock import patch chunker = DoclingLocalChunker() event_loop_thread = threading.current_thread() @@ -66,15 +67,15 @@ async def test_local_chunker_runs_off_event_loop_thread(): original = chunker._chunk_sync - def recording_chunk_sync(document): + def recording_chunk_sync(self, document): called_from.append(threading.current_thread()) return original(document) - chunker._chunk_sync = recording_chunk_sync - converter = get_converter(Config) doc = await converter.convert_text("# Hello\n\nWorld", name="test.md") - await chunker.chunk(doc) + + with patch.object(DoclingLocalChunker, "_chunk_sync", recording_chunk_sync): + await chunker.chunk(doc) assert called_from, "_chunk_sync was never called" assert called_from[0] is not event_loop_thread, (