style: use single import style for infra.local_converter in tests
Use `import infra.local_converter as lc_mod` consistently instead of mixing `import` and `from ... import` for the same module. Addresses CodeQL review comment on PR #58.
This commit is contained in:
parent
6177452de1
commit
f04e5369ef
1 changed files with 9 additions and 17 deletions
|
|
@ -165,15 +165,11 @@ docling = pytest.importorskip("docling", reason="docling library not installed")
|
||||||
|
|
||||||
from docling.datamodel.base_models import InputFormat # noqa: E402
|
from docling.datamodel.base_models import InputFormat # noqa: E402
|
||||||
|
|
||||||
from infra.local_converter import ( # noqa: E402
|
import infra.local_converter as lc_mod # noqa: E402
|
||||||
_build_docling_converter as build_converter,
|
|
||||||
)
|
build_converter = lc_mod._build_docling_converter
|
||||||
from infra.local_converter import ( # noqa: E402
|
convert_sync = lc_mod._convert_sync
|
||||||
_convert_sync as convert_sync,
|
get_default_converter = lc_mod._get_default_converter
|
||||||
)
|
|
||||||
from infra.local_converter import ( # noqa: E402
|
|
||||||
_get_default_converter as get_default_converter,
|
|
||||||
)
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# C1 — document_timeout in PdfPipelineOptions
|
# C1 — document_timeout in PdfPipelineOptions
|
||||||
|
|
@ -335,23 +331,19 @@ class TestGetDefaultConverterReset:
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def reset_default_converter(self):
|
def reset_default_converter(self):
|
||||||
import infra.local_converter as mod
|
original = lc_mod._default_converter
|
||||||
|
lc_mod._default_converter = None
|
||||||
original = mod._default_converter
|
|
||||||
mod._default_converter = None
|
|
||||||
yield
|
yield
|
||||||
mod._default_converter = original
|
lc_mod._default_converter = original
|
||||||
|
|
||||||
@patch("infra.local_converter._build_docling_converter")
|
@patch("infra.local_converter._build_docling_converter")
|
||||||
def test_init_failure_resets_to_none(self, mock_build):
|
def test_init_failure_resets_to_none(self, mock_build):
|
||||||
import infra.local_converter as mod
|
|
||||||
|
|
||||||
mock_build.side_effect = RuntimeError("torch not found")
|
mock_build.side_effect = RuntimeError("torch not found")
|
||||||
|
|
||||||
with pytest.raises(RuntimeError, match="torch not found"):
|
with pytest.raises(RuntimeError, match="torch not found"):
|
||||||
get_default_converter()
|
get_default_converter()
|
||||||
|
|
||||||
assert mod._default_converter is None
|
assert lc_mod._default_converter is None
|
||||||
|
|
||||||
@patch("infra.local_converter._build_docling_converter")
|
@patch("infra.local_converter._build_docling_converter")
|
||||||
def test_retry_after_failure_succeeds(self, mock_build):
|
def test_retry_after_failure_succeeds(self, mock_build):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue