-
Notifications
You must be signed in to change notification settings - Fork 50
ENH: Add --format Option for Custom Page Sizes in x2pdf Command
#65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
fcf7aa2
92a2c93
7eab975
3108e70
aca5206
bf50183
9fcb11a
5d7d5ab
0cb1d6e
ecda603
c724c84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,23 +9,42 @@ | |
| from .conftest import run_cli | ||
|
|
||
|
|
||
| def test_x2pdf(capsys, tmp_path: Path) -> None: | ||
|
Lucas-C marked this conversation as resolved.
|
||
| def test_x2pdf_with_format(capsys, tmp_path: Path) -> None: | ||
| # Arrange | ||
| output = tmp_path / "out.pdf" | ||
| assert not output.exists() | ||
|
|
||
| formats_to_test = [ | ||
| "Letter", | ||
| "A4-portrait", | ||
| "A4-landscape", | ||
| "210x297", | ||
| "invalid-format" | ||
| ] | ||
|
|
||
| for format_option in formats_to_test: | ||
| # Act | ||
| exit_code = run_cli( | ||
| [ | ||
| "x2pdf", | ||
| "sample-files/003-pdflatex-image/page-0-Im1.jpg", | ||
|
Lucas-C marked this conversation as resolved.
|
||
| "--output", | ||
| str(output), | ||
| "--format", | ||
| format_option, | ||
| ] | ||
| ) | ||
|
|
||
| # Act | ||
| exit_code = run_cli( | ||
| [ | ||
| "x2pdf", | ||
| "sample-files/003-pdflatex-image/page-0-Im1.jpg", | ||
| "--output", | ||
| str(output), | ||
| ] | ||
| ) | ||
|
|
||
| # Assert | ||
| captured = capsys.readouterr() | ||
| assert exit_code == 0, captured | ||
| assert captured.out == "" | ||
| assert output.exists() | ||
| # Assert | ||
| captured = capsys.readouterr() | ||
|
|
||
| # For valid formats, we expect a successful exit code and the output file to exist | ||
| if format_option != "invalid-format": | ||
| assert exit_code == 0, captured | ||
| assert captured.out == "" | ||
| assert output.exists() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be interesting to also validate the resulting pages dimensions. This can be checked with Or using the underlying
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you did not handle that feedback comment @mulla028 🙂 |
||
| else: | ||
| # For an invalid format, we expect a non-zero exit code (indicating failure) | ||
| assert exit_code != 0 | ||
| assert "Invalid format" in captured.err # Check for expected error message | ||
| output.unlink(missing_ok=True) # Clean up for the next test iteration | ||
Uh oh!
There was an error while loading. Please reload this page.