!9 Package upgrade
From: @starlet-dx Reviewed-by: @myeuler Signed-off-by: @myeuler
This commit is contained in:
commit
5059c1b16f
@ -1,134 +0,0 @@
|
|||||||
From 37a4d0dbeb9a92b959edfb9b1aceba4eaacf9f78 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Alex Panov <thealexpanov@gmail.com>
|
|
||||||
Date: Sun, 15 May 2016 23:36:18 -0400
|
|
||||||
Subject: [PATCH] Add boolean matchers
|
|
||||||
|
|
||||||
---
|
|
||||||
README.rst | 5 ++++
|
|
||||||
src/hamcrest/library/__init__.py | 3 ++
|
|
||||||
src/hamcrest/library/bool/__init__.py | 1 +
|
|
||||||
src/hamcrest/library/bool/bool_comparison.py | 22 ++++++++++++++
|
|
||||||
tests/hamcrest_unit_test/bool/__init__.py | 0
|
|
||||||
.../bool/bool_comparison_test.py | 34 ++++++++++++++++++++++
|
|
||||||
6 files changed, 65 insertions(+)
|
|
||||||
create mode 100644 src/hamcrest/library/bool/__init__.py
|
|
||||||
create mode 100644 src/hamcrest/library/bool/bool_comparison.py
|
|
||||||
create mode 100644 tests/hamcrest_unit_test/bool/__init__.py
|
|
||||||
create mode 100644 tests/hamcrest_unit_test/bool/bool_comparison_test.py
|
|
||||||
|
|
||||||
diff --git a/README.rst b/README.rst
|
|
||||||
index 8ef46bb..d2200f8 100644
|
|
||||||
--- a/README.rst
|
|
||||||
+++ b/README.rst
|
|
||||||
@@ -148,6 +148,11 @@ PyHamcrest comes with a library of useful matchers:
|
|
||||||
* ``greater_than``, ``greater_than_or_equal_to``, ``less_than``,
|
|
||||||
``less_than_or_equal_to`` - match numeric ordering
|
|
||||||
|
|
||||||
+* Boolean
|
|
||||||
+
|
|
||||||
+ * ``is_true`` - verify the value is True
|
|
||||||
+ * ``is_false`` - verify the value is False
|
|
||||||
+
|
|
||||||
* Text
|
|
||||||
|
|
||||||
* ``contains_string`` - match part of a string
|
|
||||||
diff --git a/src/hamcrest/library/__init__.py b/src/hamcrest/library/__init__.py
|
|
||||||
index a5a7963..55dfcda 100644
|
|
||||||
--- a/src/hamcrest/library/__init__.py
|
|
||||||
+++ b/src/hamcrest/library/__init__.py
|
|
||||||
@@ -7,6 +7,7 @@ from hamcrest.library.integration import *
|
|
||||||
from hamcrest.library.number import *
|
|
||||||
from hamcrest.library.object import *
|
|
||||||
from hamcrest.library.text import *
|
|
||||||
+from hamcrest.library.bool import *
|
|
||||||
|
|
||||||
__author__ = "Jon Reid"
|
|
||||||
__copyright__ = "Copyright 2011 hamcrest.org"
|
|
||||||
@@ -41,4 +42,6 @@ __all__ = [
|
|
||||||
'ends_with',
|
|
||||||
'starts_with',
|
|
||||||
'string_contains_in_order',
|
|
||||||
+ 'is_true',
|
|
||||||
+ 'is_false'
|
|
||||||
]
|
|
||||||
diff --git a/src/hamcrest/library/bool/__init__.py b/src/hamcrest/library/bool/__init__.py
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..7cf13a3
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/hamcrest/library/bool/__init__.py
|
|
||||||
@@ -0,0 +1 @@
|
|
||||||
+from .bool_comparison import is_true, is_false
|
|
||||||
diff --git a/src/hamcrest/library/bool/bool_comparison.py b/src/hamcrest/library/bool/bool_comparison.py
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..af7e1b6
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/hamcrest/library/bool/bool_comparison.py
|
|
||||||
@@ -0,0 +1,22 @@
|
|
||||||
+from hamcrest.core.base_matcher import BaseMatcher
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+class IsABool(BaseMatcher):
|
|
||||||
+ def __init__(self, boolean_value):
|
|
||||||
+ self.boolean_value = boolean_value
|
|
||||||
+
|
|
||||||
+ def describe_to(self, description):
|
|
||||||
+ description.append_text(str(self.boolean_value))
|
|
||||||
+
|
|
||||||
+ def _matches(self, item):
|
|
||||||
+ if not isinstance(item, bool):
|
|
||||||
+ return False
|
|
||||||
+ return item == self.boolean_value
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def is_true():
|
|
||||||
+ return IsABool(True)
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def is_false():
|
|
||||||
+ return IsABool(False)
|
|
||||||
diff --git a/tests/hamcrest_unit_test/bool/__init__.py b/tests/hamcrest_unit_test/bool/__init__.py
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..e69de29
|
|
||||||
diff --git a/tests/hamcrest_unit_test/bool/bool_comparison_test.py b/tests/hamcrest_unit_test/bool/bool_comparison_test.py
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..e865365
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/tests/hamcrest_unit_test/bool/bool_comparison_test.py
|
|
||||||
@@ -0,0 +1,34 @@
|
|
||||||
+from hamcrest import assert_that, equal_to
|
|
||||||
+from hamcrest.core.string_description import StringDescription
|
|
||||||
+from hamcrest.library.bool import is_false, is_true
|
|
||||||
+from hamcrest_unit_test.matcher_test import MatcherTest
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+class BoolComparisonTest(MatcherTest):
|
|
||||||
+ def test_true_is_true(self):
|
|
||||||
+ self.assert_matches('Is True', is_true(), True)
|
|
||||||
+
|
|
||||||
+ def test_false_is_not_true(self):
|
|
||||||
+ self.assert_does_not_match('False', is_true(), False)
|
|
||||||
+
|
|
||||||
+ def test_false_is_false(self):
|
|
||||||
+ self.assert_matches('False', is_false(), False)
|
|
||||||
+
|
|
||||||
+ def test_true_is_not_false(self):
|
|
||||||
+ self.assert_does_not_match('True', is_false(), True)
|
|
||||||
+
|
|
||||||
+ def test_number_is_not_true(self):
|
|
||||||
+ self.assert_does_not_match('True', is_true(), 1)
|
|
||||||
+
|
|
||||||
+ def test_number_is_not_false(self):
|
|
||||||
+ self.assert_does_not_match('False', is_false(), 1)
|
|
||||||
+
|
|
||||||
+ def test_is_true_description(self):
|
|
||||||
+ description = StringDescription()
|
|
||||||
+ is_true().describe_to(description)
|
|
||||||
+ assert_that(str(description), equal_to('True'))
|
|
||||||
+
|
|
||||||
+ def test_is_false_description(self):
|
|
||||||
+ description = StringDescription()
|
|
||||||
+ is_false().describe_to(description)
|
|
||||||
+ assert_that(str(description), equal_to('False'))
|
|
||||||
--
|
|
||||||
2.9.3
|
|
||||||
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
From fc3c3a92c9c53d923e1f9b1ab11d3362c73ac99d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Balint Reczey <balint.reczey@canonical.com>
|
|
||||||
Date: Tue, 5 Nov 2019 16:49:25 +0100
|
|
||||||
Subject: [PATCH] Mark issue56 in a way that works wity pytest 4
|
|
||||||
|
|
||||||
reference: https://github.com/hamcrest/PyHamcrest/commit/fc3c3a92c9c53d923e1f9b1ab11d3362c73ac99d
|
|
||||||
|
|
||||||
---
|
|
||||||
pytest.ini | 2 ++
|
|
||||||
tests/hamcrest_unit_test/core/is_test.py | 2 +-
|
|
||||||
tests/hamcrest_unit_test/core/isinstanceof_test.py | 7 -------
|
|
||||||
3 files changed, 3 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/pytest.ini b/pytest.ini
|
|
||||||
index 80c7b6a..55c7e5f 100644
|
|
||||||
--- a/pytest.ini
|
|
||||||
+++ b/pytest.ini
|
|
||||||
@@ -1,2 +1,4 @@
|
|
||||||
[pytest]
|
|
||||||
addopts = --cov hamcrest --cov-report term-missing --no-cov-on-fail
|
|
||||||
+markers =
|
|
||||||
+ issue56
|
|
||||||
diff --git a/tests/hamcrest_unit_test/core/is_test.py b/tests/hamcrest_unit_test/core/is_test.py
|
|
||||||
index 9205ddb..e0bd23d 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', (
|
|
||||||
diff --git a/tests/hamcrest_unit_test/core/isinstanceof_test.py b/tests/hamcrest_unit_test/core/isinstanceof_test.py
|
|
||||||
index 862fd06..9f4608b 100644
|
|
||||||
--- a/tests/hamcrest_unit_test/core/isinstanceof_test.py
|
|
||||||
+++ b/tests/hamcrest_unit_test/core/isinstanceof_test.py
|
|
||||||
@@ -41,13 +41,6 @@ def test_matching_evaluation(arg, matcher):
|
|
||||||
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),
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
From 0170484ec60853dbbdbd4aa5f3ffff9517ee77ed Mon Sep 17 00:00:00 2001
|
|
||||||
From: Balint Reczey <balint.reczey@canonical.com>
|
|
||||||
Date: Tue, 5 Nov 2019 17:09:49 +0100
|
|
||||||
Subject: [PATCH] Drop Python 2-only tests breaking with pytest 4
|
|
||||||
|
|
||||||
reference: https://github.com/hamcrest/PyHamcrest/commit/0170484ec60853dbbdbd4aa5f3ffff9517ee77ed
|
|
||||||
---
|
|
||||||
tests/hamcrest_unit_test/core/is_test.py | 1 -
|
|
||||||
tests/hamcrest_unit_test/core/isinstanceof_test.py | 3 ---
|
|
||||||
tests/hamcrest_unit_test/matcher_test.py | 6 ------
|
|
||||||
3 files changed, 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/tests/hamcrest_unit_test/core/is_test.py b/tests/hamcrest_unit_test/core/is_test.py
|
|
||||||
index e0bd23d..6c222b7 100644
|
|
||||||
--- a/tests/hamcrest_unit_test/core/is_test.py
|
|
||||||
+++ b/tests/hamcrest_unit_test/core/is_test.py
|
|
||||||
@@ -65,7 +65,6 @@ def test_description_uses_equal_to(arg, identity, desc):
|
|
||||||
@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")
|
|
||||||
diff --git a/tests/hamcrest_unit_test/core/isinstanceof_test.py b/tests/hamcrest_unit_test/core/isinstanceof_test.py
|
|
||||||
index 9f4608b..a963d4f 100644
|
|
||||||
--- 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,8 +34,6 @@ 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))),
|
|
||||||
))
|
|
||||||
def test_mismatching_evaluation(arg, matcher):
|
|
||||||
assert_does_not_match(matcher, arg, 'mismatched')
|
|
||||||
diff --git a/tests/hamcrest_unit_test/matcher_test.py b/tests/hamcrest_unit_test/matcher_test.py
|
|
||||||
index ec40158..5bb14bf 100644
|
|
||||||
--- 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, matcher, arg):
|
|
||||||
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")
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
From a7ba2de9d3661c9a4489810669586be23f159d46 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.
|
|
||||||
|
|
||||||
reference: https://github.com/hamcrest/PyHamcrest/commit/a7ba2de9d3661c9a4489810669586be23f159d46
|
|
||||||
---
|
|
||||||
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 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):
|
|
||||||
Binary file not shown.
BIN
python-hamcrest-2.0.3.tar.gz
Normal file
BIN
python-hamcrest-2.0.3.tar.gz
Normal file
Binary file not shown.
@ -1,14 +1,10 @@
|
|||||||
Name: python-hamcrest
|
Name: python-hamcrest
|
||||||
Version: 1.9.0
|
Version: 2.0.3
|
||||||
Release: 11
|
Release: 1
|
||||||
Summary: Hamcrest matchers for Python
|
Summary: Hamcrest matchers for Python
|
||||||
License: BSD-3-Clause
|
License: BSD-3-Clause
|
||||||
URL: https://github.com/hamcrest/PyHamcrest
|
URL: https://github.com/hamcrest/PyHamcrest
|
||||||
Source0: https://github.com/hamcrest/PyHamcrest/archive/V1.9.0/%{name}-1.9.0.tar.gz
|
Source0: https://github.com/hamcrest/PyHamcrest/archive/V2.0.3/%{name}-%{version}.tar.gz
|
||||||
Patch0001: 0001-Add-boolean-matchers.patch
|
|
||||||
Patch0002: 0002-Mark-issue56-in-a-way-that-works-wity-pytest4.patch
|
|
||||||
Patch0003: 0003-Drop-Python2-only-tests-breaking-with-pytest4.patch
|
|
||||||
Patch0004: 0004-Silence-warnings-from-tests-due-to-use-of-old-pytest.parameterize-signature.patch
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -22,6 +18,7 @@ commonly used.
|
|||||||
Summary: Hamcrest matchers for Python
|
Summary: Hamcrest matchers for Python
|
||||||
%{?python_provide:%python_provide python3-hamcrest}
|
%{?python_provide:%python_provide python3-hamcrest}
|
||||||
BuildRequires: python3-devel python3-setuptools python3-pytest python3-mock python3-six
|
BuildRequires: python3-devel python3-setuptools python3-pytest python3-mock python3-six
|
||||||
|
BuildRequires: python3-numpy
|
||||||
Requires: python3-six
|
Requires: python3-six
|
||||||
|
|
||||||
%description -n python3-hamcrest
|
%description -n python3-hamcrest
|
||||||
@ -42,7 +39,6 @@ Python 3 version.
|
|||||||
%py3_install
|
%py3_install
|
||||||
|
|
||||||
%check
|
%check
|
||||||
mv pytest.ini pytest.ini~
|
|
||||||
PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v
|
PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v
|
||||||
|
|
||||||
|
|
||||||
@ -50,6 +46,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v
|
|||||||
%{python3_sitelib}/*
|
%{python3_sitelib}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jun 29 2022 yaoxin <yaoxin30@h-partners.com> - 2.0.3-1
|
||||||
|
- Update to 2.0.3
|
||||||
|
|
||||||
* Wed May 11 2022 houyingchao <houyingchao@h-partners.com> - 1.9.0-11
|
* Wed May 11 2022 houyingchao <houyingchao@h-partners.com> - 1.9.0-11
|
||||||
- License compliance rectification
|
- License compliance rectification
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user