Skip to content

Commit a36d1cf

Browse files
authored
DEV: Fix test_update_offsets.py (#100)
1 parent 6b90a7d commit a36d1cf

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

make_release.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ def get_formatted_changes(git_tag: str) -> Tuple[str, str]:
259259
if grouped:
260260
output += "\n### Other\n"
261261
output_with_user += "\n### Other\n"
262-
for prefix, commit_dict in grouped.items():
263-
output += f"- {prefix}: {commit_dict['msg']}\n"
264-
output_with_user += f"- {prefix}: {commit_dict['msg']} by @{commit_dict['author']}\n"
262+
for prefix, commit_dicts in grouped.items():
263+
for commit_dict in commit_dicts:
264+
output += f"- {prefix}: {commit_dict['msg']}\n"
265+
output_with_user += f"- {prefix}: {commit_dict['msg']} by @{commit_dict['author']}\n"
265266

266267
return output, output_with_user
267268

pdfly/cli.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ def update_offsets(
283283
resolve_path=True,
284284
),
285285
],
286-
file_out: Path = typer.Option(..., "-o", "--output"), # noqa
286+
file_out: Annotated[
287+
Path, typer.Option("-o", "--output") # noqa
288+
] = None, # type: ignore
287289
encoding: str = typer.Option(
288290
"ISO-8859-1",
289291
help="Encoding used to read and write the files, e.g. UTF-8.",
-3 Bytes
Binary file not shown.

tests/test_update_offsets.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,25 @@
1414

1515
def test_update_offsets(capsys, tmp_path: Path) -> None:
1616
# Arrange
17-
input = str(RESOURCES_ROOT / "file-with-invalid-offsets.pdf")
17+
input = RESOURCES_ROOT / "file-with-invalid-offsets.pdf"
1818
file_expected = str(RESOURCES_ROOT / "file-with-fixed-offsets.pdf")
19-
output = tmp_path / "file-with-offsets-out.pdf"
20-
assert not output.exists()
2119

2220
# Act
2321
exit_code = run_cli(
2422
[
2523
"update-offsets",
2624
str(input),
27-
str(output),
2825
]
2926
)
3027

3128
# Assert
3229
captured = capsys.readouterr()
3330
assert exit_code == 0, captured
3431
assert not captured.err
35-
assert re.search(r"Wrote\s+" + re.escape(str(output)), captured.out)
36-
assert output.exists()
32+
assert re.search(r"Wrote\s+" + re.escape(str(input)), captured.out)
3733
with open(file_expected, encoding="iso-8859-1") as file_exp:
3834
lines_exp = file_exp.readlines()
39-
with open(output, encoding="iso-8859-1") as file_act:
35+
with input.open(encoding="iso-8859-1") as file_act:
4036
lines_act = file_act.readlines()
4137
assert len(lines_exp) == len(
4238
lines_act
@@ -92,6 +88,7 @@ def test_update_offsets_on_all_reference_files(
9288
"--encoding",
9389
"iso-8859-1",
9490
input_pdf_filepath,
91+
"-o",
9592
str(output_pdf_filepath),
9693
]
9794
)

0 commit comments

Comments
 (0)