Skip to content

Commit

Permalink
DEV: Fix test_update_offsets.py (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C authored Feb 7, 2025
1 parent 6b90a7d commit a36d1cf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
7 changes: 4 additions & 3 deletions make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ def get_formatted_changes(git_tag: str) -> Tuple[str, str]:
if grouped:
output += "\n### Other\n"
output_with_user += "\n### Other\n"
for prefix, commit_dict in grouped.items():
output += f"- {prefix}: {commit_dict['msg']}\n"
output_with_user += f"- {prefix}: {commit_dict['msg']} by @{commit_dict['author']}\n"
for prefix, commit_dicts in grouped.items():
for commit_dict in commit_dicts:
output += f"- {prefix}: {commit_dict['msg']}\n"
output_with_user += f"- {prefix}: {commit_dict['msg']} by @{commit_dict['author']}\n"

return output, output_with_user

Expand Down
4 changes: 3 additions & 1 deletion pdfly/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ def update_offsets(
resolve_path=True,
),
],
file_out: Path = typer.Option(..., "-o", "--output"), # noqa
file_out: Annotated[
Path, typer.Option("-o", "--output") # noqa
] = None, # type: ignore
encoding: str = typer.Option(
"ISO-8859-1",
help="Encoding used to read and write the files, e.g. UTF-8.",
Expand Down
Binary file modified resources/file-with-invalid-offsets.pdf
Binary file not shown.
11 changes: 4 additions & 7 deletions tests/test_update_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,25 @@

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

# Act
exit_code = run_cli(
[
"update-offsets",
str(input),
str(output),
]
)

# Assert
captured = capsys.readouterr()
assert exit_code == 0, captured
assert not captured.err
assert re.search(r"Wrote\s+" + re.escape(str(output)), captured.out)
assert output.exists()
assert re.search(r"Wrote\s+" + re.escape(str(input)), captured.out)
with open(file_expected, encoding="iso-8859-1") as file_exp:
lines_exp = file_exp.readlines()
with open(output, encoding="iso-8859-1") as file_act:
with input.open(encoding="iso-8859-1") as file_act:
lines_act = file_act.readlines()
assert len(lines_exp) == len(
lines_act
Expand Down Expand Up @@ -92,6 +88,7 @@ def test_update_offsets_on_all_reference_files(
"--encoding",
"iso-8859-1",
input_pdf_filepath,
"-o",
str(output_pdf_filepath),
]
)
Expand Down

0 comments on commit a36d1cf

Please sign in to comment.