HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/hamcrest/library/object/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/hamcrest/library/object/__pycache__/hasproperty.cpython-312.pyc
�

���e���v�ddlmZmZmZmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZddlmZdd	lmZd
ZdZdZed
�ZGd�dee�Zddededeeefdeefd�Zedeeeefdeefd��Zedeeeeeeffdeefd��Zededeefd��Zd�Zy)�)�Any�Mapping�TypeVar�Union�overload)�described_as)�anything)�BaseMatcher)�AllOf)�Description)�wrap_matcher)�Matcher)�StringDescriptionz
Chris RosezCopyright 2011 hamcrest.orgzBSD, see License.txt�Vc�`�eZdZdedeeddfd�Zdedefd�Z	de
ddfd	�Zded
e
ddfd�Zd�Z
y)
�IsObjectWithProperty�
property_name�
value_matcher�returnNc� �||_||_y�N)rr)�selfrrs   �E/usr/lib/python3/dist-packages/hamcrest/library/object/hasproperty.py�__init__zIsObjectWithProperty.__init__s��*���*����itemc��|�yt||j�syt||j�}|jj	|�S)NF)�hasattrr�getattrr�matches)rr�values   r�_matcheszIsObjectWithProperty._matchessF���<���t�T�/�/�0����d�0�0�1���!�!�)�)�%�0�0r�descriptionc��|jd�j|j�jd�j|j�y)Nzan object with a property 'z' matching )�append_textr�append_description_ofr)rr#s  r�describe_toz IsObjectWithProperty.describe_to"s@����� =�>�J�J����	
�
�+�m�
$�%:�%:�4�;M�;M�%Nr�mismatch_descriptionc��|�|jd�yt||j�sI|j|�jd�j|j�jd�y|jd�j|j�jd�t	||j�}|j
j
||�y)Nzwas Nonez did not have the z	 propertyz	property � )r%rrr&rr�describe_mismatch)rrr(r!s    rr+z&IsObjectWithProperty.describe_mismatch's����<� �,�,�Z�8���t�T�/�/�0� �6�6�t�<�H�H�$�
�#�#�D�$6�$6�7���K�8P���(�(��5�K�K����	
�
�+�c�
���d�0�0�1�����,�,�U�4H�Irc�N�t�}|j|�t|�Sr)rr'�str)r�ds  r�__str__zIsObjectWithProperty.__str__8s!�����������1�v�
r)�__name__�
__module__�__qualname__r-rrr�object�boolr"rr'r+r/�rrrrsm��+�c�+�'�!�*�+��+�1�V�1��1�O�{�O�t�O�
J�f�J�K�J�TX�J�"rrN�name�matchrc�D�|�
t�}t|t|��S)a�Matches if object has a property with a given name whose value satisfies
    a given matcher.

    :param name: The name of the property.
    :param match: Optional matcher to satisfy.

    This matcher determines if the evaluated object has a property with a given
    name. If no such property is found, ``has_property`` is not satisfied.

    If the property is found, its value is passed to a given matcher for
    evaluation. If the ``match`` argument is not a matcher, it is implicitly
    wrapped in an :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to
    check for equality.

    If the ``match`` argument is not provided, the
    :py:func:`~hamcrest.core.core.isanything.anything` matcher is used so that
    ``has_property`` is satisfied if a matching property is found.

    Examples::

        has_property('name', starts_with('J'))
        has_property('name', 'Jon')
        has_property('name')

    )r	r�
wrap_shortcut)r6r7s  r�has_propertyr:>s"��6
�}��
����m�E�&:�;�;r�keys_valuematchersc��yrr5�r;s r�has_propertiesr>`���rc��yrr5r=s rr>r>fr?rc��yrr5r=s rr>r>lr?rc
���t|�dk(r-	|dj�}|D]}t||�||<�n]t|�dzrt	d��i}tt
t|�dz��D]}t|d|zdz�||d|z<�!|j�D]\}}t|�||<�t|�dkDr�t�jd�}tt|j���D]Z\}\}}	|j|�jd�j|	�|t|�dz
ks�J|jd��\tt|�tt|j��D��	cgc]\}}	t!||	���c}	}d	d
d���S|j#�\}}	t!||	�S#t$rt	d��wxYwcc}	}w)aXMatches if an object has properties satisfying all of a dictionary
    of string property names and corresponding value matchers.

    :param matcher_dict: A dictionary mapping keys to associated value matchers,
        or to expected values for
        :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    Note that the keys must be actual keys, not matchers. Any value argument
    that is not a matcher is implicitly wrapped in an
    :py:func:`~hamcrest.core.core.isequal.equal_to` matcher to check for
    equality.

    Examples::

        has_properties({'foo':equal_to(1), 'bar':equal_to(2)})
        has_properties({'foo':1, 'bar':2})

    ``has_properties`` also accepts a list of keyword arguments:

    .. function:: has_properties(keyword1=value_matcher1[, keyword2=value_matcher2[, ...]])

    :param keyword1: A keyword to look up.
    :param valueMatcher1: The matcher to satisfy for the value, or an expected
        value for :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    Examples::

        has_properties(foo=equal_to(1), bar=equal_to(2))
        has_properties(foo=1, bar=2)

    Finally, ``has_properties`` also accepts a list of alternating keys and their
    value matchers:

    .. function:: has_properties(key1, value_matcher1[, ...])

    :param key1: A key (not a matcher) to look up.
    :param valueMatcher1: The matcher to satisfy for the value, or an expected
        value for :py:func:`~hamcrest.core.core.isequal.equal_to` matching.

    Examples::

        has_properties('foo', equal_to(1), 'bar', equal_to(2))
        has_properties('foo', 1, 'bar', 2)

    �rzHsingle-argument calls to has_properties must pass a dict as the argument�z'has_properties requires key-value pairszan object with properties z
 matching z and TF)�describe_all_mismatches�describe_matcher_in_mismatch)�len�copyr9�AttributeError�
ValueError�range�int�itemsrr%�	enumerate�sortedr&rr-rr:�popitem)
r;�kv_args�	base_dict�key�indexr!r#�ir�property_value_matchers
          rr>r>qs��\���!�#�	�*�1�-�2�2�4�I� �
?��!.�y��~�!>�	�#��
?��!�"�Q�&��F�G�G��	��3�s�#5�6��:�;�<�	�E�7D�"�1�u�9�q�=�1�8�I�(��U��3�4�	�
�m�m�o�.�
��U�&�u�-�	�#��.��9�~���'�)�5�5�6R�S��:C�F�9�?�?�K\�D]�:^�	1�6�A�6�
�5��-�-�m�<�H�H��
�#�#�$:�;��3�y�>�A�%�%��'�'��0�	1������BH�	���HY�AZ��=�
�'=�!��0F�G��)-�-2�

�

�
	
�1:�0A�0A�0C�-�
�-��M�+A�B�B��M�	��Z��
�	��8s�+G�G/�G,r) �typingrrrrr�hamcrestr�
hamcrest.corer	�hamcrest.core.base_matcherr
�hamcrest.core.core.allofr�hamcrest.core.descriptionr�"hamcrest.core.helpers.wrap_matcherr
r9�hamcrest.core.matcherr� hamcrest.core.string_descriptionr�
__author__�
__copyright__�__license__rr3rr-r:r>r5rr�<module>rcs��9�9�!�"�2�*�1�L�)�>�
�
�-�
�$���C�L��(�;�v�.�(�V<�s�<�5��w�q�z�1�)<�#=�<��QW��<�D
���w�q�z�1�}�)=��'�#�,��
��

��w�s�E�'�!�*�a�-�4H�/H�'I��g�VY�l��
��

��������
��YCr