Skip to content

Commit

Permalink
add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
kotaro-kinoshita committed Jan 3, 2025
1 parent 7018416 commit 07f4da8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/yomitoku/export/export_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def save_figure(
out_path,
figure_dir="figures",
):
assert img is not None, "img is required for saving figures"

for i, figure in enumerate(figures):
x1, y1, x2, y2 = map(int, figure.box)
figure_img = img[y1:y2, x1:x2, :]
Expand Down
2 changes: 2 additions & 0 deletions src/yomitoku/export/export_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def figure_to_html(
figure_dir="figures",
width=200,
):
assert img is not None, "img is required for saving figures"

elements = []
for i, figure in enumerate(figures):
x1, y1, x2, y2 = map(int, figure.box)
Expand Down
2 changes: 2 additions & 0 deletions src/yomitoku/export/export_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def save_figure(
out_path,
figure_dir="figures",
):
assert img is not None, "img is required for saving figures"

for i, figure in enumerate(figures):
x1, y1, x2, y2 = map(int, figure.box)
figure_img = img[y1:y2, x1:x2, :]
Expand Down
2 changes: 2 additions & 0 deletions src/yomitoku/export/export_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def figure_to_md(
width=200,
figure_dir="figures",
):
assert img is not None, "img is required for saving figures"

elements = []
for i, figure in enumerate(figures):
x1, y1, x2, y2 = map(int, figure.box)
Expand Down
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def test_validate_encoding():
validate_encoding("utf-9")

assert validate_encoding("utf-8")
assert validate_encoding("utf-8-sig")
assert validate_encoding("shift-jis")
assert validate_encoding("euc-jp")
assert validate_encoding("cp932")

0 comments on commit 07f4da8

Please sign in to comment.