- Remove pytest4.patch and replace it with pytest4-02.patch,

which is the upstream gh#hamcrest/PyHamcrest#124 fixing
  compatibility with pytest 4+ officially.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PyHamcrest?expand=0&rev=16
This commit is contained in:
Matej Cepl 2019-11-21 11:10:31 +00:00 committed by Git OBS Bridge
parent 6847971762
commit f49e15a53d
4 changed files with 110 additions and 37 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,32 +0,0 @@
--- a/tests/hamcrest_unit_test/base_description_test.py
+++ b/tests/hamcrest_unit_test/base_description_test.py
@@ -32,17 +32,18 @@ def test_append_text_delegates(desc):
assert desc.appended == [sentinel.Text]
-@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'>")),
- (six.u("\U0001F4A9"), six.u("'{0}'").format(six.u("\U0001F4A9"))),
-))
-def test_append_description_types(desc, described, appended):
- desc.append_description_of(described)
- assert ''.join(desc.appended) == appended
+# gh#hamcrest/PyHamcrest#123
+# @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'>")),
+# (six.u("\U0001F4A9"), six.u("'{0}'").format(six.u("\U0001F4A9"))),
+# ))
+# def test_append_description_types(desc, described, appended):
+# desc.append_description_of(described)
+# assert ''.join(desc.appended) == appended
@pytest.mark.parametrize("char, rep", (

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
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.
-------------------------------------------------------------------
Tue Nov 5 11:20:23 UTC 2019 - Matej Cepl <mcepl@suse.com>

View File

@ -1,7 +1,7 @@
#
# 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
# remain the property of their copyright owners, unless otherwise agreed
@ -27,9 +27,12 @@ URL: https://github.com/hamcrest/PyHamcrest
#Source: https://files.pythonhosted.org/packages/source/P/PyHamcrest/PyHamcrest-%%{version}.tar.gz
Source: https://github.com/hamcrest/PyHamcrest/archive/V%{version}.tar.gz
Patch0: 0001-Add-boolean-matchers.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.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 mock}
BuildRequires: %{python_module pytest}
@ -39,7 +42,7 @@ BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-six >= 1.4
Provides: python-hamcrest = %{version}
Obsoletes: python-hamcrest
Obsoletes: python-hamcrest < %{version}
BuildArch: noarch
%python_subpackages