o
    >h_                     @   s  d Z ddl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mZ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"m#Z#m$Z$m%Z%m&Z& eee$ ge$f Z'e(Z)dj*Z+dj*Z,G dd de Z-G dd de Z.G dd de Z/dS )z1
Tests for L{twisted.trial._dist.test.matchers}.
    )CallableSequenceTupleType)anythingassert_thatcontainscontains_stringequal_tonot_)Matcher)StringDescription)given)	binarybooleansintegersjustlistsone_ofsampled_fromtexttuples)Failure)SynchronousTestCase   )HasSumIsSequenceOfS	isFailuresimilarFrame     c                   @   s   e Zd ZdZeeee ee	eee
 eeeee eeZeedeee ee f ddfddZeedeee ee f ddfddZdS )	HasSumTestsz
    Tests for L{HasSum}.
    summablereturnNc                 C   sX   |\}}||}|g }t t||}t }t|||td tt|td dS )a  
        L{HasSum} matches a sequence if the elements sum to a value matched by
        the parameterized matcher.

        :param summable: A tuple of a sequence of values to try to match and a
            function which can compute the correct sum for that sequence.
        Tr    N)r   r
   r   r   matchesstr)selfr#   seqsumFuncexpectedzeromatcherdescription r.   /var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/trial/_dist/test/test_matchers.pytest_matches,   s   	zHasSumTests.test_matchesc           
      C   s|   |\}}|g }t t }t||}t }t|||td t }|| t|}	t|	t	d t|	t	t| dS )z
        L{HasSum} does not match a sequence if the elements do not sum to a
        value matched by the parameterized matcher.

        :param summable: See L{test_matches}.
        Fza sequence with sumN)
r   r   r   r   r   r%   r
   append_description_ofr&   r	   )
r'   r#   r(   r)   r+   
sumMatcherr,   actualDescriptionsumMatcherDescription	actualStrr.   r.   r/   test_mismatches>   s   


zHasSumTests.test_mismatches)__name__
__module____qualname____doc__r   r   r   r   r   	concatIntr   	concatStrr   concatBytes	summablesr   r   r   r   Summerr0   r6   r.   r.   r.   r/   r"   !   s&    $r"   c                   @   sl   e Zd ZdZee Zeedddde	ddfdd	Z
eedddedddd
e	de	ddfddZdS )IsSequenceOfTestsz$
    Tests for L{IsSequenceOf}.
    r   i  )	min_value	max_valuenumItemsr$   Nc                 C   sH   dg| }t td}t }t|||td tt|td dS )z
        L{IsSequenceOf} matches a sequence if all of the elements are
        matched by the parameterized matcher.

        :param numItems: The length of a sequence to try to match.
        Tr    N)r   r
   r   r   r%   r&   )r'   rC   r(   r,   r3   r.   r.   r/   r0   c   s
   
zIsSequenceOfTests.test_matches	numBeforenumAfterc                 C   sp   dg| dg dg|  }t td}t }t|||td t|}t|td t|td|  dS )a  
        L{IsSequenceOf} does not match a sequence if any of the elements
        are not matched by the parameterized matcher.

        :param numBefore: In the sequence to try to match, the number of
            elements expected to match before an expected mismatch.

        :param numAfter: In the sequence to try to match, the number of
            elements expected expected to match after an expected mismatch.
        TFza sequence containing onlyznot sequence with element #N)r   r
   r   r   r%   r&   r	   )r'   rD   rE   r(   r,   r3   r5   r.   r.   r/   r6   r   s   z!IsSequenceOfTests.test_mismatches)r7   r8   r9   r:   r   r   	sequencesr   r   intr0   r6   r.   r.   r.   r/   r@   \   s    
r@   c                   @   sh   e Zd ZdZeeeeegde	e
 ddfddZeeeeegde	e
 ddfddZd	d
 ZdS )IsFailureTestsz!
    Tests for L{isFailure}.
    excTyper$   Nc                 C   s0   t t|d}t| }t||td dS )z
        L{isFailure} matches instances of L{Failure} with matching
        attributes.

        :param excType: An exception type to wrap in a L{Failure} to be
            matched against.
        )typeTN)r   r
   r   r   r%   r'   rI   r,   failurer.   r.   r/   r0      s   	
zIsFailureTests.test_matchesc                 C   s8   t t|tt d}t| }t||td dS )z
        L{isFailure} does not match instances of L{Failure} with
        attributes that don't match.

        :param excType: An exception type to wrap in a L{Failure} to be
            matched against.
        )rJ   otherFN)r   r
   r   r   r   r   r%   rK   r.   r.   r/   r6      s   	
zIsFailureTests.test_mismatchesc                 C   sX   zt d ty   t }Y nw t }tttddd}t|||t	d| dS )zm
        The L{similarFrame} matcher matches elements of the C{frames} list
        of a L{Failure}.
        zOh notest_framestest_matchers)framesTN)

ValueErrorBaseExceptionr   r   r   r   r   r   r%   r
   )r'   fr3   r,   r.   r.   r/   rN      s   

zIsFailureTests.test_frames)r7   r8   r9   r:   r   r   rQ   ZeroDivisionErrorRuntimeErrorr   rR   r0   r6   rN   r.   r.   r.   r/   rH      s    rH   N)0r:   typingr   r   r   r   hamcrestr   r   r   r	   r
   r   hamcrest.core.matcherr    hamcrest.core.string_descriptionr   
hypothesisr   hypothesis.strategiesr   r   r   r   r   r   r   r   r   twisted.python.failurer   twisted.trial.unittestr   matchersr   r   r   r   r   r?   sumr;   joinr<   r=   r"   r@   rH   r.   r.   r.   r/   <module>   s"     ,;/