Accepting request 750095 from devel:languages:python

- Remove pytest4.patch and replace it with pytest4-02.patch,
  which is the upstream gh#hamcrest/PyHamcrest#124 fixing
  compatibility with pytest 4+ officially. And of course, we
  don't have to massacre test files anymore.

- Run spec-cleaner
- Add pytest4.patch to make the testsuite actually really pass.

- Because of gh#hamcrest/PyHamcrest#123 we have to remove 
  tests/hamcrest_unit_test/core/is{_test,instanceof_test}.py to
  make the test suite passing.
  Patch pytest4.patch has been removed, it was a step into dead
  end.

OBS-URL: https://build.opensuse.org/request/show/750095
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-PyHamcrest?expand=0&rev=4
This commit is contained in:
Dominique Leuenberger 2019-11-22 09:26:21 +00:00 committed by Git OBS Bridge
commit 0e3c0a5063
4 changed files with 127 additions and 34 deletions

95
pytest4-02.patch Normal file
View File

@ -0,0 +1,95 @@
From 891f22d080402c8086a07e0d83f3fa27c3fa8e8f Mon Sep 17 00:00:00 2001
From: Simon Brunning <simon@brunningonline.net>
Date: Fri, 2 Nov 2018 09:50:20 +0000
Subject: [PATCH 1/3] Silence warnings from tests due to use of old
pytest.parameterize() signature.
---
tests/hamcrest_unit_test/base_description_test.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/tests/hamcrest_unit_test/base_description_test.py
+++ b/tests/hamcrest_unit_test/base_description_test.py
@@ -34,10 +34,10 @@ def test_append_text_delegates(desc):
@pytest.mark.parametrize('described, appended', (
(Described(), 'described'),
- pytest.mark.skipif(six.PY3, reason="py2 only")((six.u('unicode-py2'), "'unicode-py2'")),
- pytest.mark.skipif(six.PY3, reason="py2 only")((six.b('bytes-py2'), "'bytes-py2'")),
- pytest.mark.skipif(six.PY2, reason="py3 only")((six.u('unicode-py3'), "'unicode-py3'")),
- pytest.mark.skipif(six.PY2, reason="py3 only")((six.b('bytes-py3'), "<b'bytes-py3'>")),
+ pytest.param(six.u('unicode-py2'), "'unicode-py2'", marks=pytest.mark.skipif(six.PY3, reason="py2 only")),
+ pytest.param(six.b('bytes-py2'), "'bytes-py2'", marks=pytest.mark.skipif(six.PY3, reason="py2 only")),
+ pytest.param(six.u('unicode-py3'), "'unicode-py3'", marks=pytest.mark.skipif(six.PY2, reason="py3 only")),
+ pytest.param(six.b('bytes-py3'), "<b'bytes-py3'>", marks=pytest.mark.skipif(six.PY2, reason="py3 only")),
(six.u("\U0001F4A9"), six.u("'{0}'").format(six.u("\U0001F4A9"))),
))
def test_append_description_types(desc, described, appended):
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,2 +1,4 @@
[pytest]
addopts = --cov hamcrest --cov-report term-missing --no-cov-on-fail
+markers =
+ issue56
--- a/tests/hamcrest_unit_test/core/is_test.py
+++ b/tests/hamcrest_unit_test/core/is_test.py
@@ -39,7 +39,7 @@ def test_description_should_pass_through
equal_matches = pytest.mark.parametrize('arg, identity, desc', (
('A', 'A', "'A'"),
(5 + 3, 8, "<8>"),
- pytest.mark.issue56((tuple(), (), "<()>")),
+ pytest.param(tuple(), (), "<()>", marks=pytest.mark.issue56),
))
equal_mismatches = pytest.mark.parametrize('arg, identity, desc', (
@@ -65,7 +65,6 @@ def test_description_uses_equal_to(arg,
@pytest.mark.parametrize('arg, identity', (
('A', str),
(1, int),
- only_py2((OldClass(), OldClass)),
))
def test_provides_instanceof_shortcut(arg, identity):
assert_matches(is_(identity), arg, "should match")
--- a/tests/hamcrest_unit_test/core/isinstanceof_test.py
+++ b/tests/hamcrest_unit_test/core/isinstanceof_test.py
@@ -26,7 +26,6 @@ class Child(Parent):
('foo', instance_of((str, int))),
(1, instance_of((int, str))),
('foo', instance_of((int, str))),
- only_py2((Parent(), instance_of(Parent))),
))
def test_matching_evaluation(arg, matcher):
assert_matches(matcher, arg, 'same class')
@@ -35,19 +34,10 @@ def test_matching_evaluation(arg, matche
@pytest.mark.parametrize('arg, matcher', (
('hi', instance_of(int)),
(None, instance_of(int)),
- only_py2(('not a parent', instance_of(Parent))),
- only_py2((None, instance_of(Parent))),
))
def test_mismatching_evaluation(arg, matcher):
assert_does_not_match(matcher, arg, 'mismatched')
-@pytest.mark.parametrize('obj', (
- pytest.mark.issue56(()),
- 'str',
-))
-def test_matcher_creation_requires_type(obj):
- with pytest.raises(TypeError):
- instance_of(obj)
@pytest.mark.parametrize('desc, type', (
('an instance of int', int),
--- a/tests/hamcrest_unit_test/matcher_test.py
+++ b/tests/hamcrest_unit_test/matcher_test.py
@@ -77,9 +77,3 @@ def assert_describe_mismatch(expected, m
description = StringDescription()
matcher.describe_mismatch(arg, description)
assert expected == str(description)
-
-
-only_py3 = pytest.mark.skipif(sys.version_info < (3, ),
- reason="Only relevant in Python 3")
-only_py2 = pytest.mark.skipif(sys.version_info >= (3, ),
- reason="Only relevant in Python 2")

View File

@ -1,29 +0,0 @@
From f71c3c6f8af716435b6d44c007d502b6fb362e20 Mon Sep 17 00:00:00 2001
From: Simon Brunning <simon@brunningonline.net>
Date: Fri, 2 Nov 2018 09:50:20 +0000
Subject: [PATCH] Silence warnings from tests due to use of old
pytest.parameterize() signature.
---
tests/hamcrest_unit_test/base_description_test.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tests/hamcrest_unit_test/base_description_test.py b/tests/hamcrest_unit_test/base_description_test.py
index 82cd238..60f1862 100644
--- a/tests/hamcrest_unit_test/base_description_test.py
+++ b/tests/hamcrest_unit_test/base_description_test.py
@@ -35,10 +35,10 @@ def test_append_text_delegates(desc):
@pytest.mark.parametrize('described, appended', (
(Described(), 'described'),
- pytest.mark.skipif(six.PY3, reason="py2 only")((six.u('unicode-py2'), "'unicode-py2'")),
- pytest.mark.skipif(six.PY3, reason="py2 only")((six.b('bytes-py2'), "'bytes-py2'")),
- pytest.mark.skipif(six.PY2, reason="py3 only")((six.u('unicode-py3'), "'unicode-py3'")),
- pytest.mark.skipif(six.PY2, reason="py3 only")((six.b('bytes-py3'), "<b'bytes-py3'>")),
+ pytest.param(six.u('unicode-py2'), "'unicode-py2'", marks=pytest.mark.skipif(six.PY3, reason="py2 only")),
+ pytest.param(six.b('bytes-py2'), "'bytes-py2'", marks=pytest.mark.skipif(six.PY3, reason="py2 only")),
+ pytest.param(six.u('unicode-py3'), "'unicode-py3'", marks=pytest.mark.skipif(six.PY2, reason="py3 only")),
+ pytest.param(six.b('bytes-py3'), "<b'bytes-py3'>", marks=pytest.mark.skipif(six.PY2, reason="py3 only")),
(six.u("\U0001F4A9"), six.u("'{0}'").format(six.u("\U0001F4A9"))),
))
def test_append_description_types(desc, described, appended):

View File

@ -1,3 +1,26 @@
-------------------------------------------------------------------
Thu Nov 21 12:06:53 CET 2019 - Matej Cepl <mcepl@suse.com>
- Remove pytest4.patch and replace it with pytest4-02.patch,
which is the upstream gh#hamcrest/PyHamcrest#124 fixing
compatibility with pytest 4+ officially. And of course, we
don't have to massacre test files anymore.
-------------------------------------------------------------------
Tue Nov 5 11:20:23 UTC 2019 - Matej Cepl <mcepl@suse.com>
- Run spec-cleaner
- Add pytest4.patch to make the testsuite actually really pass.
-------------------------------------------------------------------
Mon Nov 4 14:35:43 UTC 2019 - Matej Cepl <mcepl@suse.com>
- Because of gh#hamcrest/PyHamcrest#123 we have to remove
tests/hamcrest_unit_test/core/is{_test,instanceof_test}.py to
make the test suite passing.
Patch pytest4.patch has been removed, it was a step into dead
end.
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jul 19 10:22:31 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com> Fri Jul 19 10:22:31 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>

View File

@ -1,7 +1,7 @@
# #
# spec file for package python-PyHamcrest # spec file for package python-PyHamcrest
# #
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2019 SUSE LLC
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -22,23 +22,27 @@ Version: 1.9.0
Release: 0 Release: 0
Summary: Hamcrest framework for matcher objects Summary: Hamcrest framework for matcher objects
License: BSD-3-Clause License: BSD-3-Clause
Group: Development/Languages/Python
URL: https://github.com/hamcrest/PyHamcrest URL: https://github.com/hamcrest/PyHamcrest
# PyPi is missing tests # PyPi is missing tests
#Source: https://files.pythonhosted.org/packages/source/P/PyHamcrest/PyHamcrest-%%{version}.tar.gz #Source: https://files.pythonhosted.org/packages/source/P/PyHamcrest/PyHamcrest-%%{version}.tar.gz
Source: https://github.com/hamcrest/PyHamcrest/archive/V%{version}.tar.gz Source: https://github.com/hamcrest/PyHamcrest/archive/V%{version}.tar.gz
Patch0: 0001-Add-boolean-matchers.patch Patch0: 0001-Add-boolean-matchers.patch
Patch1: pytest4.patch # # PATCH-FIX-UPSTREAM pytest4.patch gh#hamcrest/PyHamcrest#123 mcepl@suse.com
# # eliminate non-compatible test case
# Patch1: pytest4.patch
# PATCH-FIX-UPSTREAM pytest4-02.patch gh#hamcrest/PyHamcrest#123 mcepl@suse.com
# compatibility with pytest4+ (from gh#hamcrest/PyHamcrest#124)
Patch1: pytest4-02.patch
BuildRequires: %{python_module hypothesis >= 1.11} BuildRequires: %{python_module hypothesis >= 1.11}
BuildRequires: %{python_module mock} BuildRequires: %{python_module mock}
BuildRequires: %{python_module pytest < 4.0} BuildRequires: %{python_module pytest}
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module six >= 1.4} BuildRequires: %{python_module six >= 1.4}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: python-six >= 1.4 Requires: python-six >= 1.4
Provides: python-hamcrest = %{version} Provides: python-hamcrest = %{version}
Obsoletes: python-hamcrest Obsoletes: python-hamcrest < %{version}
BuildArch: noarch BuildArch: noarch
%python_subpackages %python_subpackages