Ϫf dZddlmZmZmZmZmZddlmZddl m Z ddl m Z ddl mZmZmZddlmZddlmZd d lmZGd d eZy )z+ Tests for L{twisted.trial.test.matchers}. )anything assert_thatcontains_stringequal_tonot_)AllOf)StringDescription)given)just sampled_fromtext)FilePath)SynchronousTestCase) fileContentsceZdZdZeeeddededdfdZeede gd dededdfd Z d d Z y) FileContentsTestsz$ Tests for L{fileContents}. utf-8contentsencodingreturnNc4t|j}|j|j|t }t t t|j||tdt t|tdy)ah L{fileContents} matches a L{IFilePath} that refers to a file that contains a string that is matched by the parameterized matcher. :param contents: The text string to place in the file and match against. :param encoding: The text encoding to use to encode C{contents} when writing to the file. TN) rmktemp setContentencoder rrrmatchesstrselfrrp descriptions B/usr/lib/python3/dist-packages/twisted/trial/test/test_matchers.py test_matcheszFileContentsTests.test_matchessn T[[] # X__X./')  (+ , 4 4Q Dhtn  C $hrl3z!some text, it doesn't matter what)asciizlatin-1rcLt|j}|j|j|t }t t ttj||tdt t|td|dy)a| L{fileContents} does not match an L{IFilePath} that refers to a file that contains a string that is not matched by the parameterized matcher. :param contents: The text string to place in the file and match against. :param encoding: The text encoding to use to encode C{contents} when writing to the file. Fzwas <>N) rrrrr rrrrrrrrs r#test_mismatchesz!FileContentsTests.test_mismatches)sy T[[] # X__X./')  hj) * 2 21k BHUO  C $hqc|&<=r%c Rt|j}t}tt t j ||tdtt|ttdtdtt|jy)zq L{fileContents} reports details of any I/O error encountered while attempting to match. FrFileNotFoundErrorN) rrr rrrrrrrrreprpath)r r!r"s r# test_ioerrorzFileContentsTests.test_ioerrorBsy T[[] #') L,44Q DhuoV   / 34 QVV -  r%)rN) __name__ __module__ __qualname____doc__r r r rr$r r)r.r%r#rrs 464=!4S4C4D4"4(  0123>>s>t> >* r%rN)r2hamcrestrrrrrhamcrest.core.core.allofr hamcrest.core.string_descriptionr hypothesisr hypothesis.strategiesr r r twisted.python.filepathrtwisted.trial.unittestrmatchersrrr3r%r#r<s:LK*>::,6"H +H r%