From 3b7fe3f06c03414a17d063cf73cc3502bf947355 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 21 Jan 2024 11:50:47 +0100 Subject: [PATCH] TST: Skip tests using fpdf2 if it's not installed 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 --- tests/test_page.py | 1 + tests/test_writer.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/test_page.py b/tests/test_page.py index 84774dbf2..a5e5725b9 100644 --- a/tests/test_page.py +++ b/tests/test_page.py @@ -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() diff --git a/tests/test_writer.py b/tests/test_writer.py index 494fa08cd..74bd1dd52 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -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()