Ϫf dZddlmZmZmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZedZed ZGd d eeZd eegefd e ede efdZdd e edede e fdZy)z5 Hamcrest matchers useful throughout the test suite. )IOCallableOptionalTypeVar) BaseMatcher) Description)Matcher) IFilePath)fullyQualifiedName_A_BcveZdZdZdeegefdeeddfdZdede fdZ ded e ddffd Z d e ddfd Z xZS) _MatchAftera( The implementation of L{after}. @ivar f: The function to apply. @ivar m: The matcher to use on the result. @ivar _e: After trying to apply the function fails with an exception, the exception that was raised. This can later be used by L{describe_mismatch}. fmreturnNc.||_||_d|_yN)rr_e)selfrrs =/usr/lib/python3/dist-packages/twisted/trial/test/matchers.py__init__z_MatchAfter.__init__!s'+itemc |j|}|jj|S#t$r}||_Yd}~yd}~wwxYw)zI Apply the function and delegate matching on the result. NF)rrmatches Exceptionr)rr transformedes r_matchesz_MatchAfter._matches&sE /&&,K 66>>+. .  DG s. AAAmismatch_descriptionc |jt| ||y|jt |j d|dt |jj d|jy)a Describe the mismatching item or the exception that occurred while pre-processing it. @note: Since the exception reporting here depends on mutable state it will only work as long as PyHamcrest calls methods in the right order. The PyHamcrest Matcher interface doesn't seem to allow implementing this functionality in a more reliable way (see the implementation of L{assert_that}). N(z ) raised z: )rsuperdescribe_mismatch append_textr r __class__)rrr!r's rr%z_MatchAfter.describe_mismatch2sh 77? G %d,@ A , ,%dff-.axz%dgg&7&789DGG9F r descriptioncx|jd|jd|jj|y)zE Create a text description of the match requirement. z[after z] N)r&rr describe_to)rr(s rr*z_MatchAfter.describe_toEs1 '$&& 45 ;'r)__name__ __module__ __qualname____doc__rr r r rboolr rr%r* __classcell__)r's@rrrsr ,(B48,,,, /R /D /b PT&({(t(rrrrrct||S)zN Create a matcher which calls C{f} and uses C{m} to match the result. )r)rrs rafterr2Ms q! rencodingc@dtdtffd }t||S)ze Create a matcher which matches a L{FilePath} the contents of which are matched by L{m}. prc|j5}|jjcdddS#1swYyxYwr)openreaddecode)r5rr3s r getContentz fileContents..getContentZs5 VVX -668??8, - - -s ;A)r strr2)rr3r:s ` r fileContentsr<Ts% -i-C- Q rN)zutf-8)r.typingrrrrhamcrest.core.base_matcherrhamcrest.core.descriptionrhamcrest.core.matcherr twisted.python.filepathr twisted.python.reflectr r r rr2r;r<rrrDs3221)-5 T] T]5(+b/5(pXrdBh GBKGBK  GCL  C  gi>P  r