File: //lib/python3/dist-packages/hamcrest/library/object/__pycache__/hasproperty.cpython-38.pyc
U
�b�Vl � @ sz d dl mZ d dlmZ d dlmZ d dlmZ d dlm Z d dl
mZ dZ
dZd ZG d
d� de�Zdd
d�Zdd� ZdS )� )�BaseMatcher)�anything)�all_of)�StringDescription)� hasmethod)�wrap_matcherz
Chris RosezCopyright 2011 hamcrest.orgzBSD, see License.txtc @ s4 e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� ZdS )�IsObjectWithPropertyc C s || _ || _d S �N)�
property_name�
value_matcher)�selfr
r � r
�E/usr/lib/python3/dist-packages/hamcrest/library/object/hasproperty.py�__init__ s zIsObjectWithProperty.__init__c C s4 |d krdS t || j�sdS t|| j�}| j�|�S )NF)�hasattrr
�getattrr Zmatches)r �o�valuer
r
r �_matches s zIsObjectWithProperty._matchesc C s$ |� d�� | j�� d��| j� d S )Nzan object with a property 'z' matching )�append_textr
Zappend_description_ofr )r Zdescriptionr
r
r �describe_to s
���z IsObjectWithProperty.describe_toc C sz |d kr|� d� d S t|| j�sD|�|�� d��| j�� d� d S |� d��| j�� d� t|| j�}| j�||� d S )Nzwas Nonez did not have the z propertyz property � )r r r
Zappend_valuer r �describe_mismatch)r �itemZmismatch_descriptionr r
r
r r # s
���z&IsObjectWithProperty.describe_mismatchc C s t � }| �|� t|�S r )r r �str)r �dr
r
r �__str__3 s
zIsObjectWithProperty.__str__N)�__name__�
__module__�__qualname__r r r r r r
r
r
r r
s
r Nc C s |dkrt � }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')
N)r r �
wrap_shortcut)�name�matchr
r
r �has_property9 s r# c O s� t | �dkrVz*| d �� }|D ]}t|| �||<