From 930ce6deb95c2dfdeebf8d90137aa6bb24787577882da64bb10bf7a230fd875d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 11 Jun 2019 19:45:25 +0000 Subject: [PATCH] Accepting request 709252 from home:mcepl:branches:devel:languages:python It's better to fix than to avoid. OBS-URL: https://build.opensuse.org/request/show/709252 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-Arpeggio?expand=0&rev=10 --- imp-to-importlib.patch | 37 +++++++++++++++++++++++++++++++++++++ python-Arpeggio.changes | 7 +++++++ python-Arpeggio.spec | 7 +++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 imp-to-importlib.patch 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