ϪfdZgdZddlmZmZmZmZmZddlm Z m Z m Z m Z m Z mZddlmZddlmZddlmZddlmZdd lmZdd lmZed ZGd d eeZedeeZe de de de de de dfdeedeedeedeedeedeedeefdZGddeeeZGddeeeZdee dee fdZ!de"de"deeee"e"e#ee ee ffd Z$y!)"z5 Hamcrest matchers useful throughout the test suite. )matches_resultHasSum IsSequenceOf)AnyListSequenceTupleTypeVar)contains_exactlycontains_stringequal_to has_lengthhas_properties instance_of) BaseMatcher)AllOf) Description)Matcher)Protocol)FailureTc eZdZdZdedefdZy) Semigroupz A type with an associative binary operator. Common examples of a semigroup are integers with addition and strings with concatenation. otherreturncy)zF This must be associative: a + (b + c) == (a + b) + c N)selfrs C/usr/lib/python3/dist-packages/twisted/trial/_dist/test/matchers.py__add__zSemigroup.__add__+sN)__name__ __module__ __qualname____doc__rr rr!rrr#s Q 1 r!rS)bound successeserrorsfailuresskipsexpectedFailuresunexpectedSuccessesrc &t||||||dS)zA Match a L{TestCase} instances with matching attributes. r(r)r*r+r,r-)rr/s rrr4s( "  0#6    r!ceZdZdZdeededdfdZdeedefdZd eede fd Z d eed e ddfd Z d e ddfd Z y)rz 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. sumMatcherzerorNc ||_||_yN)r1r2)rr1r2s r__init__zHasSum.__init__Ts$ r!sequencecR|s |jS|j}|D]}||z} |Sr4)r2)rr6resultelems r_sumz HasSum._sumXs599  #Dd]F # r!itemcZ|j|}|jj|S)zG Determine whether the sum of the sequence is matched. )r:r1matches)rr;ss r_matcheszHasSum._matches`s& IIdO&&q))r! descriptionc|j|}|j||jj||y)( Describe the mismatch. N)r:append_description_ofr1describe_mismatch)rr;r@r>s rrDzHasSum.describe_mismatchgs6 IIdO))$/ ))![9r!c~|jd|j|j|jdy); Describe this matcher for error messages. za sequence with sum , N) append_textrCr1rr@s r describe_tozHasSum.describe_tops3  67))$//:%r!)r"r#r$r%rr&r5rr:boolr?rrDrJrr!rrrKs71:Q4Xa[Q*Xa[*T*hqk PT&{&t&r!rcfeZdZdZdeeddfdZdeedefdZ deede ddfd Z de ddfd Z y) rz Match a sequence where every element is matched by another matcher. :ivar elementMatcher: The matcher which must match every element of the sequence. elementMatcherrNc||_yr4)rM)rrMs rr5zIsSequenceOf.__init__s ,r!r;cL|D]}|jj|ryy)zM Determine whether every element of the sequence is matched. FT)rMr=)rr;r9s rr?zIsSequenceOf._matchess/ D&&..t4 r!r@ct|D]I\}}|jj|r"|j||j d|d|Ky)rBznot sequence with element # N) enumeraterMr=rCrH)rr;r@idxr9s rrDzIsSequenceOf.describe_mismatchs[#4 VIC&&..t411$7''*EcU!D8(TU Vr!c~|jd|j|j|jdy)rFza sequence containing only rGN)rHrCrMrIs rrJzIsSequenceOf.describe_tos5  =>))$*=*=>%r!) r"r#r$r%rrr5rrKr?rrDrJrr!rrrysk-wqz-d-Xa[TVhqkV VPTV&{&t&r!r propertiesc Fttttdi|S)zC Match an instance of L{Failure} with matching attributes. r)rrrr)rUs r isFailurerWs$ G$$ r! functionNamefileNamec tt|t|ttt dt dS)zk Match a tuple representation of a frame like those used by L{twisted.python.failure.Failure}. r)r r r rintr)rXrYs r similarFramer\s9 !C 1 1  r!N)%r%__all__typingrrrr r hamcrestr r r rrrhamcrest.core.base_matcherrhamcrest.core.core.allofrhamcrest.core.descriptionrhamcrest.core.matcherrrtwisted.python.failurerrrr&rrrobjectrWstrr[r\rr!rrgsw  763*1)* CL     Cy~&'qk%a=']$Q-%/](21 s| CLcl 3<  cl  !  S\.+&[! %+&\#&;x{+#&LGFO!$ XeCc4<fEF GHr!