From 41ebe191d8cc007695a8dff535d3a289f4037a10fee34a496a39d13d8eac5a48 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 9 Nov 2021 07:33:46 +0000 Subject: [PATCH] - Use pytest to run the testsuite. - Add patch import-from-non-pythonpath-files.patch: * Allow the test suite to find modules not shipped as modules. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pdfminer.six?expand=0&rev=7 --- import-from-non-pythonpath-files.patch | 36 ++++++++++++++++++++++++++ python-pdfminer.six.changes | 7 +++++ python-pdfminer.six.spec | 10 +++---- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 import-from-non-pythonpath-files.patch diff --git a/import-from-non-pythonpath-files.patch b/import-from-non-pythonpath-files.patch new file mode 100644 index 0000000..8ff47c7 --- /dev/null +++ b/import-from-non-pythonpath-files.patch @@ -0,0 +1,36 @@ +Index: pdfminer.six-20200726/tests/test_tools_dumppdf.py +=================================================================== +--- pdfminer.six-20200726.orig/tests/test_tools_dumppdf.py ++++ pdfminer.six-20200726/tests/test_tools_dumppdf.py +@@ -5,8 +5,11 @@ from tempfile import NamedTemporaryFile + + from helpers import absolute_sample_path + from pdfminer.pdfdocument import PDFNoValidXRefWarning +-from tools import dumppdf + ++import importlib.util ++spec = importlib.util.spec_from_file_location("dumppdf", "tools/dumppdf.py") ++dumppdf = importlib.util.module_from_spec(spec) ++spec.loader.exec_module(dumppdf) + + def run(filename, options=None): + absolute_path = absolute_sample_path(filename) +Index: pdfminer.six-20200726/tests/test_tools_pdf2txt.py +=================================================================== +--- pdfminer.six-20200726.orig/tests/test_tools_pdf2txt.py ++++ pdfminer.six-20200726/tests/test_tools_pdf2txt.py +@@ -4,9 +4,13 @@ import os + from shutil import rmtree + from tempfile import NamedTemporaryFile, mkdtemp + +-import tools.pdf2txt as pdf2txt + from helpers import absolute_sample_path + ++import importlib.util ++spec = importlib.util.spec_from_file_location("pdf2txt", "tools/pdf2txt.py") ++pdf2txt = importlib.util.module_from_spec(spec) ++spec.loader.exec_module(pdf2txt) ++ + + def run(sample_path, options=None): + absolute_path = absolute_sample_path(sample_path) diff --git a/python-pdfminer.six.changes b/python-pdfminer.six.changes index cafd00e..a33c563 100644 --- a/python-pdfminer.six.changes +++ b/python-pdfminer.six.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Nov 9 07:32:27 UTC 2021 - Steve Kowalik + +- Use pytest to run the testsuite. +- Add patch import-from-non-pythonpath-files.patch: + * Allow the test suite to find modules not shipped as modules. + ------------------------------------------------------------------- Tue Sep 8 16:58:08 UTC 2020 - pgajdos@suse.com diff --git a/python-pdfminer.six.spec b/python-pdfminer.six.spec index 29dd710..3f0ac89 100644 --- a/python-pdfminer.six.spec +++ b/python-pdfminer.six.spec @@ -1,7 +1,7 @@ # # spec file for package python-pdfminer.six # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -27,9 +27,9 @@ URL: https://github.com/pdfminer/pdfminer.six Source: https://github.com/pdfminer/pdfminer.six/archive/%{version}.tar.gz#/pdfminer.six-%{version}.tar.gz # https://github.com/pdfminer/pdfminer.six/pull/489 Patch0: python-pdfminer.six-remove-nose.patch +Patch1: import-from-non-pythonpath-files.patch BuildRequires: %{python_module chardet} BuildRequires: %{python_module cryptography} -BuildRequires: %{python_module nose} BuildRequires: %{python_module pycryptodome} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} @@ -43,7 +43,7 @@ Requires: python-pycryptodome Requires: python-six Requires: python-sortedcontainers Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives Provides: python-pdfminer3k = %{version} Obsoletes: python-pdfminer3k < %{version} BuildArch: noarch @@ -63,7 +63,7 @@ of text analysis. %prep %setup -q -n pdfminer.six-%{version} -%patch0 -p1 +%autopatch -p1 sed -i -e '/^#!\//, 1d' pdfminer/psparser.py sed -i '1i #!%{_bindir}/python3' tools/dumppdf.py tools/pdf2txt.py @@ -80,7 +80,7 @@ mv %{buildroot}%{_bindir}/pdf2txt.py %{buildroot}%{_bindir}/pdf2txt %python_clone -a %{buildroot}%{_bindir}/dumppdf %check -%python_expand nosetests-%{$python_bin_suffix} -v +%pytest %post %python_install_alternative pdf2txt