fix(test): reset _cached_backend before factory dispatch tests
This commit is contained in:
@@ -15,18 +15,21 @@ from decnet.realism.llm.impl.ollama import OllamaBackend
|
|||||||
|
|
||||||
def test_factory_default_is_ollama(monkeypatch):
|
def test_factory_default_is_ollama(monkeypatch):
|
||||||
monkeypatch.delenv("DECNET_REALISM_LLM", raising=False)
|
monkeypatch.delenv("DECNET_REALISM_LLM", raising=False)
|
||||||
|
monkeypatch.setattr("decnet.realism.llm.config._cached_backend", None)
|
||||||
backend = get_llm()
|
backend = get_llm()
|
||||||
assert isinstance(backend, OllamaBackend)
|
assert isinstance(backend, OllamaBackend)
|
||||||
|
|
||||||
|
|
||||||
def test_factory_selects_fake(monkeypatch):
|
def test_factory_selects_fake(monkeypatch):
|
||||||
monkeypatch.setenv("DECNET_REALISM_LLM", "fake")
|
monkeypatch.setenv("DECNET_REALISM_LLM", "fake")
|
||||||
|
monkeypatch.setattr("decnet.realism.llm.config._cached_backend", None)
|
||||||
backend = get_llm()
|
backend = get_llm()
|
||||||
assert isinstance(backend, FakeBackend)
|
assert isinstance(backend, FakeBackend)
|
||||||
|
|
||||||
|
|
||||||
def test_factory_unknown_raises(monkeypatch):
|
def test_factory_unknown_raises(monkeypatch):
|
||||||
monkeypatch.setenv("DECNET_REALISM_LLM", "vllm-someday")
|
monkeypatch.setenv("DECNET_REALISM_LLM", "vllm-someday")
|
||||||
|
monkeypatch.setattr("decnet.realism.llm.config._cached_backend", None)
|
||||||
with pytest.raises(ValueError, match="Unsupported"):
|
with pytest.raises(ValueError, match="Unsupported"):
|
||||||
get_llm()
|
get_llm()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user