17
0

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
This commit is contained in:
Tomáš Chvátal
2019-06-11 19:45:25 +00:00
committed by Git OBS Bridge
parent ffb01e1a61
commit 930ce6deb9
3 changed files with 49 additions and 2 deletions

37
imp-to-importlib.patch Normal file
View File

@@ -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)

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jun 11 20:52:07 CEST 2019 - Matej Cepl <mcepl@suse.com>
- 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 <tchvatal@suse.com>

View File

@@ -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