
    Vh_                     P   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jT                  Z+djT                  Z, G d de       Z- G d de       Z. G d de       Z/y)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y)HasSumTestsz
    Tests for L{HasSum}.
    summablereturnNc                     |\  }} ||      } |g       }t        t        |      |      }t               }t        |j	                  ||      t        d             t        t        |      t        d             y)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           V/home/dcms/DCMS/lib/python3.12/site-packages/twisted/trial/_dist/test/test_matchers.pytest_matcheszHasSumTests.test_matches,   sd      W3<r{(+T2')GOOC5x~FC$hrl3r"   c                 l   |\  }} |g       }t        t                     }t        ||      }t               }t	        |j                  ||      t        d             t               }|j                  |       t        |      }	t	        |	t        d             t	        |	t        t        |                   y)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r{!%hj!1
T*-/GOOC):;Xe_M 1 333J?)*	I/DEFIs3H/IJKr"   )__name__
__module____qualname____doc__r   r   r   r   r   	concatIntr   	concatStrr   concatBytes	summablesr   r   r   r   Summerr2   r9    r"   r1   r$   r$   !   s     uXZ $y/2uTV}d9o.uVX[ 12I 94U8A;q	+A%B 4t 4 4" 9LQK1I
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y)IsSequenceOfTestsz$
    Tests for L{IsSequenceOf}.
    r   i  )	min_value	max_valuenumItemsr&   Nc                     dg|z  }t        t        d            }t               }t        |j	                  ||      t        d             t        t        |      t        d             y)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   sU     fxx~.-/GOOC):;Xd^LC)*HRL9r"   	numBeforenumAfterc                    dg|z  dgz   dg|z  z   }t        t        d            }t               }t        |j	                  ||      t        d             t        |      }t        |t        d             t        |t        d|              y)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)*	I/KLM)DYK'PQ	
r"   )r:   r;   r<   r=   r   r   	sequencesr   r   intr2   r9   rC   r"   r1   rE   rE   \   s     hj!I
8a401:S :T : 2: 8a40(QRV2WX
 
 
 
 Y
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y)IsFailureTestsz!
    Tests for L{isFailure}.
    excTyper&   Nc                     t        t        |            }t         |             }t        |j	                  |      t        d             y)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   s6     '!23')$GOOG,htn=r"   c                     t        t        |      t        t                           }t	         |             }t        |j                  |      t        d             y)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   s?     '!2$xz:JK')$GOOG,huo>r"   c                     	 t        d      # t        $ r t               }Y nw xY wt               }t	        t        t        dd                  }t        |j                  ||      t        d      |       y)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   so    
	W%% 		A	 ./LHI
 	OOA01TN	
s    ##)r:   r;   r<   r=   r   r   r\   ZeroDivisionErrorRuntimeErrorr   r]   r2   r9   rY   rC   r"   r1   rP   rP      s     <%6EFG
>D$7 
>D 
> H
> <%6EFG
?tM': 
?t 
? H
?
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 U U ) > 
 
 
 + 6 F F	8A;-"	#	GG	hh8L% 8Lv,
+ ,
^1
( 1
r"   