MCPcopy Index your code
hub / github.com/idank/explainshell / _make_mock_extractor

Function _make_mock_extractor

tests/extraction/llm/test_extractor.py:29–53  ·  view source on GitHub ↗

Build an LLMExtractor whose provider is a MagicMock. Patching make_provider sidesteps eager client construction (e.g. OpenAIProvider's OpenAI() call which now fails when credentials are missing — irrelevant for these tests). retryable_exceptions is set so _call_llm's `except retrya

(
    model: str = "openai/test-model",
    run_dir: str | None = None,
    debug: bool = False,
)

Source from the content-addressed store, hash-verified

27
28
29def _make_mock_extractor(
30 model: str = "openai/test-model",
31 run_dir: str | None = None,
32 debug: bool = False,
33) -> LLMExtractor:
34 """Build an LLMExtractor whose provider is a MagicMock.
35
36 Patching make_provider sidesteps eager client construction (e.g.
37 OpenAIProvider's OpenAI() call which now fails when credentials are
38 missing — irrelevant for these tests). retryable_exceptions is set
39 so _call_llm's `except retryable as e:` clause type-checks.
40 """
41 cfg = ExtractorConfig(model=model, run_dir=run_dir, debug=debug)
42 provider = MagicMock(retryable_exceptions=(ConnectionError,))
43 with (
44 patch(
45 "explainshell.extraction.llm.extractor.make_provider",
46 return_value=provider,
47 ),
48 patch(
49 "explainshell.extraction.llm.extractor.make_batch_provider",
50 return_value=MagicMock(),
51 ),
52 ):
53 return LLMExtractor(cfg)
54
55
56class TestExtractIntegration(unittest.TestCase):

Callers 3

_make_extractorMethod · 0.85
_make_extractorMethod · 0.85
_make_extractorMethod · 0.85

Calls 2

ExtractorConfigClass · 0.90
LLMExtractorClass · 0.90

Tested by

no test coverage detected