Unverified Commit cd89bb23 authored by prspkt's avatar prspkt
Browse files

testing/py3-pyhamcrest: add checkdepends and run test suite

* Switch source to github as it provides a test suite.
* Since pytest4 no longer supports the _pytest.mark.parametrize_ function call,
  some tests will fail. Import patch from fedora to enable compatibility with
  pytest4.
parent df47d91d
......@@ -12,17 +12,29 @@ replaces="py3-hamcrest"
provides="py3-hamcrest=$pkgver-r$pkgrel"
depends="py3-six python3"
makedepends="py3-setuptools python3-dev"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
checkdepends="py3-hypothesis py3-mock py3-pytest"
source="$_pkgname-$pkgver.tar.gz::https://github.com/hamcrest/PyHamcrest/archive/V$pkgver.tar.gz
silence-warnings.patch"
builddir="$srcdir/"$_pkgname-$pkgver
prepare() {
default_prepare
rm -f pytest.ini
}
build() {
cd "$builddir"
python3 setup.py build
}
check() {
PYTHONPATH="build/lib" py.test-3
}
package() {
cd "$builddir"
python3 setup.py install --prefix=/usr --root="$pkgdir"
}
sha512sums="3b8393d0079b619b208ec7f06ed5133c4ff9d9dba050f818adf56347fc2225fd1c85d60f3dc262b7b9722061f0b8e4966180b6b96245a371e578d0d51633b4b0 PyHamcrest-1.9.0.tar.gz"
sha512sums="3a878637ed5138365416c170871a63640f089047b723c7ec8db893dd716c0b1cdad16a98584700405693b954af7d4868a8543d1a3fc58ded22b493c8c61661b4 PyHamcrest-1.9.0.tar.gz
8320f8c832ed3f90c11242b3bd6fad2327b3d6d1cda9a025b80453a4e69a34d39d338a21601f412d4f1903eab74bf7217c21e5ac31f84091e2f11cf6369a5658 silence-warnings.patch"
From a916909e315eb219f79b99d927c54028d7af1fc4 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 ++++----
tests/hamcrest_unit_test/core/is_test.py | 4 ++--
tests/hamcrest_unit_test/core/isinstanceof_test.py | 8 ++++----
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/tests/hamcrest_unit_test/base_description_test.py b/tests/hamcrest_unit_test/base_description_test.py
index 43d9bc9..ce76557 100644
--- 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):
diff --git a/tests/hamcrest_unit_test/core/is_test.py b/tests/hamcrest_unit_test/core/is_test.py
index 9205ddb..632c67c 100644
--- 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_matcher():
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,7 @@ def test_description_uses_equal_to(arg, identity, desc):
@pytest.mark.parametrize('arg, identity', (
('A', str),
(1, int),
- only_py2((OldClass(), OldClass)),
+ pytest.param(OldClass(), OldClass, marks=only_py2()),
))
def test_provides_instanceof_shortcut(arg, identity):
assert_matches(is_(identity), arg, "should match")
diff --git a/tests/hamcrest_unit_test/core/isinstanceof_test.py b/tests/hamcrest_unit_test/core/isinstanceof_test.py
index 862fd06..f74b84d 100644
--- a/tests/hamcrest_unit_test/core/isinstanceof_test.py
+++ b/tests/hamcrest_unit_test/core/isinstanceof_test.py
@@ -26,7 +26,7 @@ class Child(Parent):
('foo', instance_of((str, int))),
(1, instance_of((int, str))),
('foo', instance_of((int, str))),
- only_py2((Parent(), instance_of(Parent))),
+ pytest.param(Parent(), instance_of(Parent), marks=only_py2()),
))
def test_matching_evaluation(arg, matcher):
assert_matches(matcher, arg, 'same class')
@@ -35,14 +35,14 @@ def test_matching_evaluation(arg, matcher):
@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))),
+ pytest.param('not a parent', instance_of(Parent), marks=only_py2()),
+ pytest.param(None, instance_of(Parent), marks=only_py2()),
))
def test_mismatching_evaluation(arg, matcher):
assert_does_not_match(matcher, arg, 'mismatched')
@pytest.mark.parametrize('obj', (
- pytest.mark.issue56(()),
+ pytest.param((), marks=pytest.mark.issue56()),
'str',
))
def test_matcher_creation_requires_type(obj):
--
2.21.0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment