Skip to content

Commit de92f11

Browse files
committed
OON 依存欠如時に MissingDependencyError も許容するよう変更(従来の RuntimeError 互換)。
1 parent 6871d47 commit de92f11

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

tests/test_cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
from collections.abc import Callable
12
from importlib import util
23
from pathlib import Path
34
import subprocess
45
import sys
6+
from typing import TypeVar, cast
57

68
from openpyxl import Workbook
79
import pytest
810

11+
F = TypeVar("F", bound=Callable[..., object])
12+
render = cast(Callable[[F], F], pytest.mark.render)
13+
914

1015
def _toon_available() -> bool:
1116
try:
@@ -108,7 +113,7 @@ def test_CLIでyamlやtoon指定は未サポート(tmp_path: Path) -> None:
108113
assert "TOON export requires python-toon" in result.stdout
109114

110115

111-
@pytest.mark.render # type: ignore[misc]
116+
@render
112117
def test_CLIでpdfと画像が出力される(tmp_path: Path) -> None:
113118
xlsx = _prepare_sample_excel(tmp_path)
114119
out_json = tmp_path / "out.json"

tests/test_models_export.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import pytest
55

6+
from exstruct.errors import MissingDependencyError
67
from exstruct.models import CellRow, SheetData, WorkbookData
78

89
HAS_PYYAML = util.find_spec("yaml") is not None
@@ -58,15 +59,16 @@ def test_save_unsupported_format_raises(tmp_path: Path) -> None:
5859
wb.save(bad)
5960

6061

61-
@pytest.mark.skipif(not HAS_PYYAML, reason="pyyaml not installed")
62+
# pytest.skipif is typed; no ignore needed
63+
@pytest.mark.skipif(not HAS_PYYAML, reason="pyyaml not installed") # type: ignore[misc]
6264
def test_sheet_to_yaml_roundtrip() -> None:
6365
sheet = _sheet()
6466
text = sheet.to_yaml()
6567
assert "table_candidates" in text
6668
assert "SheetData" not in text # not a repr
6769

6870

69-
@pytest.mark.skipif(not HAS_PYYAML, reason="pyyaml not installed")
71+
@pytest.mark.skipif(not HAS_PYYAML, reason="pyyaml not installed") # type: ignore[misc]
7072
def test_workbook_to_yaml() -> None:
7173
wb = _workbook()
7274
text = wb.to_yaml()
@@ -79,7 +81,7 @@ def test_sheet_to_toon_dependency() -> None:
7981
text = sheet.to_toon()
8082
assert isinstance(text, str) and text
8183
else:
82-
with pytest.raises(RuntimeError):
84+
with pytest.raises((RuntimeError, MissingDependencyError)):
8385
sheet.to_toon()
8486

8587

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)