Skip to content

Commit f626c04

Browse files
committed
pyyamlインポートチェックの修正
1 parent de8f454 commit f626c04

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

tests/test_cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import xlwings as xw
88
from openpyxl import Workbook
9+
from importlib import util
910

1011

1112
def _excel_available() -> bool:
@@ -75,8 +76,13 @@ def test_CLIでyamlやtoon指定は未サポート(tmp_path: Path) -> None:
7576
out_yaml = tmp_path / "out.yaml"
7677
cmd = [sys.executable, "-m", "exstruct.cli.main", str(xlsx), "-o", str(out_yaml), "-f", "yaml"]
7778
result = subprocess.run(cmd, capture_output=True, text=True)
78-
assert result.returncode == 0
79-
assert out_yaml.exists()
79+
if util.find_spec("yaml") is not None:
80+
assert result.returncode == 0
81+
assert out_yaml.exists()
82+
else:
83+
assert result.returncode != 0
84+
assert "pyyaml" in result.stdout or "pyyaml" in result.stderr
85+
8086
out_toon = tmp_path / "out.toon"
8187
cmd = [sys.executable, "-m", "exstruct.cli.main", str(xlsx), "-o", str(out_toon), "-f", "toon"]
8288
result = subprocess.run(cmd, capture_output=True, text=True)

0 commit comments

Comments
 (0)