From 5522d8729ed1448689557050f44789ec3f66e3ae Mon Sep 17 00:00:00 2001 From: Scott Kitterman Date: Mon, 15 Jan 2024 11:10:35 -0500 Subject: [PATCH 1/3] Fix missing pytest.mark.samples (#2407) --- tests/test_encryption.py | 1 + tests/test_images.py | 3 +++ tests/test_reader.py | 2 ++ tests/test_text_extraction.py | 1 + 4 files changed, 7 insertions(+) diff --git a/tests/test_encryption.py b/tests/test_encryption.py index cb2d1f719..f15e072fa 100644 --- a/tests/test_encryption.py +++ b/tests/test_encryption.py @@ -344,6 +344,7 @@ def test_aes_decrypt_corrupted_data(): aes.decrypt(secrets.token_bytes(num)) +@pytest.mark.samples() def test_encrypt_stream_dictionary(pdf_file_path): user_password = secrets.token_urlsafe(10) diff --git a/tests/test_images.py b/tests/test_images.py index 3e9e8a034..b256efe9f 100644 --- a/tests/test_images.py +++ b/tests/test_images.py @@ -73,18 +73,21 @@ def image_similarity( return 1 - mse +@pytest.mark.samples() def test_image_similarity_one(): path_a = SAMPLE_ROOT / "018-base64-image/page-0-QuickPDFImd32aa1ab.png" path_b = path_a assert image_similarity(path_a, path_b) == 1 +@pytest.mark.samples() def test_image_similarity_zero(): path_a = SAMPLE_ROOT / "018-base64-image/page-0-QuickPDFImd32aa1ab.png" path_b = SAMPLE_ROOT / "009-pdflatex-geotopo/page-23-Im2.png" assert image_similarity(path_a, path_b) == 0 +@pytest.mark.samples() def test_image_similarity_mid(): path_a = SAMPLE_ROOT / "018-base64-image/page-0-QuickPDFImd32aa1ab.png" img_b = Image.open(path_a) diff --git a/tests/test_reader.py b/tests/test_reader.py index ab4a8d302..f2b8203b4 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -248,6 +248,7 @@ def test_get_images(src, expected_images): pass +@pytest.mark.samples() @pytest.mark.parametrize( ("strict", "with_prev_0", "startx_correction", "should_fail", "warning_msgs"), [ @@ -675,6 +676,7 @@ def test_reader_properties(): assert reader.is_encrypted is False +@pytest.mark.samples() @pytest.mark.parametrize( "strict", [True, False], diff --git a/tests/test_text_extraction.py b/tests/test_text_extraction.py index 58f174f22..1ffa68a3e 100644 --- a/tests/test_text_extraction.py +++ b/tests/test_text_extraction.py @@ -19,6 +19,7 @@ SAMPLE_ROOT = PROJECT_ROOT / "sample-files" +@pytest.mark.samples() @pytest.mark.parametrize(("visitor_text"), [None, lambda a, b, c, d, e: None]) def test_multi_language(visitor_text): reader = PdfReader(RESOURCE_ROOT / "multilang.pdf") From eef8f2cd4e3c0ee36ac9bec9a83cb7d35b3bc863 Mon Sep 17 00:00:00 2001 From: Scott Kitterman Date: Mon, 15 Jan 2024 11:11:52 -0500 Subject: [PATCH 2/3] Skip test if fpdf is not available (#2408) --- tests/test_writer.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_writer.py b/tests/test_writer.py index 494fa08cd..08f83dbb4 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -1949,6 +1949,7 @@ def _get_parent_bookmark(current_indent, history_indent, bookmarks) -> Any: bookmarks.append(new_bookmark) +pytest.importorskip("fpdf") def test_merging_many_temporary_files(): def create_number_pdf(n) -> BytesIO: from fpdf import FPDF From 091c2cc8a3b007a28d077853a9b087d620956ad4 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Wed, 17 Jan 2024 23:00:41 +0100 Subject: [PATCH 3/3] Remove lines which are unclear --- tests/test_reader.py | 2 -- tests/test_writer.py | 1 - 2 files changed, 3 deletions(-) diff --git a/tests/test_reader.py b/tests/test_reader.py index f2b8203b4..ab4a8d302 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -248,7 +248,6 @@ def test_get_images(src, expected_images): pass -@pytest.mark.samples() @pytest.mark.parametrize( ("strict", "with_prev_0", "startx_correction", "should_fail", "warning_msgs"), [ @@ -676,7 +675,6 @@ def test_reader_properties(): assert reader.is_encrypted is False -@pytest.mark.samples() @pytest.mark.parametrize( "strict", [True, False], diff --git a/tests/test_writer.py b/tests/test_writer.py index 08f83dbb4..494fa08cd 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -1949,7 +1949,6 @@ def _get_parent_bookmark(current_indent, history_indent, bookmarks) -> Any: bookmarks.append(new_bookmark) -pytest.importorskip("fpdf") def test_merging_many_temporary_files(): def create_number_pdf(n) -> BytesIO: from fpdf import FPDF