Accepting request 723243 from home:dancermak:branches:devel:languages:python

enable unit test run via _multibuild

OBS-URL: https://build.opensuse.org/request/show/723243
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-packaging?expand=0&rev=27
This commit is contained in:
Tomáš Chvátal 2019-08-14 09:33:53 +00:00 committed by Git OBS Bridge
parent 4ba3c858e1
commit 585d4a79ce
7 changed files with 207 additions and 5 deletions

View File

@ -0,0 +1,39 @@
From ee35f4ff365c3a65872f2d2ba5320c6673a5859a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dcermak@suse.com>
Date: Thu, 8 Aug 2019 14:39:57 +0200
Subject: [PATCH 1/4] Fix test failures test_linux_platforms_manylinux* for non
x86_64
Theses tests are implicitly assuming that they are being run on x86_64 or i686,
but fail on ARM, PPC, etc.
---
tests/test_tags.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/test_tags.py b/tests/test_tags.py
index 0bb4fd6..1f1441e 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -511,7 +511,8 @@ def test_linux_platforms_manylinux1(monkeypatch):
if platform.system() != "Linux":
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
platforms = tags._linux_platforms(is_32bit=False)
- assert platforms == ["manylinux1_x86_64", "linux_x86_64"]
+ arch = platform.machine()
+ assert platforms == ["manylinux1_" + arch, "linux_" + arch]
def test_linux_platforms_manylinux2010(monkeypatch):
@@ -521,7 +522,8 @@ def test_linux_platforms_manylinux2010(monkeypatch):
if platform.system() != "Linux":
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
platforms = tags._linux_platforms(is_32bit=False)
- expected = ["manylinux2010_x86_64", "manylinux1_x86_64", "linux_x86_64"]
+ arch = platform.machine()
+ expected = ["manylinux2010_" + arch, "manylinux1_" + arch, "linux_" + arch]
assert platforms == expected
--
2.22.0

View File

@ -0,0 +1,70 @@
From 73c4a178654cf0ffe64d2f10155f7d7978f3622d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dcermak@suse.com>
Date: Thu, 8 Aug 2019 15:44:09 +0200
Subject: [PATCH 2/4] Fix check for 64 bit OS
distutils.util.get_platform() returns "linux-x86_64" on 64 bit Linux and not
"linux_86_64" as assumed by this function. Instead we use the first element
returned by platform.architecture() and move the check into a separate fixture.
Furthermore, we have to check whether the current OS is x86-based, as the
results don't match otherwise.
---
tests/test_tags.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tests/test_tags.py b/tests/test_tags.py
index 1f1441e..9ec30a4 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -11,6 +11,7 @@ except ImportError:
import distutils.util
import platform
+import re
import sys
import sysconfig
import types
@@ -26,6 +27,16 @@ def example_tag():
return tags.Tag("py3", "none", "any")
+@pytest.fixture
+def is_x86():
+ return re.match(r"(i\d86|x86_64)", platform.machine()) is not None
+
+
+@pytest.fixture
+def is_64bit_os():
+ return platform.architecture()[0] == "64bit"
+
+
def test_tag_lowercasing():
tag = tags.Tag("PY3", "None", "ANY")
assert tag.interpreter == "py3"
@@ -486,18 +497,16 @@ def test_have_compatible_glibc(monkeypatch):
assert not tags._have_compatible_glibc(2, 4)
-def test_linux_platforms_64bit_on_64bit_os(monkeypatch):
- is_64bit_os = distutils.util.get_platform().endswith("_x86_64")
- if platform.system() != "Linux" or not is_64bit_os:
+def test_linux_platforms_64bit_on_64bit_os(is_64bit_os, is_x86, monkeypatch):
+ if platform.system() != "Linux" or not is_64bit_os or not is_x86:
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
linux_platform = tags._linux_platforms(is_32bit=False)[-1]
assert linux_platform == "linux_x86_64"
-def test_linux_platforms_32bit_on_64bit_os(monkeypatch):
- is_64bit_os = distutils.util.get_platform().endswith("_x86_64")
- if platform.system() != "Linux" or not is_64bit_os:
+def test_linux_platforms_32bit_on_64bit_os(is_64bit_os, is_x86, monkeypatch):
+ if platform.system() != "Linux" or not is_64bit_os or not is_x86:
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
linux_platform = tags._linux_platforms(is_32bit=True)[-1]
--
2.22.0

View File

@ -0,0 +1,32 @@
From e25b14f0ab054dbde4c2bf274f938a0f74ebb823 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dcermak@suse.com>
Date: Thu, 8 Aug 2019 15:45:12 +0200
Subject: [PATCH 3/4] Add additional test to get 100% branch coverage
the else: branch was not covered in tags._linux_platforms() due to the from the
previous commit
---
tests/test_tags.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/test_tags.py b/tests/test_tags.py
index 9ec30a4..5ffbfa5 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -513,6 +513,13 @@ def test_linux_platforms_32bit_on_64bit_os(is_64bit_os, is_x86, monkeypatch):
assert linux_platform == "linux_i686"
+def test_linux_platforms_manylinux_unsupported(monkeypatch):
+ monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+ monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
+ linux_platform = tags._linux_platforms(is_32bit=False)
+ assert linux_platform == ["linux_x86_64"]
+
+
def test_linux_platforms_manylinux1(monkeypatch):
monkeypatch.setattr(
tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux1"
--
2.22.0

View File

@ -0,0 +1,26 @@
From d691f8387975b426585bb197fc3f8d8ad6ba02c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dcermak@suse.com>
Date: Thu, 8 Aug 2019 15:54:48 +0200
Subject: [PATCH 4/4] Fix test_macos_version_detection failure on 32 bit Linux
tags._mac_arch always returns i386 on 32 bit Linux and thereby
tags._mac_platforms()[0] ends with "i386" even in the arch="x86_64" case
---
tests/test_tags.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/test_tags.py b/tests/test_tags.py
index 5ffbfa5..0e5b0c6 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -183,6 +183,7 @@ def test_macos_version_detection(monkeypatch):
def test_macos_arch_detection(arch, monkeypatch):
if platform.system() != "Darwin" or platform.mac_ver()[2] != arch:
monkeypatch.setattr(platform, "mac_ver", lambda: ("10.14", ("", "", ""), arch))
+ monkeypatch.setattr(tags, "_mac_arch", lambda *args: arch)
assert tags._mac_platforms((10, 14))[0].endswith(arch)
--
2.22.0

3
_multibuild Normal file
View File

@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Thu Aug 8 11:41:45 UTC 2019 - Dan Čermák <dcermak@suse.com>
- Enable tests via _multibuild
Add patches from https://github.com/pypa/packaging/pull/176:
* 0001-Fix-test-failures-test_linux_platforms_manylinux-for.patch
* 0002-Fix-check-for-64-bit-OS.patch
* 0003-Add-additional-test-to-get-100-branch-coverage.patch
* 0004-Fix-test_macos_version_detection-failure-on-32-bit-L.patch
(these fix the tests on non-x86 platforms and can be dropped on the next
release)
-------------------------------------------------------------------
Thu Aug 8 10:24:07 UTC 2019 - Dan Čermák <dcermak@suse.com>

View File

@ -17,7 +17,15 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%define skip_python2 1
%else
%define psuffix %{nil}
%bcond_with test
%endif
Name: python-packaging
Version: 19.1
Release: 0
@ -26,6 +34,11 @@ License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/pypa/packaging
Source: https://pypi.io/packages/source/p/packaging/packaging-%{version}.tar.gz
# FIXME: drop these patches on the next release after 19.1
Patch0: 0001-Fix-test-failures-test_linux_platforms_manylinux-for.patch
Patch1: 0002-Fix-check-for-64-bit-OS.patch
Patch2: 0003-Add-additional-test-to-get-100-branch-coverage.patch
Patch3: 0004-Fix-test_macos_version_detection-failure-on-32-bit-L.patch
BuildRequires: %{python_module six}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
@ -50,12 +63,22 @@ Core utilities for Python packages
%prep
%setup -q -n packaging-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
# sdist must provide a packaging.egg-info, used below in install phase
test -d packaging.egg-info
%build
%python_build
%if %{with test}
%check
%python_exec %{_bindir}/py.test
%endif # %%{with_test}
%if !%{with test}
%install
%python_install
# Replace distutils generated egg-info, which varies in metadata version and
@ -66,15 +89,12 @@ cp -r packaging.egg-info %{buildroot}%{$python_sitelib}/packaging-%{version}-py%
}
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%if %{with test}
%check
%python_exec %{_bindir}/py.test
%endif
%files %{python_files}
%license LICENSE LICENSE.APACHE LICENSE.BSD
%doc CHANGELOG.rst README.rst
%{python_sitelib}/packaging
%{python_sitelib}/packaging-%{version}-py*.egg-info/
%endif # !%%{with_test}
%changelog