
    Yf                        d Z g dZddlmZmZmZmZmZ ddl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d	lmZ dd
lmZ  ed          Z G d dee                   Z edee                   Z ed           ed           ed           ed           ed           ed          fdee         dee         dee         dee         dee         dee         dee         fdZ G d deee                            Z G d deee                            Z dee!         dee!         fdZ"de#de#deeee#e#e$ee!         ee!         f                           fd Z%d!S )"z5
Hamcrest matchers useful throughout the test suite.
)matches_resultHasSumIsSequenceOf    )AnyListSequenceTupleTypeVar)contains_exactlycontains_stringequal_to
has_lengthhas_propertiesinstance_of)BaseMatcher)AllOf)Description)Matcher)Protocol)FailureTc                   "    e Zd ZdZdedefdZdS )	Semigroupz
    A type with an associative binary operator.

    Common examples of a semigroup are integers with addition and strings with
    concatenation.
    otherreturnc                     dS )zF
        This must be associative: a + (b + c) == (a + b) + c
        N )selfr   s     S/var/www/html/env/lib/python3.11/site-packages/twisted/trial/_dist/test/matchers.py__add__zSemigroup.__add__+   s          N)__name__
__module____qualname____doc__r   r    r   r!   r   r   r   #   s@         Q 1      r!   r   S)bound	successeserrorsfailuresskipsexpectedFailuresunexpectedSuccessesr   c           	      .    t          | |||||d          S )zA
    Match a L{TestCase} instances with matching attributes.
    r(   r)   r*   r+   r,   r-   )r   r/   s         r   r   r   4   s2     "  0#6	
 	
	 	 	r!   c                       e Zd ZdZdee         deddfdZdee         defdZd	ee         de	fd
Z
d	ee         deddfdZdeddfdZdS )r   z
    Match a sequence the elements of which sum to a value matched by
    another matcher.

    :ivar sumMatcher: The matcher which must match the sum.
    :ivar zero: The zero value for the matched type.
    
sumMatcherzeror   Nc                 "    || _         || _        d S N)r1   r2   )r   r1   r2   s      r   __init__zHasSum.__init__T   s    $			r!   sequencec                 :    |s| j         S | j         }|D ]}||z   }|S r4   )r2   )r   r6   resultelems       r   _sumzHasSum._sumX   s8     	9 	# 	#Dd]FFr!   itemc                 `    |                      |          }| j                            |          S )zG
        Determine whether the sum of the sequence is matched.
        )r:   r1   matches)r   r;   ss      r   _matcheszHasSum._matches`   s)     IIdOO&&q)))r!   descriptionc                     |                      |          }|                    |            | j                            ||           dS )(
        Describe the mismatch.
        N)r:   append_description_ofr1   describe_mismatch)r   r;   r@   r>   s       r   rD   zHasSum.describe_mismatchg   sD     IIdOO))$///))![999tr!   c                     |                     d           |                    | j                   |                     d           dS );
        Describe this matcher for error messages.
        za sequence with sum , N)append_textrC   r1   r   r@   s     r   describe_tozHasSum.describe_top   sI     	 6777))$/:::%%%%%r!   )r"   r#   r$   r%   r   r&   r5   r   r:   boolr?   r   rD   rJ   r   r!   r   r   r   K   s         71: Q 4    Xa[ Q    *Xa[ *T * * * *hqk  PT    &{ &t & & & & & &r!   r   c                   z    e Zd ZdZdee         ddfdZdee         defdZ	dee         de
ddfd	Zde
ddfd
ZdS )r   z
    Match a sequence where every element is matched by another matcher.

    :ivar elementMatcher: The matcher which must match every element of the
        sequence.
    elementMatcherr   Nc                     || _         d S r4   )rM   )r   rM   s     r   r5   zIsSequenceOf.__init__   s    ,r!   r;   c                 J    |D ]}| j                             |          s dS  dS )zM
        Determine whether every element of the sequence is matched.
        FT)rM   r=   )r   r;   r9   s      r   r?   zIsSequenceOf._matches   s=      	 	D&..t44 uutr!   r@   c                     t          |          D ]O\  }}| j                            |          s0|                    |            |                    d| d|           PdS )rB   znot sequence with element # N)	enumeraterM   r=   rC   rH   )r   r;   r@   idxr9   s        r   rD   zIsSequenceOf.describe_mismatch   s     #4 	V 	VIC&..t44 V11$777''(Tc(T(TD(T(TUUU	V 	Vr!   c                     |                     d           |                    | j                   |                     d           dS )rF   za sequence containing only rG   N)rH   rC   rM   rI   s     r   rJ   zIsSequenceOf.describe_to   sJ     	 =>>>))$*=>>>%%%%%r!   )r"   r#   r$   r%   r   r   r5   r   rK   r?   r   rD   rJ   r   r!   r   r   r   y   s         -wqz -d - - - -Xa[ T    Vhqk V VPT V V V V&{ &t & & & & & &r!   r   
propertiesc                  Z    t          t          t                    t          di |           S )zC
    Match an instance of L{Failure} with matching attributes.
    r   )r   r   r   r   )rU   s    r   	isFailurerW      s2     G$$$$  r!   functionNamefileNamec           	          t          t          |           t          |          t          t                    t          d          t          d                    S )zk
    Match a tuple representation of a frame like those used by
    L{twisted.python.failure.Failure}.
    r   )r   r   r   r   intr   )rX   rY   s     r   similarFramer\      sK     !!C 	11  r!   N)&r%   __all__typingr   r   r   r	   r
   hamcrestr   r   r   r   r   r   hamcrest.core.base_matcherr   hamcrest.core.core.allofr   hamcrest.core.descriptionr   hamcrest.core.matcherr   typing_extensionsr   twisted.python.failurer   r   r   r&   r   r   r   objectrW   strr[   r\   r   r!   r   <module>rh      s      7 6 6 6 6 6 6 6 6 6 6 6 6 6                3 2 2 2 2 2 * * * * * * 1 1 1 1 1 1 ) ) ) ) ) ) & & & & & & * * * * * *GCLL        GCy~&&& 'hqkk%:a=='Z]]$*Q--%/Z]](2
1 s|CL cl 3<	
 cl ! S\   .+& +& +& +& +&[!% +& +& +&\#& #& #& #& #&;x{+ #& #& #&LGFO     !$XeCc4<fEFGH     r!   