py-pdf / pypdf

A pure-python PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files

Home Page:https://pypdf.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing test annocations in 4.1.0

kitterma opened this issue · comments

Replace this: What happened? What were you trying to achieve?

Environment

Building and running tests in Debian.

$ python -m platform
Linux-6.1.0-18-amd64-x86_64-with-glibc2.37

$ python -c "import pypdf;print(pypdf._debug_versions)"
4.1.0

Code + PDF

This is a minimal, complete example that shows the issue:

N/A

In this release, get_data_from_url is missing enable_socket and tests/scripts/test_make_release.py fails since make_release.py is (correctly) not included in the release as it's only useful upstream. Patch for both issues provided below.

From: Scott Kitterman <scott@kitterman.com>
Date: Fri, 8 Mar 2024 00:25:05 -0500
Subject: Fix test exceptions

---
 tests/scripts/test_make_release.py | 8 +++++++-
 tests/test_generic.py              | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tests/scripts/test_make_release.py b/tests/scripts/test_make_release.py
index 51b5e5a..e1250fe 100644
--- a/tests/scripts/test_make_release.py
+++ b/tests/scripts/test_make_release.py
@@ -1,8 +1,12 @@
 """Test the `make_release.py` script."""
 from pathlib import Path
 from unittest import mock
+import pytest

-import make_release
+try:
+    import make_release
+except:
+    pass

 DATA_PATH = Path(__file__).parent.resolve() / "data"

@@ -17,6 +21,7 @@ f851a532a5ec23b572d86bd7185b327a3fac6b58:::DEV: Bump codecov/codecov-action from
 COMMITS__VERSION_4_0_1 = DATA_PATH.joinpath("commits__version_4_0_1.json")


+pytest.importorskip("make_release")
 def test_get_git_commits_since_tag():
     with open(COMMITS__VERSION_4_0_1, mode="rb") as commits, \
             mock.patch("urllib.request.urlopen", side_effect=lambda n: commits), \
@@ -61,6 +66,7 @@ def test_get_git_commits_since_tag():
     ]


+pytest.importorskip("make_release")
 def test_get_formatted_changes():
     with open(COMMITS__VERSION_4_0_1, mode="rb") as commits, \
             mock.patch("urllib.request.urlopen", side_effect=lambda n: commits), \
diff --git a/tests/test_generic.py b/tests/test_generic.py
index f77b018..f31a4f1 100644
--- a/tests/test_generic.py
+++ b/tests/test_generic.py
@@ -1247,6 +1247,7 @@ def test_encodedstream_set_data():
     assert cc[NameObject("/Test")] == "/MyTest"


+@pytest.mark.enable_socket()
 def test_calling_indirect_objects():
     """Cope with cases where attributes/items are called from indirectObject"""
     url = (

Thanks for the report. Do you want to submit a corresponding PR?

I have converted your patch into a corresponding PR for further inclusion into pypdf once this has been approved by one of the other maintainers.