
    Yf_                     \   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e           Z- G d de           Z. G 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            
          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            Z ee          deee         ee         f         ddfd            ZdS )HasSumTestsz
    Tests for L{HasSum}.
    summablereturnNc                 H   |\  }} ||          } |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descriptions           X/var/www/html/env/lib/python3.11/site-packages/twisted/trial/_dist/test/test_matchers.pytest_matcheszHasSumTests.test_matches,   s      W73<<wr{{(++T22'))GOOC55x~~FFFC$$hrll33333r"   c                    |\  }} |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	actualStrs
             r1   test_mismatcheszHasSumTests.test_mismatches>   s      Wwr{{!%hjj!1!1
T**-//GOOC):;;Xe__MMM 1 3 333J???)**	I/DEEFFFIs3H/I/IJJKKKKKr"   )__name__
__module____qualname____doc__r   r   r   r   r   	concatIntr   	concatStrr   concatBytes	summablesr   r   r   r   Summerr2   r9    r"   r1   r$   r$   !   sL         uuXXZZ  $$y//22uuTTVV}}dd9oo..uuVVXX[ 1 122 I U94U8A;q	+A%B 4t 4 4 4 4" U9LQK1I
L 
L L L L L Lr"   r$   c                       e Zd ZdZ e e                      Z e edd                    de	ddfd            Z
 e edd           edd                    d	e	d
e	ddfd            ZdS )IsSequenceOfTestsz$
    Tests for L{IsSequenceOf}.
    r   i  )	min_value	max_valuenumItemsr&   Nc                    dg|z  }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*   rH   r+   r/   r6   s        r1   r2   zIsSequenceOfTests.test_matchesc   sy     fxx~~..-//GOOC):;;Xd^^LLLC)**HRLL99999r"   	numBeforenumAfterc                 v   dg|z  dgz   dg|z  z   }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*   rJ   rK   r+   r/   r6   r8   s          r1   r9   z!IsSequenceOfTests.test_mismatchesr   s     fy E7*dVh->>x~~..-//GOOC):;;Xe__MMM)**	I/KLLMMM'PY'P'PQQ	
 	
 	
 	
 	
r"   )r:   r;   r<   r=   r   r   	sequencesr   r   intr2   r9   rC   r"   r1   rE   rE   \   s          hhjj!!I
U88a400011:S :T : : : 21: U88a4000((QRV2W2W2WXX
 
 
 
 
 
 YX
 
 
r"   rE   c                       e Zd ZdZ e eeeeg                    de	e
         ddfd            Z e eeeeg                    de	e
         ddfd            Zd ZdS )IsFailureTestsz!
    Tests for L{isFailure}.
    excTyper&   Nc                     t          t          |                    }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*   rQ   r/   failures       r1   r2   zIsFailureTests.test_matches   sW     '!2!2333''))$$GOOG,,htnn=====r"   c                    t          t          |          t          t                                          }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.
        )rS   otherFN)r   r   r   r   r   r   r(   rT   s       r1   r9   zIsFailureTests.test_mismatches   se     '!2!2$xzz:J:JKKK''))$$GOOG,,huoo>>>>>r"   c                 8   	 t          d          # t          $ r t                      }Y nw xY wt                      }t	          t          t          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*   fr6   r/   s       r1   rY   zIsFailureTests.test_frames   s    
	W%%% 	 	 			AAA	 .//LHHII
 
 
 	OOA011TNN	
 	
 	
 	
 	
s    ,,)r:   r;   r<   r=   r   r   r\   ZeroDivisionErrorRuntimeErrorr   r]   r2   r9   rY   rC   r"   r1   rP   rP      s          U<<%6EFFGG
>D$7 
>D 
> 
> 
> HG
> U<<%6EFFGG
?tM': 
?t 
? 
? 
? HG
?
 
 
 
 
r"   rP   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    rB   sumr>   joinr?   r@   r$   rE   rP   rC   r"   r1   <module>rl      s    3 2 2 2 2 2 2 2 2 2 2 2 U U U U U U U U U U U U U U U U ) ) ) ) ) ) > > > > > >      
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 + * * * * * 6 6 6 6 6 6 F F F F F F F F F F F F F F	8A;-"	#	G	h8L 8L 8L 8L 8L% 8L 8L 8Lv,
 ,
 ,
 ,
 ,
+ ,
 ,
 ,
^1
 1
 1
 1
 1
( 1
 1
 1
 1
 1
r"   