summaryrefslogtreecommitdiffstats
path: root/contrib/python/PyHamcrest/py3
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
parent3f573d26f7b92eb46dfff503d68a5897c96386ce (diff)
Intermediate changes
commit_hash:6b9536340f4f2533b62d862c22cbfeb121d4fa3f
Diffstat (limited to 'contrib/python/PyHamcrest/py3')
-rw-r--r--contrib/python/PyHamcrest/py3/.dist-info/METADATA90
-rw-r--r--contrib/python/PyHamcrest/py3/README.rst78
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/__init__.py4
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/assert_that.py3
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/base_description.py3
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py20
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/core/raises.py7
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/helpers/ismock.py15
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/helpers/wrap_matcher.py4
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/selfdescribingvalue.py2
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py13
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/library/__init__.py1
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/library/collection/__init__.py2
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/library/collection/issequence_containinginorder.py10
-rw-r--r--contrib/python/PyHamcrest/py3/hamcrest/library/object/hasproperty.py39
-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
-rw-r--r--contrib/python/PyHamcrest/py3/ya.make4
20 files changed, 283 insertions, 113 deletions
diff --git a/contrib/python/PyHamcrest/py3/.dist-info/METADATA b/contrib/python/PyHamcrest/py3/.dist-info/METADATA
index e8ca1e0f931..071bd13e3ad 100644
--- a/contrib/python/PyHamcrest/py3/.dist-info/METADATA
+++ b/contrib/python/PyHamcrest/py3/.dist-info/METADATA
@@ -1,12 +1,12 @@
-Metadata-Version: 2.0
+Metadata-Version: 2.1
Name: PyHamcrest
-Version: 1.9.0
+Version: 1.10.1
Summary: Hamcrest framework for matcher objects
Home-page: https://github.com/hamcrest/PyHamcrest
Author: Chris Rose
Author-email: [email protected]
License: New BSD
-Download-URL: http://pypi.python.org/packages/source/P/PyHamcrest/PyHamcrest-1.9.0.tar.gz
+Download-URL: http://pypi.python.org/packages/source/P/PyHamcrest/PyHamcrest-1.10.1.tar.gz
Keywords: hamcrest matchers pyunit unit test testing unittest unittesting
Platform: All
Classifier: Development Status :: 5 - Production/Stable
@@ -18,7 +18,9 @@ Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: Jython
Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -26,28 +28,30 @@ Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Provides: hamcrest
-Requires-Dist: setuptools
+Requires-Python: >=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4
Requires-Dist: six
PyHamcrest
==========
-| |docs| |travis| |coveralls| |landscape| |scrutinizer| |codeclimate|
+| |docs| |travis| |coveralls| |landscape| |scrutinizer|
| |version| |downloads| |wheel| |supported-versions| |supported-implementations|
+| |GitHub forks| |GitHub stars| |GitHub watchers| |GitHub contributors| |Lines of Code|
+| |GitHub issues| |GitHub issues-closed| |GitHub pull-requests| |GitHub pull-requests closed|
-.. |docs| image:: https://readthedocs.org/projects/pyhamcrest/badge/?style=flat
+.. |docs| image:: https://readthedocs.org/projects/pyhamcrest/badge/
:target: https://pyhamcrest.readthedocs.org/
:alt: Documentation Status
-.. |travis| image:: http://img.shields.io/travis/hamcrest/PyHamcrest/master.png?style=flat
+.. |travis| image:: http://img.shields.io/travis/hamcrest/PyHamcrest/master.svg
:alt: Travis-CI Build Status
:target: https://travis-ci.org/hamcrest/PyHamcrest
-.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hamcrest/PyHamcrest?branch=master
+.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hamcrest/PyHamcrest?branch=master&svg=true
:alt: AppVeyor Build Status
:target: https://ci.appveyor.com/project/hamcrest/PyHamcrest
-.. |coveralls| image:: http://img.shields.io/coveralls/hamcrest/PyHamcrest/master.png?style=flat
+.. |coveralls| image:: http://img.shields.io/coveralls/hamcrest/PyHamcrest/master.svg?style=flat
:alt: Coverage Status
:target: https://coveralls.io/r/hamcrest/PyHamcrest
@@ -55,31 +59,63 @@ PyHamcrest
:target: https://landscape.io/github/hamcrest/PyHamcrest/master
:alt: Code Quality Status
-.. |codeclimate| image:: https://codeclimate.com/github/hamcrest/PyHamcrest/badges/gpa.svg
- :target: https://codeclimate.com/github/hamcrest/PyHamcrest
- :alt: Code Climate
-
-.. |version| image:: http://img.shields.io/pypi/v/PyHamcrest.png?style=flat
+.. |version| image:: http://img.shields.io/pypi/v/PyHamcrest.svg?style=flat
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |downloads| image:: http://img.shields.io/pypi/dm/PyHamcrest.png?style=flat
+.. |downloads| image:: http://img.shields.io/pypi/dm/PyHamcrest.svg?style=flat
:alt: PyPI Package monthly downloads
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |wheel| image:: https://pypip.in/wheel/PyHamcrest/badge.png?style=flat
+.. |wheel| image:: https://pypip.in/wheel/PyHamcrest/badge.svg?style=flat
:alt: PyPI Wheel
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |supported-versions| image:: https://pypip.in/py_versions/PyHamcrest/badge.png?style=flat
+.. |supported-versions| image:: https://pypip.in/py_versions/PyHamcrest/badge.svg?style=flat
:alt: Supported versions
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |supported-implementations| image:: https://pypip.in/implementation/PyHamcrest/badge.png?style=flat
- :alt: Supported imlementations
+.. |GitHub forks| image:: https://img.shields.io/github/forks/hamcrest/PyHamcrest.svg?label=Fork&logo=github
+ :alt: GitHub forks
+ :target: https://github.com/hamcrest/PyHamcrest/network/members
+
+.. |GitHub stars| image:: https://img.shields.io/github/stars/hamcrest/PyHamcrest.svg?label=Star&logo=github
+ :alt: GitHub stars
+ :target: https://github.com/hamcrest/PyHamcrest/stargazers/
+
+.. |GitHub watchers| image:: https://img.shields.io/github/watchers/hamcrest/PyHamcrest.svg?label=Watch&logo=github
+ :alt: GitHub watchers
+ :target: https://github.com/hamcrest/PyHamcrest/watchers/
+
+.. |GitHub contributors| image:: https://img.shields.io/github/contributors/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub contributors
+ :target: https://github.com/hamcrest/PyHamcrest/graphs/contributors/
+
+.. |GitHub issues| image:: https://img.shields.io/github/issues/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub issues
+ :target: https://github.com/hamcrest/PyHamcrest/issues/
+
+.. |GitHub issues-closed| image:: https://img.shields.io/github/issues-closed/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub issues-closed
+ :target: https://github.com/hamcrest/PyHamcrest/issues?q=is%3Aissue+is%3Aclosed
+
+.. |GitHub pull-requests| image:: https://img.shields.io/github/issues-pr/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub pull-requests
+ :target: https://github.com/hamcrest/PyHamcrest/pulls
+
+.. |GitHub pull-requests closed| image:: https://img.shields.io/github/issues-pr-closed/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub pull-requests closed
+ :target: https://github.com/hamcrest/PyHamcrest/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed
+
+.. |Lines of Code| image:: https://tokei.rs/b1/github/hamcrest/PyHamcrest
+ :alt: Lines of Code
+ :target: https://github.com/hamcrest/PyHamcrest
+
+.. |supported-implementations| image:: https://pypip.in/implementation/PyHamcrest/badge.svg?style=flat
+ :alt: Supported implementations
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |scrutinizer| image:: https://img.shields.io/scrutinizer/g/hamcrest/PyHamcrest/master.png?style=flat
+.. |scrutinizer| image:: https://img.shields.io/scrutinizer/g/hamcrest/PyHamcrest/master.svg?style=flat
:alt: Scrtinizer Status
:target: https://scrutinizer-ci.com/g/hamcrest/PyHamcrest/
@@ -194,7 +230,7 @@ PyHamcrest comes with a library of useful matchers:
* ``all_of`` - ``and`` together all matchers
* ``any_of`` - ``or`` together all matchers
* ``anything`` - match anything, useful in composite matchers when you don't care about a particular value
- * ``is_not`` - negate the matcher
+ * ``is_not``, ``not_`` - negate the matcher
* Sequence
@@ -215,7 +251,7 @@ PyHamcrest comes with a library of useful matchers:
* Decorator
- * ``calling`` - wrap a callable in a deffered object, for subsequent matching on calling behaviour
+ * ``calling`` - wrap a callable in a deferred object, for subsequent matching on calling behaviour
* ``raises`` - Ensure that a deferred callable raises as expected
* ``described_as`` - give the matcher a custom failure description
* ``is_`` - decorator to improve readability - see `Syntactic sugar` below
@@ -269,7 +305,7 @@ This is the test we want to write:
.. code:: python
def testDateIsOnASaturday(self):
- d = datetime.date(2008, 04, 26)
+ d = datetime.date(2008, 4, 26)
assert_that(d, is_(on_a_saturday()))
And here's the implementation:
@@ -306,7 +342,7 @@ failure message looks:
.. code:: python
- assert_that(datetime.date(2008, 04, 06), is_(on_a_saturday()))
+ assert_that(datetime.date(2008, 4, 6), is_(on_a_saturday()))
fails with the message::
@@ -325,7 +361,7 @@ could use it in our test by importing the factory function ``on_a_saturday``:
class DateTest(unittest.TestCase):
def testDateIsOnASaturday(self):
- d = datetime.date(2008, 04, 26)
+ d = datetime.date(2008, 4, 26)
assert_that(d, is_(on_a_saturday()))
if __name__ == '__main__':
@@ -345,7 +381,7 @@ More resources
* Sources_
* Hamcrest_
-.. _Documentation: http://readthedocs.org/docs/pyhamcrest/en/V1.8.2/
+.. _Documentation: https://pyhamcrest.readthedocs.io/
.. _Package: http://pypi.python.org/pypi/PyHamcrest
.. _Sources: https://github.com/hamcrest/PyHamcrest
.. _Hamcrest: http://hamcrest.org
diff --git a/contrib/python/PyHamcrest/py3/README.rst b/contrib/python/PyHamcrest/py3/README.rst
index 8ef46bbb916..7bae39eea29 100644
--- a/contrib/python/PyHamcrest/py3/README.rst
+++ b/contrib/python/PyHamcrest/py3/README.rst
@@ -1,22 +1,24 @@
PyHamcrest
==========
-| |docs| |travis| |coveralls| |landscape| |scrutinizer| |codeclimate|
+| |docs| |travis| |coveralls| |landscape| |scrutinizer|
| |version| |downloads| |wheel| |supported-versions| |supported-implementations|
+| |GitHub forks| |GitHub stars| |GitHub watchers| |GitHub contributors| |Lines of Code|
+| |GitHub issues| |GitHub issues-closed| |GitHub pull-requests| |GitHub pull-requests closed|
-.. |docs| image:: https://readthedocs.org/projects/pyhamcrest/badge/?style=flat
+.. |docs| image:: https://readthedocs.org/projects/pyhamcrest/badge/
:target: https://pyhamcrest.readthedocs.org/
:alt: Documentation Status
-.. |travis| image:: http://img.shields.io/travis/hamcrest/PyHamcrest/master.png?style=flat
+.. |travis| image:: http://img.shields.io/travis/hamcrest/PyHamcrest/master.svg
:alt: Travis-CI Build Status
:target: https://travis-ci.org/hamcrest/PyHamcrest
-.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hamcrest/PyHamcrest?branch=master
+.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/hamcrest/PyHamcrest?branch=master&svg=true
:alt: AppVeyor Build Status
:target: https://ci.appveyor.com/project/hamcrest/PyHamcrest
-.. |coveralls| image:: http://img.shields.io/coveralls/hamcrest/PyHamcrest/master.png?style=flat
+.. |coveralls| image:: http://img.shields.io/coveralls/hamcrest/PyHamcrest/master.svg?style=flat
:alt: Coverage Status
:target: https://coveralls.io/r/hamcrest/PyHamcrest
@@ -24,31 +26,63 @@ PyHamcrest
:target: https://landscape.io/github/hamcrest/PyHamcrest/master
:alt: Code Quality Status
-.. |codeclimate| image:: https://codeclimate.com/github/hamcrest/PyHamcrest/badges/gpa.svg
- :target: https://codeclimate.com/github/hamcrest/PyHamcrest
- :alt: Code Climate
-
-.. |version| image:: http://img.shields.io/pypi/v/PyHamcrest.png?style=flat
+.. |version| image:: http://img.shields.io/pypi/v/PyHamcrest.svg?style=flat
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |downloads| image:: http://img.shields.io/pypi/dm/PyHamcrest.png?style=flat
+.. |downloads| image:: http://img.shields.io/pypi/dm/PyHamcrest.svg?style=flat
:alt: PyPI Package monthly downloads
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |wheel| image:: https://pypip.in/wheel/PyHamcrest/badge.png?style=flat
+.. |wheel| image:: https://pypip.in/wheel/PyHamcrest/badge.svg?style=flat
:alt: PyPI Wheel
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |supported-versions| image:: https://pypip.in/py_versions/PyHamcrest/badge.png?style=flat
+.. |supported-versions| image:: https://pypip.in/py_versions/PyHamcrest/badge.svg?style=flat
:alt: Supported versions
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |supported-implementations| image:: https://pypip.in/implementation/PyHamcrest/badge.png?style=flat
- :alt: Supported imlementations
+.. |GitHub forks| image:: https://img.shields.io/github/forks/hamcrest/PyHamcrest.svg?label=Fork&logo=github
+ :alt: GitHub forks
+ :target: https://github.com/hamcrest/PyHamcrest/network/members
+
+.. |GitHub stars| image:: https://img.shields.io/github/stars/hamcrest/PyHamcrest.svg?label=Star&logo=github
+ :alt: GitHub stars
+ :target: https://github.com/hamcrest/PyHamcrest/stargazers/
+
+.. |GitHub watchers| image:: https://img.shields.io/github/watchers/hamcrest/PyHamcrest.svg?label=Watch&logo=github
+ :alt: GitHub watchers
+ :target: https://github.com/hamcrest/PyHamcrest/watchers/
+
+.. |GitHub contributors| image:: https://img.shields.io/github/contributors/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub contributors
+ :target: https://github.com/hamcrest/PyHamcrest/graphs/contributors/
+
+.. |GitHub issues| image:: https://img.shields.io/github/issues/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub issues
+ :target: https://github.com/hamcrest/PyHamcrest/issues/
+
+.. |GitHub issues-closed| image:: https://img.shields.io/github/issues-closed/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub issues-closed
+ :target: https://github.com/hamcrest/PyHamcrest/issues?q=is%3Aissue+is%3Aclosed
+
+.. |GitHub pull-requests| image:: https://img.shields.io/github/issues-pr/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub pull-requests
+ :target: https://github.com/hamcrest/PyHamcrest/pulls
+
+.. |GitHub pull-requests closed| image:: https://img.shields.io/github/issues-pr-closed/hamcrest/PyHamcrest.svg?logo=github
+ :alt: GitHub pull-requests closed
+ :target: https://github.com/hamcrest/PyHamcrest/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed
+
+.. |Lines of Code| image:: https://tokei.rs/b1/github/hamcrest/PyHamcrest
+ :alt: Lines of Code
+ :target: https://github.com/hamcrest/PyHamcrest
+
+.. |supported-implementations| image:: https://pypip.in/implementation/PyHamcrest/badge.svg?style=flat
+ :alt: Supported implementations
:target: https://pypi.python.org/pypi/PyHamcrest
-.. |scrutinizer| image:: https://img.shields.io/scrutinizer/g/hamcrest/PyHamcrest/master.png?style=flat
+.. |scrutinizer| image:: https://img.shields.io/scrutinizer/g/hamcrest/PyHamcrest/master.svg?style=flat
:alt: Scrtinizer Status
:target: https://scrutinizer-ci.com/g/hamcrest/PyHamcrest/
@@ -163,7 +197,7 @@ PyHamcrest comes with a library of useful matchers:
* ``all_of`` - ``and`` together all matchers
* ``any_of`` - ``or`` together all matchers
* ``anything`` - match anything, useful in composite matchers when you don't care about a particular value
- * ``is_not`` - negate the matcher
+ * ``is_not``, ``not_`` - negate the matcher
* Sequence
@@ -184,7 +218,7 @@ PyHamcrest comes with a library of useful matchers:
* Decorator
- * ``calling`` - wrap a callable in a deffered object, for subsequent matching on calling behaviour
+ * ``calling`` - wrap a callable in a deferred object, for subsequent matching on calling behaviour
* ``raises`` - Ensure that a deferred callable raises as expected
* ``described_as`` - give the matcher a custom failure description
* ``is_`` - decorator to improve readability - see `Syntactic sugar` below
@@ -238,7 +272,7 @@ This is the test we want to write:
.. code:: python
def testDateIsOnASaturday(self):
- d = datetime.date(2008, 04, 26)
+ d = datetime.date(2008, 4, 26)
assert_that(d, is_(on_a_saturday()))
And here's the implementation:
@@ -275,7 +309,7 @@ failure message looks:
.. code:: python
- assert_that(datetime.date(2008, 04, 06), is_(on_a_saturday()))
+ assert_that(datetime.date(2008, 4, 6), is_(on_a_saturday()))
fails with the message::
@@ -294,7 +328,7 @@ could use it in our test by importing the factory function ``on_a_saturday``:
class DateTest(unittest.TestCase):
def testDateIsOnASaturday(self):
- d = datetime.date(2008, 04, 26)
+ d = datetime.date(2008, 4, 26)
assert_that(d, is_(on_a_saturday()))
if __name__ == '__main__':
@@ -314,7 +348,7 @@ More resources
* Sources_
* Hamcrest_
-.. _Documentation: http://readthedocs.org/docs/pyhamcrest/en/V1.8.2/
+.. _Documentation: https://pyhamcrest.readthedocs.io/
.. _Package: http://pypi.python.org/pypi/PyHamcrest
.. _Sources: https://github.com/hamcrest/PyHamcrest
.. _Hamcrest: http://hamcrest.org
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/__init__.py b/contrib/python/PyHamcrest/py3/hamcrest/__init__.py
index 3a751d44f62..f45b032075d 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/__init__.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/__init__.py
@@ -2,7 +2,7 @@ from __future__ import absolute_import
from hamcrest.core import *
from hamcrest.library import *
-__version__ = "1.9.0"
+__version__ = "1.10.1"
__author__ = "Chris Rose"
-__copyright__ = "Copyright 2015 hamcrest.org"
+__copyright__ = "Copyright 2020 hamcrest.org"
__license__ = "BSD, see License.txt"
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/assert_that.py b/contrib/python/PyHamcrest/py3/hamcrest/core/assert_that.py
index b38bc243ca0..8c36ceab764 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/assert_that.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/assert_that.py
@@ -1,4 +1,5 @@
from __future__ import absolute_import
+import warnings
from hamcrest.core.matcher import Matcher
from hamcrest.core.string_description import StringDescription
@@ -42,6 +43,8 @@ def assert_that(arg1, arg2=None, arg3=''):
if isinstance(arg2, Matcher):
_assert_match(actual=arg1, matcher=arg2, reason=arg3)
else:
+ if isinstance(arg1, Matcher):
+ warnings.warn("arg1 should be boolean, but was {}".format(type(arg1)))
_assert_bool(assertion=arg1, reason=arg2)
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/base_description.py b/contrib/python/PyHamcrest/py3/hamcrest/core/base_description.py
index 8c7c51364de..18b3ee9ee53 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/base_description.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/base_description.py
@@ -9,6 +9,7 @@ import six
from hamcrest.core.description import Description
from hamcrest.core.selfdescribingvalue import SelfDescribingValue
from hamcrest.core.helpers.hasmethod import hasmethod
+from hamcrest.core.helpers.ismock import ismock
class BaseDescription(Description):
"""Base class for all :py:class:`~hamcrest.core.description.Description`
@@ -21,7 +22,7 @@ class BaseDescription(Description):
return self
def append_description_of(self, value):
- if hasmethod(value, 'describe_to'):
+ if not ismock(value) and hasmethod(value, 'describe_to'):
value.describe_to(self)
elif six.PY3 and isinstance(value, six.text_type):
self.append(repr(value))
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py b/contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py
index 35c5d0bfeb6..e051f6abb30 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/core/allof.py
@@ -8,18 +8,26 @@ __license__ = "BSD, see License.txt"
class AllOf(BaseMatcher):
- def __init__(self, *matchers):
+ def __init__(self, *matchers, **kwargs):
self.matchers = matchers
+ self.describe_matcher_in_mismatch = kwargs.pop('describe_matcher_in_mismatch', True) # No keyword-only args in 2.7 :-(
+ self.describe_all_mismatches = kwargs.pop('describe_all_mismatches', False)
def matches(self, item, mismatch_description=None):
- for matcher in self.matchers:
+ found_mismatch = False
+ for i, matcher in enumerate(self.matchers):
if not matcher.matches(item):
if mismatch_description:
- mismatch_description.append_description_of(matcher) \
- .append_text(' ')
+ if self.describe_matcher_in_mismatch:
+ mismatch_description.append_description_of(matcher) \
+ .append_text(' ')
matcher.describe_mismatch(item, mismatch_description)
- return False
- return True
+ found_mismatch = True
+ if not self.describe_all_mismatches:
+ break
+ elif i < len(self.matchers) - 1 and mismatch_description:
+ mismatch_description.append_text(' and ')
+ return not found_mismatch
def describe_mismatch(self, item, mismatch_description):
self.matches(item, mismatch_description)
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/core/raises.py b/contrib/python/PyHamcrest/py3/hamcrest/core/core/raises.py
index 16614cc1b77..699a1ccc91d 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/core/raises.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/core/raises.py
@@ -2,6 +2,7 @@ from weakref import ref
import re
import sys
from hamcrest.core.base_matcher import BaseMatcher
+from hamcrest.core.helpers.wrap_matcher import wrap_matcher
from hamcrest.core.compat import is_callable
__author__ = "Per Fagrell"
@@ -29,7 +30,7 @@ class Raises(BaseMatcher):
self.actual = None
try:
self.actual_return_value = function()
- except Exception:
+ except BaseException:
self.actual = sys.exc_info()[1]
if isinstance(self.actual, self.expected):
@@ -69,7 +70,7 @@ class Raises(BaseMatcher):
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, matcher=None):
@@ -98,7 +99,7 @@ class DeferredCallable(object):
self.kwargs = {}
def __call__(self):
- return self.func(*self.args, **self.kwargs)
+ self.func(*self.args, **self.kwargs)
def with_args(self, *args, **kwargs):
self.args = args
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/ismock.py b/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/ismock.py
new file mode 100644
index 00000000000..318e0d4f9cb
--- /dev/null
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/ismock.py
@@ -0,0 +1,15 @@
+MOCKTYPES = ()
+try:
+ from mock import Mock
+ MOCKTYPES += (Mock,)
+except ImportError:
+ pass
+try:
+ from unittest.mock import Mock
+ MOCKTYPES += (Mock,)
+except ImportError:
+ pass
+
+
+def ismock(obj):
+ return isinstance(obj, MOCKTYPES)
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/wrap_matcher.py b/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/wrap_matcher.py
index a5b506fb395..587ae4c6101 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/wrap_matcher.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/helpers/wrap_matcher.py
@@ -28,9 +28,7 @@ def is_matchable_type(expected_type):
if isinstance(expected_type, six.class_types):
return True
- if isinstance(expected_type, tuple) and \
- expected_type and \
- all(map(is_matchable_type, expected_type)):
+ if isinstance(expected_type, tuple) and all(map(is_matchable_type, expected_type)):
return True
return False
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/selfdescribingvalue.py b/contrib/python/PyHamcrest/py3/hamcrest/core/selfdescribingvalue.py
index dfa4e3a20e4..7f471e04f2d 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/selfdescribingvalue.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/selfdescribingvalue.py
@@ -24,4 +24,4 @@ class SelfDescribingValue(SelfDescribing):
def describe_to(self, description):
"""Generates a description of the value."""
- description.append_value(self.value)
+ description.append_description_of(self.value)
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py b/contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py
index 7626bf91e8e..172dfb4ff22 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/core/string_description.py
@@ -24,14 +24,21 @@ def tostring(selfdescribing):
class StringDescription(BaseDescription):
"""A :py:class:`~hamcrest.core.description.Description` that is stored as a
string.
+
"""
def __init__(self):
- self.__out_list = []
+ self.out = ''
def __str__(self):
"""Returns the description."""
- return ''.join(self.__out_list)
+ return self.out
def append(self, string):
- self.__out_list.append(six.text_type(string))
+ if six.PY3:
+ self.out += str(string)
+ else:
+ if isinstance(string, unicode):
+ self.out += string
+ else:
+ self.out += unicode(string, errors="ignore")
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/library/__init__.py b/contrib/python/PyHamcrest/py3/hamcrest/library/__init__.py
index a5a7963521f..d5f909c9216 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/library/__init__.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/library/__init__.py
@@ -23,6 +23,7 @@ __all__ = [
'has_items',
'contains_inanyorder',
'contains',
+ 'contains_exactly',
'only_contains',
'match_equality',
'matches_regexp',
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/library/collection/__init__.py b/contrib/python/PyHamcrest/py3/hamcrest/library/collection/__init__.py
index 2f899877883..f910e973259 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/library/collection/__init__.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/library/collection/__init__.py
@@ -7,7 +7,7 @@ from .isdict_containingvalue import has_value
from .isin import is_in
from .issequence_containing import has_item, has_items
from .issequence_containinginanyorder import contains_inanyorder
-from .issequence_containinginorder import contains
+from .issequence_containinginorder import contains, contains_exactly
from .issequence_onlycontaining import only_contains
from .is_empty import empty
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/library/collection/issequence_containinginorder.py b/contrib/python/PyHamcrest/py3/hamcrest/library/collection/issequence_containinginorder.py
index 3fd91a6c925..7c37b328b61 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/library/collection/issequence_containinginorder.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/library/collection/issequence_containinginorder.py
@@ -1,3 +1,5 @@
+import warnings
+
__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"
@@ -69,7 +71,7 @@ class IsSequenceContainingInOrder(BaseMatcher):
.append_list('[', ', ', ']', self.matchers)
-def contains(*items):
+def contains_exactly(*items):
"""Matches if sequence's elements satisfy a given list of matchers, in order.
:param match1,...: A comma-separated list of matchers.
@@ -86,3 +88,9 @@ def contains(*items):
for item in items:
matchers.append(wrap_matcher(item))
return IsSequenceContainingInOrder(matchers)
+
+
+def contains(*items):
+ """Deprecated - use contains_exactly(*items)"""
+ warnings.warn("deprecated - use contains_exactly(*items)", DeprecationWarning)
+ return contains_exactly(*items)
diff --git a/contrib/python/PyHamcrest/py3/hamcrest/library/object/hasproperty.py b/contrib/python/PyHamcrest/py3/hamcrest/library/object/hasproperty.py
index d2536d69f40..18f591f1ed6 100644
--- a/contrib/python/PyHamcrest/py3/hamcrest/library/object/hasproperty.py
+++ b/contrib/python/PyHamcrest/py3/hamcrest/library/object/hasproperty.py
@@ -1,9 +1,9 @@
-from hamcrest.core.base_matcher import BaseMatcher
+from hamcrest import described_as
from hamcrest.core import anything
-from hamcrest.core.core.allof import all_of
-from hamcrest.core.string_description import StringDescription
-from hamcrest.core.helpers.hasmethod import hasmethod
+from hamcrest.core.base_matcher import BaseMatcher
+from hamcrest.core.core.allof import AllOf
from hamcrest.core.helpers.wrap_matcher import wrap_matcher as wrap_shortcut
+from hamcrest.core.string_description import StringDescription
__author__ = "Chris Rose"
__copyright__ = "Copyright 2011 hamcrest.org"
@@ -38,13 +38,15 @@ class IsObjectWithProperty(BaseMatcher):
return
if not hasattr(item, self.property_name):
- mismatch_description.append_value(item) \
- .append_text(' did not have the ') \
- .append_value(self.property_name) \
- .append_text(' property')
+ mismatch_description.append_description_of(item) \
+ .append_text(' did not have the ') \
+ .append_description_of(self.property_name) \
+ .append_text(' property')
return
- mismatch_description.append_text('property ').append_value(self.property_name).append_text(' ')
+ mismatch_description.append_text('property ') \
+ .append_description_of(self.property_name) \
+ .append_text(' ')
value = getattr(item, self.property_name)
self.value_matcher.describe_mismatch(value, mismatch_description)
@@ -150,5 +152,20 @@ def has_properties(*keys_valuematchers, **kv_args):
for key, value in kv_args.items():
base_dict[key] = wrap_shortcut(value)
- return all_of(*[has_property(property_name, property_value_matcher) for \
- property_name, property_value_matcher in base_dict.items()])
+ if len(base_dict) > 1:
+ description = StringDescription().append_text('an object with properties ')
+ for i, (property_name, property_value_matcher) in enumerate(sorted(base_dict.items())):
+ description.append_value(property_name).append_text(' matching ').append_description_of(
+ property_value_matcher)
+ if i < len(base_dict) - 1:
+ description.append_text(' and ')
+
+ return described_as(str(description),
+ AllOf(*[has_property(property_name, property_value_matcher)
+ for property_name, property_value_matcher
+ in sorted(base_dict.items())],
+ describe_all_mismatches=True,
+ describe_matcher_in_mismatch=False))
+ else:
+ property_name, property_value_matcher = base_dict.popitem()
+ return has_property(property_name, property_value_matcher)
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
+
diff --git a/contrib/python/PyHamcrest/py3/ya.make b/contrib/python/PyHamcrest/py3/ya.make
index 54060504493..e036d7b9124 100644
--- a/contrib/python/PyHamcrest/py3/ya.make
+++ b/contrib/python/PyHamcrest/py3/ya.make
@@ -2,12 +2,11 @@
PY3_LIBRARY()
-VERSION(1.9.0)
+VERSION(1.10.1)
LICENSE(BSD-3-Clause)
PEERDIR(
- contrib/python/setuptools
contrib/python/six
)
@@ -36,6 +35,7 @@ PY_SRCS(
hamcrest/core/description.py
hamcrest/core/helpers/__init__.py
hamcrest/core/helpers/hasmethod.py
+ hamcrest/core/helpers/ismock.py
hamcrest/core/helpers/wrap_matcher.py
hamcrest/core/matcher.py
hamcrest/core/selfdescribing.py