diff --git a/imp-to-importlib.patch b/imp-to-importlib.patch new file mode 100644 index 0000000..f6155be --- /dev/null +++ b/imp-to-importlib.patch @@ -0,0 +1,37 @@ +--- a/tests/unit/test_examples.py ++++ b/tests/unit/test_examples.py +@@ -10,8 +10,12 @@ import pytest # noqa + import os + import sys + import glob +-import imp + ++PY2 = sys.version_info[0] < 3 ++if PY2: ++ import imp ++else: ++ import importlib + + def test_examples(): + +@@ -24,10 +28,14 @@ def test_examples(): + example_dir = os.path.dirname(e) + sys.path.insert(0, example_dir) + (module_name, _) = os.path.splitext(os.path.basename(e)) +- (module_file, module_path, desc) = \ +- imp.find_module(module_name, [example_dir]) ++ if PY2: ++ (module_file, module_path, desc) = \ ++ imp.find_module(module_name, [example_dir]) ++ mod = imp.load_module(module_name, module_file, module_path, desc) ++ else: ++ mod_spec = importlib.util.spec_from_file_location(module_name, e) ++ mod = importlib.util.module_from_spec(mod_spec) ++ mod_spec.loader.exec_module(mod) + +- m = imp.load_module(module_name, module_file, module_path, desc) +- +- if hasattr(m, 'main'): +- m.main(debug=False) ++ if hasattr(mod, 'main'): ++ mod.main(debug=False) diff --git a/python-Arpeggio.changes b/python-Arpeggio.changes index 4936934..70a3a66 100644 --- a/python-Arpeggio.changes +++ b/python-Arpeggio.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Jun 11 20:52:07 CEST 2019 - Matej Cepl + +- It's better to fix a bug, than to switch off test. Add + imp-to-importlib.patch replacing use of imp library in Python + 3 with importlib. gh#textX/Arpeggio#54 + ------------------------------------------------------------------- Tue Jun 11 13:14:44 UTC 2019 - Tomáš Chvátal diff --git a/python-Arpeggio.spec b/python-Arpeggio.spec index 3d15f4e..fcecde5 100644 --- a/python-Arpeggio.spec +++ b/python-Arpeggio.spec @@ -25,6 +25,9 @@ License: MIT Group: Development/Languages/Python URL: https://github.com/textX/Arpeggio/ Source: https://github.com/textX/Arpeggio/archive/v%{version}.tar.gz +# PATCH-FIX-UPSTREAM imp-to-importlib.patch gh#textX/Arpeggio#54 mcepl@suse.com +# Replace use of imp library with importlib. +Patch0: imp-to-importlib.patch BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} BuildRequires: fdupes @@ -41,6 +44,7 @@ Arpeggio) see textX %prep %setup -q -n Arpeggio-%{version} +%autopatch -p1 %build %python_build @@ -50,8 +54,7 @@ Arpeggio) see textX %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -# skip as it randomly fails: test_examples -%pytest tests/unit -k 'not test_examples' +%pytest tests/unit %files %{python_files} %doc README.rst CHANGELOG AUTHORS.md