
    e9                     \   d dl mZmZmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ dZdZdZ ed	e
      Z ed      Z G d de	eeef            Zedeee   ef   deeeef      fd       Zedeeeee   ef   f   deeeef      fd       Zededeeeef      fd       Zd Zy)    )AnyHashableMappingOptionalTypeVarUnionoverload)BaseMatcher)Description)wrap_matcher)MatcherzJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtK)boundVc                       e Zd ZddZdeeef   dee   de	fdZ
	 ddeeef   dee   de	fdZdeeef   deddfdZd	ed
ededdfdZdeddfdZy)IsDictContainingEntriesreturnNc                 @    t        |j                               | _        y N)sorteditemsvalue_matchers)selfr   s     V/usr/lib/python3/dist-packages/hamcrest/library/collection/isdict_containingentries.py__init__z IsDictContainingEntries.__init__   s    $^%9%9%;<    itemmismatch_descriptionc                 H    |r |j                  |      j                  d       y)Nz is not a mapping objectFappend_description_ofappend_textr   r   r   s      r   _not_a_dictionaryz)IsDictContainingEntries._not_a_dictionary   s$       66t<HHIcdr   c                     | j                   D ]  \  }}	 ||vrB|r>|j                  d      j                  |      j                  d      j                  |        y	 	 ||   }|j                  |      rf|rA|j                  d      j                  |      j                  d       |j                  ||        y y# t        $ r | j	                  ||      cY c S w xY w# t        $ r | j	                  ||      cY c S w xY w)Nzno z key in Fz
value for  T)r   r"   r!   	TypeErrorr$   matchesdescribe_mismatch)r   r   r   keyvalue_matcheractual_values         r   r(   zIsDictContainingEntries.matches   s    #'"5"5 	CJd?+,88?UU%+j12G2G2M  #J#Cy !((6'(44\BXX!k#&!33LBVW-	0 !  J--d4HIIJ
  J--d4HIIJs$   AB:C:CCC=<C=c                 (    | j                  ||       y r   )r(   r#   s      r   r)   z)IsDictContainingEntries.describe_mismatch8   s    T/0r   indexvaluedescriptionc                 b    |j                  |      j                  d      j                  |       y)z(Describes key-value pair at given index.z: Nr    )r   r.   r/   r0   s       r   describe_keyvaluez)IsDictContainingEntries.describe_keyvalue;   s'    ))%0<<TBXXY^_r   c                     |j                  d       d}| j                  D ]-  \  }}|s|j                  d       | j                  |||       d}/ |j                  d       y )Nza dictionary containing {Tz, F})r"   r   r2   )r   r0   firstr*   r/   s        r   describe_toz#IsDictContainingEntries.describe_to?   sg     ;<-- 	JC''-""3{;E		
 	$r   )r   Nr   )__name__
__module____qualname__r   r   r   r   r   r   boolr$   r(   r)   r2   r6    r   r   r   r      s    =AqDM9A+9N	 RVAqDM9A+9N	:1gadm 1; 1[_ 1`q ` ` `QU `%{ %t %r   r   keys_valuematchersr   c                       y r   r;   r<   s    r   has_entriesr?   K       r   c                      y r   r;   r>   s    r   r?   r?   Q   r@   r   c                       y r   r;   r>   s    r   r?   r?   W   r@   r   c                     t        |       dk(  r-	 | d   j                         }|D ]  }t        ||         ||<    n]t        |       dz  rt	        d      i }t        t        t        |       dz              D ]  }t        | d|z  dz            || d|z     <   ! |j                         D ]  \  }}t        |      ||<    t        |      S # t        $ r t	        d      w xY w)a%  Matches if dictionary contains entries satisfying a dictionary of keys
    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_entries({'foo':equal_to(1), 'bar':equal_to(2)})
        has_entries({'foo':1, 'bar':2})

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

    .. function:: has_entries(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_entries(foo=equal_to(1), bar=equal_to(2))
        has_entries(foo=1, bar=2)

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

    .. function:: has_entries(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_entries('foo', equal_to(1), 'bar', equal_to(2))
        has_entries('foo', 1, 'bar', 2)

       r   zEsingle-argument calls to has_entries must pass a dict as the argument   z$has_entries requires key-value pairs)	lencopyr   AttributeError
ValueErrorrangeintr   r   )r<   kv_args	base_dictr*   r.   r/   s         r   r?   r?   \   s   \ !#	*1-224I  >!-in!=	#> !"Q&CDD	3s#56:;< 	E7C"1u9q=18I(U34	
 mmo -
U%e,	#- #9--!  	W 	s   +C
 
CN)typingr   r   r   r   r   r   r	   hamcrest.core.base_matcherr
   hamcrest.core.descriptionr   "hamcrest.core.helpers.wrap_matcherr   hamcrest.core.matcherr   
__author____copyright____license__r   r   r   strr?   r;   r   r   <module>rW      s   M M M 2 1 ; )
-$Cx CL7%k'!Q$-8 7%v 
eGAJM&: wwsTUv?W  

 
GAuWQZ]/C,C$D QXYZ\]Y]Q^I_  

 
S WWS#X5F-G  
C.r   