o
    >h                     @   s  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 dee Zedee d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dZG dd deee  ZG dd deee  Z dee! dee! fddZ"d e#d!e#deeee#e#e$ee! ee! f   fd"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                   @   s"   e Zd ZdZdedefd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                 C   s   dS )zF
        This must be associative: a + (b + c) == (a + b) + c
        N )selfr   r   r   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/trial/_dist/test/matchers.py__add__+   s    zSemigroup.__add__N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   #   s    r   S)bound	successeserrorsfailuresskipsexpectedFailuresunexpectedSuccessesr   c                 C   s   t | |||||dS )zA
    Match a L{TestCase} instances with matching attributes.
    r$   r%   r&   r'   r(   r)   )r   r*   r   r   r   r   4   s   r   c                   @   s   e Zd ZdZdee deddfddZdee defd	d
Zdee de	fddZ
dee deddfddZdeddfd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                 C   s   || _ || _d S N)r+   r,   )r   r+   r,   r   r   r   __init__T   s   
zHasSum.__init__sequencec                 C   s&   |s| j S | j }|D ]}|| }q
|S r-   )r,   )r   r/   resultelemr   r   r   _sumX   s   
zHasSum._sumitemc                 C   s   |  |}| j|S )zG
        Determine whether the sum of the sequence is matched.
        )r2   r+   matches)r   r3   sr   r   r   _matches`   s   
zHasSum._matchesdescriptionc                 C   s&   |  |}||  | j|| dS )(
        Describe the mismatch.
        N)r2   append_description_ofr+   describe_mismatch)r   r3   r7   r5   r   r   r   r:   g   s   

zHasSum.describe_mismatchc                 C   $   | d || j | d dS );
        Describe this matcher for error messages.
        za sequence with sum , N)append_textr9   r+   r   r7   r   r   r   describe_top      
zHasSum.describe_to)r   r   r    r!   r   r"   r.   r   r2   boolr6   r   r:   r@   r   r   r   r   r   K   s    	r   c                   @   sh   e Zd ZdZdee ddfddZdee defdd	Z	dee d
e
ddfddZd
e
ddfd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                 C   s
   || _ d S r-   )rC   )r   rC   r   r   r   r.      s   
zIsSequenceOf.__init__r3   c                 C   s    |D ]}| j |s dS qdS )zM
        Determine whether every element of the sequence is matched.
        FT)rC   r4   )r   r3   r1   r   r   r   r6      s
   zIsSequenceOf._matchesr7   c                 C   sB   t |D ]\}}| j|s||  |d| d| qdS )r8   znot sequence with element # N)	enumeraterC   r4   r9   r>   )r   r3   r7   idxr1   r   r   r   r:      s   
zIsSequenceOf.describe_mismatchc                 C   r;   )r<   za sequence containing only r=   N)r>   r9   rC   r?   r   r   r   r@      rA   zIsSequenceOf.describe_to)r   r   r    r!   r   r   r.   r   rB   r6   r   r:   r@   r   r   r   r   r   y   s    		r   
propertiesc                  K   s   t tttdi | S )zC
    Match an instance of L{Failure} with matching attributes.
    Nr   )r   r   r   r   )rG   r   r   r   	isFailure   s   rH   functionNamefileNamec                 C   s$   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   )rI   rJ   r   r   r   similarFrame   s   rL   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   objectrH   strrK   rL   r   r   r   r   <module>   sX    
.&
 