
    Vh                        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%y!)"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y)	Semigroupz
    A type with an associative binary operator.

    Common examples of a semigroup are integers with addition and strings with
    concatenation.
    otherreturnc                      y)zF
        This must be associative: a + (b + c) == (a + b) + c
        N )selfr   s     Q/home/dcms/DCMS/lib/python3.12/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   s(     "  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y)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                      || _         || _        y N)r1   r2   )r   r1   r2   s      r   __init__zHasSum.__init__T   s    $	r!   sequencec                 R    |s| j                   S | j                   }|D ]  }||z   }	 |S r4   )r2   )r   r6   resultelems       r   _sumzHasSum._sumX   s5    99 	#Dd]F	#r!   itemc                 Z    | j                  |      }| j                  j                  |      S )zG
        Determine whether the sum of the sequence is matched.
        )r:   r1   matches)r   r;   ss      r   _matcheszHasSum._matches`   s&     IIdO&&q))r!   descriptionc                     | j                  |      }|j                  |        | j                  j                  ||       y)(
        Describe the mismatch.
        N)r:   append_description_ofr1   describe_mismatch)r   r;   r@   r>   s       r   rD   zHasSum.describe_mismatchg   s6     IIdO))$/))![9r!   c                 ~    |j                  d       |j                  | j                         |j                  d       y);
        Describe this matcher for error messages.
        za sequence with sum , N)append_textrC   r1   r   r@   s     r   describe_tozHasSum.describe_top   s3     	 6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                   f    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y)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                     || _         y r4   )rM   )r   rM   s     r   r5   zIsSequenceOf.__init__   s
    ,r!   r;   c                 L    |D ]  }| j                   j                  |      r y y)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	 r!   r@   c                     t        |      D ]I  \  }}| j                  j                  |      r"|j                  |        |j	                  d| d|       K y)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IC&&..t411$7''*EcU!D8(TU	Vr!   c                 ~    |j                  d       |j                  | j                         |j                  d       y)rF   za sequence containing only rG   N)rH   rC   rM   rI   s     r   rJ   zIsSequenceOf.describe_to   s5     	 =>))$*=*=>%r!   )r"   r#   r$   r%   r   r   r5   r   rK   r?   r   rD   rJ   r   r!   r   r   r   y   sk    -wqz -d -Xa[ T Vhqk V VPT V&{ &t &r!   r   
propertiesc                  F    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      s$     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\      s9     !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      sw   7 6  3 * 1 ) & *CL  Cy~& 'qk%a=']$Q-%/](21s|CL cl 3<	
 cl ! S\.+&[!% +&\#&;x{+ #&LGFO  !$XeCc4<fEFGHr!   