Skip to content

Commit

Permalink
TST: Skip tests using fpdf2 if it's not installed (#2419)
Browse files Browse the repository at this point in the history
The Debian ecosystem installs only packages which are also present
in the Debian ecosystem for testing. This includes pytest, but it
does not include fpdf2.

Adding the line 'pytest.importorskip("fpdf")' within the test
and before the import ensures that pytest skips the test in
case fpdf is not installed.

Closes #2408
  • Loading branch information
MartinThoma authored Jan 21, 2024
1 parent 9e494c6 commit 54ae0a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ def test_compression():
"""Test for issue #1897"""

def create_stamp_pdf() -> BytesIO:
pytest.importorskip("fpdf")
from fpdf import FPDF

pdf = FPDF()
Expand Down
1 change: 1 addition & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,7 @@ def _get_parent_bookmark(current_indent, history_indent, bookmarks) -> Any:

def test_merging_many_temporary_files():
def create_number_pdf(n) -> BytesIO:
pytest.importorskip("fpdf")
from fpdf import FPDF

pdf = FPDF()
Expand Down

0 comments on commit 54ae0a6

Please sign in to comment.