summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2024-01-30 16:07:24 +0100
committerMichał Górny <mgorny@gentoo.org>2024-01-30 17:35:57 +0100
commitbb8693a45074c0e4b72b9b3f9b697299e855f071 (patch)
tree733a254bcdee3349b44fdc62a1f410203ebd40cf
parentdev-python/trio: Backport a musl fix (diff)
downloadgentoo-bb8693a45074c0e4b72b9b3f9b697299e855f071.tar.gz
gentoo-bb8693a45074c0e4b72b9b3f9b697299e855f071.tar.bz2
gentoo-bb8693a45074c0e4b72b9b3f9b697299e855f071.zip
dev-python/pypdf: Backport pytest-8 test fixes
Closes: https://bugs.gentoo.org/923251 Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--dev-python/pypdf/files/pypdf-4.0.1-pytest-8.patch80
-rw-r--r--dev-python/pypdf/pypdf-4.0.1.ebuild19
2 files changed, 92 insertions, 7 deletions
diff --git a/dev-python/pypdf/files/pypdf-4.0.1-pytest-8.patch b/dev-python/pypdf/files/pypdf-4.0.1-pytest-8.patch
new file mode 100644
index 000000000000..16b685970b55
--- /dev/null
+++ b/dev-python/pypdf/files/pypdf-4.0.1-pytest-8.patch
@@ -0,0 +1,80 @@
+From 7fd67692faf502663c001b38e48083c68876085b Mon Sep 17 00:00:00 2001
+From: Stefan <96178532+stefan6419846@users.noreply.github.com>
+Date: Mon, 29 Jan 2024 15:43:52 +0100
+Subject: [PATCH 1/2] TST: Avoid catching not emitted warnings
+
+---
+ tests/test_reader.py | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/tests/test_reader.py b/tests/test_reader.py
+index 98f73a01c..ad289c296 100644
+--- a/tests/test_reader.py
++++ b/tests/test_reader.py
+@@ -335,7 +335,7 @@ def test_get_images_raw(
+ )
+ pdf_stream = io.BytesIO(pdf_data)
+ if should_fail:
+- with pytest.raises(PdfReadError) as exc, pytest.warns(PdfReadWarning):
++ with pytest.raises(PdfReadError) as exc:
+ PdfReader(pdf_stream, strict=strict)
+ assert exc.type == PdfReadError
+ if startx_correction == -1:
+@@ -530,7 +530,7 @@ def test_read_prev_0_trailer():
+ pdf_data.find(b"xref") - 1,
+ )
+ pdf_stream = io.BytesIO(pdf_data)
+- with pytest.raises(PdfReadError) as exc, pytest.warns(PdfReadWarning):
++ with pytest.raises(PdfReadError) as exc:
+ PdfReader(pdf_stream, strict=True)
+ assert exc.value.args[0] == "/Prev=0 in the trailer (try opening with strict=False)"
+
+@@ -607,7 +607,7 @@ def test_read_unknown_zero_pages(caplog):
+ "Xref table not zero-indexed. ID numbers for objects will be corrected.",
+ ]
+ assert normalize_warnings(caplog.text) == warnings
+- with pytest.raises(PdfReadError) as exc, pytest.warns(PdfReadWarning):
++ with pytest.raises(PdfReadError) as exc:
+ len(reader.pages)
+
+ assert exc.value.args[0] == "Could not find object."
+@@ -617,7 +617,7 @@ def test_read_unknown_zero_pages(caplog):
+ "startxref on same line as offset",
+ ]
+ assert normalize_warnings(caplog.text) == warnings
+- with pytest.raises(AttributeError) as exc, pytest.warns(PdfReadWarning):
++ with pytest.raises(AttributeError) as exc:
+ len(reader.pages)
+ assert exc.value.args[0] == "'NoneType' object has no attribute 'get_object'"
+
+@@ -687,7 +687,7 @@ def test_issue604(caplog, strict):
+ outline = None
+ if strict:
+ pdf = PdfReader(f, strict=strict)
+- with pytest.raises(PdfReadError) as exc, pytest.warns(PdfReadWarning):
++ with pytest.raises(PdfReadError) as exc:
+ outline = pdf.outline
+ if "Unknown Destination" not in exc.value.args[0]:
+ raise Exception("Expected exception not raised")
+
+From 259128c25e25e23f284267d0abb9d7f1bd932de5 Mon Sep 17 00:00:00 2001
+From: Stefan <96178532+stefan6419846@users.noreply.github.com>
+Date: Mon, 29 Jan 2024 15:46:34 +0100
+Subject: [PATCH 2/2] remove now unused import
+
+---
+ tests/test_reader.py | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/tests/test_reader.py b/tests/test_reader.py
+index ad289c296..c9c6be9b3 100644
+--- a/tests/test_reader.py
++++ b/tests/test_reader.py
+@@ -17,7 +17,6 @@
+ EmptyFileError,
+ FileNotDecryptedError,
+ PdfReadError,
+- PdfReadWarning,
+ WrongPasswordError,
+ )
+ from pypdf.generic import (
diff --git a/dev-python/pypdf/pypdf-4.0.1.ebuild b/dev-python/pypdf/pypdf-4.0.1.ebuild
index 3035c819ee29..766a25f1da60 100644
--- a/dev-python/pypdf/pypdf-4.0.1.ebuild
+++ b/dev-python/pypdf/pypdf-4.0.1.ebuild
@@ -37,13 +37,9 @@ BDEPEND="
distutils_enable_tests pytest
-EPYTEST_DESELECT=(
- tests/test_reader.py::test_decode_permissions
- tests/test_workflows.py::test_text_extraction_layout_mode
- # rely on -Werror
- tests/test_utils.py::test_deprecate_no_replacement
- tests/test_workflows.py::test_orientations
- tests/test_writer.py::test_remove_image_per_type
+PATCHES=(
+ # https://github.com/py-pdf/pypdf/pull/2429
+ "${FILESDIR}/${P}-pytest-8.patch"
)
src_unpack() {
@@ -54,6 +50,15 @@ src_unpack() {
}
python_test() {
+ local EPYTEST_DESELECT=(
+ tests/test_reader.py::test_decode_permissions
+ tests/test_workflows.py::test_text_extraction_layout_mode
+ # rely on -Werror
+ tests/test_utils.py::test_deprecate_no_replacement
+ tests/test_workflows.py::test_orientations
+ tests/test_writer.py::test_remove_image_per_type
+ )
+
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
epytest -o addopts= -m "not enable_socket"
}