test(rust): align native OCR contract coverage

This commit is contained in:
Yujong Lee 2026-09-12 11:35:26 -07:00
parent 02e150c4a4
commit fa6bdf2e2c
2 changed files with 1 additions and 19 deletions

View file

@ -1,4 +1,3 @@
import sys
from typing import Final
import pytest
@ -17,23 +16,6 @@ def ocr_server(recording_server: RecordingServer) -> RecordingServer:
return recording_server
def test_native_ocr_rejects_disabled_gil_before_provider_call(
ocr_server: RecordingServer, monkeypatch: pytest.MonkeyPatch
) -> None:
ocr_server.expected_requests = 0
monkeypatch.setattr(sys, "_is_gil_enabled", lambda: False, raising=False)
with pytest.raises(RuntimeError, match="native OCR requires the Python GIL"):
litellm.ocr(
model=OCR_MODEL,
document=OCR_DOCUMENT,
api_key="test-key",
api_base=ocr_server.base_url,
)
assert not ocr_server.requests
@pytest.mark.parametrize("enabled", [False, True, None])
def test_public_ocr_uses_native_route_independently_of_flag(ocr_server: RecordingServer, enabled: bool | None) -> None:
litellm.rust(enabled)

View file

@ -224,7 +224,7 @@ def test_native_ocr_rejects_invalid_input_before_network(ocr_server, custom_prov
from litellm.rust_bridge import _native
server, requests = ocr_server
with pytest.raises(ValueError, match=r"invalid (OCR request field|provider)|invalid request"):
with pytest.raises(ValueError, match="Document URL is required"):
_native.ocr(
model="mistral-ocr-latest",
custom_llm_provider=custom_provider,