summaryrefslogtreecommitdiffstats
path: root/contrib/python/PyHamcrest/py3/patches
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-09-10 15:34:55 +0300
committerrobot-piglet <[email protected]>2025-09-10 15:52:03 +0300
commitb0091b5ec4e788ed216c0a23786c921307b79b0a (patch)
tree4da0bd43ceae17f84820956bcd3801cdb8c0ebb8 /contrib/python/PyHamcrest/py3/patches
parent3f573d26f7b92eb46dfff503d68a5897c96386ce (diff)
Intermediate changes
commit_hash:6b9536340f4f2533b62d862c22cbfeb121d4fa3f
Diffstat (limited to 'contrib/python/PyHamcrest/py3/patches')
-rw-r--r--contrib/python/PyHamcrest/py3/patches/01-speedup.patch28
-rw-r--r--contrib/python/PyHamcrest/py3/patches/02-add-additional-matcher.patch4
-rw-r--r--contrib/python/PyHamcrest/py3/patches/03-pr54.patch58
-rw-r--r--contrib/python/PyHamcrest/py3/patches/04-pr130.patch11
4 files changed, 71 insertions, 30 deletions
diff --git a/contrib/python/PyHamcrest/py3/patches/01-speedup.patch b/contrib/python/PyHamcrest/py3/patches/01-speedup.patch
deleted file mode 100644
index 2d96d935fd6..00000000000
--- a/contrib/python/PyHamcrest/py3/patches/01-speedup.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-commit 4dc0f71a2788ed3530b053c0363738a8964f6a86
-author: asatarin
-date: 2017-10-13T16:14:43+03:00
-revision: 3199619
-
- REVIEW:340199 Speed up StringDescription
-
---- contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py (94523234ff338f573e50b70f8cf7f6c8456bd3a1)
-+++ contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py (4dc0f71a2788ed3530b053c0363738a8964f6a86)
-@@ -24,15 +24,14 @@ def tostring(selfdescribing):
- class StringDescription(BaseDescription):
- """A :py:class:`~hamcrest.core.description.Description` that is stored as a
- string.
--
- """
-
- def __init__(self):
-- self.out = ''
-+ self.__out_list = []
-
- def __str__(self):
- """Returns the description."""
-- return self.out
-+ return ''.join(self.__out_list)
-
- def append(self, string):
-- self.out += six.text_type(string)
-+ self.__out_list.append(six.text_type(string))
diff --git a/contrib/python/PyHamcrest/py3/patches/02-add-additional-matcher.patch b/contrib/python/PyHamcrest/py3/patches/02-add-additional-matcher.patch
index 03effb4ad17..71d625bb19b 100644
--- a/contrib/python/PyHamcrest/py3/patches/02-add-additional-matcher.patch
+++ b/contrib/python/PyHamcrest/py3/patches/02-add-additional-matcher.patch
@@ -28,7 +28,7 @@ revision: 2945097
try:
- function()
+ self.actual_return_value = function()
- except Exception:
+ except BaseException:
self.actual = sys.exc_info()[1]
if isinstance(self.actual, self.expected):
@@ -68,7 +68,7 @@ revision: 2945097
+ description.append_text("\nAdditional exception matcher: ")
+ self.matcher.describe_mismatch(self.actual, description)
else:
- description.append_text('%s was raised instead' % type(self.actual))
+ description.append_text('%r of type %s was raised instead' % (self.actual, type(self.actual)))
-def raises(exception, pattern=None):
diff --git a/contrib/python/PyHamcrest/py3/patches/03-pr54.patch b/contrib/python/PyHamcrest/py3/patches/03-pr54.patch
new file mode 100644
index 00000000000..a4ff77bf863
--- /dev/null
+++ b/contrib/python/PyHamcrest/py3/patches/03-pr54.patch
@@ -0,0 +1,58 @@
+From 178dba673b36e36ca4257ecc8f0590b81334775c Mon Sep 17 00:00:00 2001
+Date: Mon, 11 May 2015 15:28:54 +0200
+Subject: [PATCH] Make instance_of work with tuple like isinstance and
+ unittest's assertIsInstance
+
+---
+ hamcrest/core/core/isinstanceof.py | 11 ++++++++---
+ hamcrest/core/helpers/wrap_matcher.py | 3 +++
+ tests/hamcrest_unit_test/core/isinstanceof_test.py | 3 +++
+ 3 files changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/hamcrest/core/core/isinstanceof.py b/hamcrest/core/core/isinstanceof.py
+index c96fdf31..f8eb4a2f 100644
+--- a/hamcrest/core/core/isinstanceof.py
++++ b/hamcrest/core/core/isinstanceof.py
+@@ -11,21 +11,26 @@ class IsInstanceOf(BaseMatcher):
+
+ def __init__(self, expected_type):
+ if not is_matchable_type(expected_type):
+- raise TypeError('IsInstanceOf requires type')
++ raise TypeError('IsInstanceOf requires type or a tuple of classes and types')
+ self.expected_type = expected_type
+
+ def _matches(self, item):
+ return isinstance(item, self.expected_type)
+
+ def describe_to(self, description):
++ try:
++ type_description = self.expected_type.__name__
++ except AttributeError:
++ type_description = "one of %s" % ",".join(str(e) for e in self.expected_type)
+ description.append_text('an instance of ') \
+- .append_text(self.expected_type.__name__)
++ .append_text(type_description)
+
+
+ def instance_of(atype):
+ """Matches if object is an instance of, or inherits from, a given type.
+
+- :param atype: The type to compare against as the expected type.
++ :param atype: The type to compare against as the expected type or a tuple
++ of types.
+
+ This matcher checks whether the evaluated object is an instance of
+ ``atype`` or an instance of any class that inherits from ``atype``.
+diff --git a/hamcrest/core/helpers/wrap_matcher.py b/hamcrest/core/helpers/wrap_matcher.py
+index 1ec9ab58..587ae4c6 100644
+--- a/hamcrest/core/helpers/wrap_matcher.py
++++ b/hamcrest/core/helpers/wrap_matcher.py
+@@ -28,4 +28,7 @@ def is_matchable_type(expected_type):
+ if isinstance(expected_type, six.class_types):
+ return True
+
++ if isinstance(expected_type, tuple) and all(map(is_matchable_type, expected_type)):
++ return True
++
+ return False
diff --git a/contrib/python/PyHamcrest/py3/patches/04-pr130.patch b/contrib/python/PyHamcrest/py3/patches/04-pr130.patch
new file mode 100644
index 00000000000..e95f47a8483
--- /dev/null
+++ b/contrib/python/PyHamcrest/py3/patches/04-pr130.patch
@@ -0,0 +1,11 @@
+--- contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py (index)
++++ contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py (working tree)
+@@ -25,7 +25,7 @@ class AllOf(BaseMatcher):
+ found_mismatch = True
+ if not self.describe_all_mismatches:
+ break
+- elif i < len(self.matchers) - 1:
++ elif i < len(self.matchers) - 1 and mismatch_description:
+ mismatch_description.append_text(' and ')
+ return not found_mismatch
+