U
    P|jÝ  ã                   @   s�   d Z ddl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 ddlmZ ddlmZ d	d
lmZ G dd„ deƒZdS )z+
Tests for L{twisted.trial.test.matchers}.
é    )ÚanythingÚassert_thatÚcontains_stringÚequal_toÚnot_)ÚAllOf)ÚStringDescription)Úgiven)ÚjustÚsampled_fromÚtext)ÚFilePath)ÚSynchronousTestCaseé   )ÚfileContentsc                   @   sj   e Zd ZdZeeƒ edƒƒeeddœdd„ƒZeedƒe	dd	dgƒƒeeddœd
d„ƒZ
ddœdd„ZdS )ÚFileContentsTestsz$
    Tests for L{fileContents}.
    zutf-8N)ÚcontentsÚencodingÚreturnc                 C   sV   t |  ¡ ƒ}| | |¡¡ tƒ }ttt|ƒƒ ||¡tdƒƒ tt	|ƒtdƒƒ dS )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.
        TÚ N)
r   ÚmktempÚ
setContentÚencoder   r   r   r   ÚmatchesÚstr©Úselfr   r   ÚpÚdescription© r   úD/tmp/pip-unpacked-wheel-audpp6lv/twisted/trial/test/test_matchers.pyÚtest_matches   s     ÿzFileContentsTests.test_matchesz!some text, it doesn't matter whatÚasciizlatin-1c                 C   s`   t |  ¡ ƒ}| | |¡¡ tƒ }ttttƒ ƒƒ 	||¡t
dƒƒ tt|ƒt
d|› d�ƒƒ dS )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.
        Fzwas <ú>N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    Útest_mismatches)   s     ÿz!FileContentsTests.test_mismatches)r   c                 C   sZ   t |  ¡ ƒ}tƒ }tttƒ ƒ ||¡tdƒƒ tt|ƒt	t
dƒt
dƒt
t|jƒƒƒƒ dS )zq
        L{fileContents} reports details of any I/O error encountered while
        attempting to match.
        Fr   ÚFileNotFoundErrorN)r   r   r   r   r   r   r   r   r   r   r   ÚreprÚpath)r   r   r   r   r   r    Útest_ioerrorB   s    ùýzFileContentsTests.test_ioerror)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r
   r   r!   r   r$   r(   r   r   r   r    r      s   þr   N)r,   Zhamcrestr   r   r   r   r   Zhamcrest.core.core.allofr   Z hamcrest.core.string_descriptionr   Z
hypothesisr	   Zhypothesis.strategiesr
   r   r   Ztwisted.python.filepathr   Ztwisted.trial.unittestr   Zmatchersr   r   r   r   r   r    Ú<module>   s   