Compare commits
10 Commits
34d499b6b5
...
6a1da5551b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a1da5551b | ||
|
|
7842b02395 | ||
|
|
3b40a5dacc | ||
|
|
53b29d02a9 | ||
|
|
0fedd6a1e6 | ||
|
|
22ed65ad3d | ||
|
|
5059c1b16f | ||
|
|
e1a6a81853 | ||
|
|
2fb6108f94 | ||
|
|
1fb9162b3e |
@ -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):
|
|
||||||
73
Ordered-comparison-matchers-should-fail-for-incompar.patch
Normal file
73
Ordered-comparison-matchers-should-fail-for-incompar.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
From 78e99b0eb25d5bd81d8f183f50bc91bed2d1fcf5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Simon Brunning <simon@brunningonline.net>
|
||||||
|
Date: Thu, 3 Mar 2022 13:31:21 +0000
|
||||||
|
Subject: [PATCH] Ordered comparison matchers should fail for incomparable
|
||||||
|
types. Fix for #185
|
||||||
|
|
||||||
|
---
|
||||||
|
src/hamcrest/library/number/ordering_comparison.py | 5 ++++-
|
||||||
|
.../issequence_containinginanyorder_test.py | 11 +++++++++++
|
||||||
|
.../number/ordering_comparison_test.py | 3 +++
|
||||||
|
3 files changed, 18 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/hamcrest/library/number/ordering_comparison.py b/src/hamcrest/library/number/ordering_comparison.py
|
||||||
|
index 6c6275d..f121caf 100644
|
||||||
|
--- a/src/hamcrest/library/number/ordering_comparison.py
|
||||||
|
+++ b/src/hamcrest/library/number/ordering_comparison.py
|
||||||
|
@@ -22,7 +22,10 @@ class OrderingComparison(BaseMatcher[Any]):
|
||||||
|
self.comparison_description = comparison_description
|
||||||
|
|
||||||
|
def _matches(self, item: Any) -> bool:
|
||||||
|
- return self.comparison_function(item, self.value)
|
||||||
|
+ try:
|
||||||
|
+ return self.comparison_function(item, self.value)
|
||||||
|
+ except TypeError:
|
||||||
|
+ return False
|
||||||
|
|
||||||
|
def describe_to(self, description: Description) -> None:
|
||||||
|
description.append_text("a value ").append_text(self.comparison_description).append_text(
|
||||||
|
diff --git a/tests/hamcrest_unit_test/collection/issequence_containinginanyorder_test.py b/tests/hamcrest_unit_test/collection/issequence_containinginanyorder_test.py
|
||||||
|
index 5c21fbb..b36d192 100644
|
||||||
|
--- a/tests/hamcrest_unit_test/collection/issequence_containinginanyorder_test.py
|
||||||
|
+++ b/tests/hamcrest_unit_test/collection/issequence_containinginanyorder_test.py
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
+from hamcrest import greater_than
|
||||||
|
from hamcrest.core.core.isequal import equal_to
|
||||||
|
from hamcrest.library.collection.issequence_containinginanyorder import contains_inanyorder
|
||||||
|
from hamcrest_unit_test.matcher_test import MatcherTest
|
||||||
|
@@ -84,6 +85,16 @@ class IsSequenceContainingInAnyOrderBase(object):
|
||||||
|
"no item matches: <2> in [<3>, <1>]", matcher, self._sequence(3, 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
+ def testIncomparableTypes(self):
|
||||||
|
+ self.assert_matches("Incomparable types", contains_inanyorder(*[4, "a"]), ["a", 4])
|
||||||
|
+
|
||||||
|
+ def testIncomparableTypesInNestedMatcher(self):
|
||||||
|
+ self.assert_matches(
|
||||||
|
+ "Incomparable types in nested matcher",
|
||||||
|
+ contains_inanyorder(*[greater_than(0), "a"]),
|
||||||
|
+ ["a", 4],
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
|
||||||
|
class IsConcreteSequenceContainingInAnyOrderTest(
|
||||||
|
MatcherTest, IsSequenceContainingInAnyOrderBase, SequenceForm
|
||||||
|
diff --git a/tests/hamcrest_unit_test/number/ordering_comparison_test.py b/tests/hamcrest_unit_test/number/ordering_comparison_test.py
|
||||||
|
index 76143df..d944519 100644
|
||||||
|
--- a/tests/hamcrest_unit_test/number/ordering_comparison_test.py
|
||||||
|
+++ b/tests/hamcrest_unit_test/number/ordering_comparison_test.py
|
||||||
|
@@ -67,6 +67,9 @@ class OrderingComparisonTest(MatcherTest):
|
||||||
|
self.assert_describe_mismatch("was <0>", greater_than_or_equal_to(1), 0)
|
||||||
|
self.assert_describe_mismatch("was <2>", less_than_or_equal_to(1), 2)
|
||||||
|
|
||||||
|
+ def testIncomparableTypes(self):
|
||||||
|
+ self.assert_does_not_match("incomparable types", greater_than(1), "a")
|
||||||
|
+
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
From 41fac8c3bc727c0bdaa0d1b037783b759238c193 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chris Rose <offline@offby1.net>
|
||||||
|
Date: Sat, 13 Aug 2022 07:51:31 -0500
|
||||||
|
Subject: [PATCH] nit: fix a minor type annotation bug in
|
||||||
|
isdict_containingentries
|
||||||
|
|
||||||
|
Fixes #182
|
||||||
|
---
|
||||||
|
changelog.d/182.bugfix.rst | 1 +
|
||||||
|
src/hamcrest/library/collection/isdict_containingentries.py | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 changelog.d/182.bugfix.rst
|
||||||
|
|
||||||
|
diff --git a/changelog.d/182.bugfix.rst b/changelog.d/182.bugfix.rst
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..1b09d8c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/changelog.d/182.bugfix.rst
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+Use the correct generic type in the internal ``describe_keyvalue`` method
|
||||||
|
diff --git a/src/hamcrest/library/collection/isdict_containingentries.py b/src/hamcrest/library/collection/isdict_containingentries.py
|
||||||
|
index 490affa..8c17c20 100644
|
||||||
|
--- a/src/hamcrest/library/collection/isdict_containingentries.py
|
||||||
|
+++ b/src/hamcrest/library/collection/isdict_containingentries.py
|
||||||
|
@@ -57,7 +57,7 @@ class IsDictContainingEntries(BaseMatcher[Mapping[K, V]]):
|
||||||
|
def describe_mismatch(self, item: Mapping[K, V], mismatch_description: Description) -> None:
|
||||||
|
self.matches(item, mismatch_description)
|
||||||
|
|
||||||
|
- def describe_keyvalue(self, index: int, value: V, description: Description) -> None:
|
||||||
|
+ def describe_keyvalue(self, index: K, value: V, description: Description) -> None:
|
||||||
|
"""Describes key-value pair at given index."""
|
||||||
|
description.append_description_of(index).append_text(": ").append_description_of(value)
|
||||||
|
|
||||||
|
--
|
||||||
|
2.9.3.windows.1
|
||||||
|
|
||||||
42
numpy-1.20.0-alias-depr.patch
Normal file
42
numpy-1.20.0-alias-depr.patch
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
From 8ccad121bccd576ecd212efb44109d697024fbf9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: aekoroglu <ali.erdinc.koroglu@intel.com>
|
||||||
|
Date: Mon, 5 Sep 2022 16:42:51 +0300
|
||||||
|
Subject: [PATCH] deprecated numpy alias
|
||||||
|
|
||||||
|
Refer: https://github.com/hamcrest/PyHamcrest/pull/218
|
||||||
|
|
||||||
|
---
|
||||||
|
tests/hamcrest_unit_test/number/iscloseto_test.py | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tests/hamcrest_unit_test/number/iscloseto_test.py b/tests/hamcrest_unit_test/number/iscloseto_test.py
|
||||||
|
index f83964fd..b82109c5 100644
|
||||||
|
--- a/tests/hamcrest_unit_test/number/iscloseto_test.py
|
||||||
|
+++ b/tests/hamcrest_unit_test/number/iscloseto_test.py
|
||||||
|
@@ -64,7 +64,7 @@ def testMatcherSupportsDecimal(self):
|
||||||
|
class IsNumericTest(unittest.TestCase):
|
||||||
|
@unittest.skipUnless(NUMPY_AVAILABLE, "Skipped because it needs NumPy")
|
||||||
|
def test_numpy_numeric_type_int(self):
|
||||||
|
- self.assertTrue(isnumeric(np.int(1)), "Platform integer (normally either int32 or int64)")
|
||||||
|
+ self.assertTrue(isnumeric(np.int_(1)), "Platform integer (normally either int32 or int64)")
|
||||||
|
|
||||||
|
@unittest.skipUnless(NUMPY_AVAILABLE, "Skipped because it needs NumPy")
|
||||||
|
def test_numpy_numeric_type_int8(self):
|
||||||
|
@@ -102,7 +102,7 @@ def test_numpy_numeric_type_uint64(self):
|
||||||
|
|
||||||
|
@unittest.skipUnless(NUMPY_AVAILABLE, "Skipped because it needs NumPy")
|
||||||
|
def test_numpy_numeric_type_float(self):
|
||||||
|
- self.assertTrue(isnumeric(np.float(1)), "Shorthand for float64.")
|
||||||
|
+ self.assertTrue(isnumeric(np.float_(1)), "Shorthand for float64.")
|
||||||
|
|
||||||
|
@unittest.skipUnless(NUMPY_AVAILABLE, "Skipped because it needs NumPy")
|
||||||
|
def test_numpy_numeric_type_float16(self):
|
||||||
|
@@ -127,7 +127,7 @@ def test_numpy_numeric_type_float64(self):
|
||||||
|
|
||||||
|
@unittest.skipUnless(NUMPY_AVAILABLE, "Skipped because it needs NumPy")
|
||||||
|
def test_numpy_numeric_type_complex(self):
|
||||||
|
- self.assertTrue(isnumeric(np.complex(1)), "Shorthand for complex128.")
|
||||||
|
+ self.assertTrue(isnumeric(np.complex_(1)), "Shorthand for complex128.")
|
||||||
|
|
||||||
|
@unittest.skipUnless(NUMPY_AVAILABLE, "Skipped because it needs NumPy")
|
||||||
|
def test_numpy_numeric_type_complex64(self):
|
||||||
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,13 @@
|
|||||||
Name: python-hamcrest
|
Name: python-hamcrest
|
||||||
Version: 1.9.0
|
Version: 2.0.3
|
||||||
Release: 10
|
Release: 4
|
||||||
Summary: Hamcrest matchers for Python
|
Summary: Hamcrest matchers for Python
|
||||||
License: BSD
|
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
|
Patch0: numpy-1.20.0-alias-depr.patch
|
||||||
Patch0002: 0002-Mark-issue56-in-a-way-that-works-wity-pytest4.patch
|
Patch1: backport-nit-fix-a-minor-type-annotation-bug-in-isdict_contai.patch
|
||||||
Patch0003: 0003-Drop-Python2-only-tests-breaking-with-pytest4.patch
|
Patch2: Ordered-comparison-matchers-should-fail-for-incompar.patch
|
||||||
Patch0004: 0004-Silence-warnings-from-tests-due-to-use-of-old-pytest.parameterize-signature.patch
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -22,6 +21,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 +42,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 +49,21 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v
|
|||||||
%{python3_sitelib}/*
|
%{python3_sitelib}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri May 10 2024 lilu <lilu@kylinos.cn> - 2.0.3-4
|
||||||
|
- Fix the error that ordered comparison matchers should fail for incomparable types
|
||||||
|
|
||||||
|
* Thu May 9 2024 wuzhaomin <wuzhaomin@kylinos.cn> - 2.0.3-3
|
||||||
|
- fix a minor type annotation bug in isdict_containingentries
|
||||||
|
|
||||||
|
* Sun Jul 23 2023 wangkai <13474090681@163.com> - 2.0.3-2
|
||||||
|
- Fix build error for numpy-1.20
|
||||||
|
|
||||||
|
* 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
|
||||||
|
- License compliance rectification
|
||||||
|
|
||||||
* Fri Jan 08 2021 maminjie <maminjie1@huawei.com> - 1.9.0-10
|
* Fri Jan 08 2021 maminjie <maminjie1@huawei.com> - 1.9.0-10
|
||||||
- port to pytest4
|
- port to pytest4
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user