U
    n5{ie  ã                   @   sZ   d Z ddlZddlmZ ddlmZ G dd„ dejƒZG dd„ dƒZG d	d
„ d
ejƒZ	dS )zÔ
Sample test cases defined using the standard library L{unittest.TestCase}
class which are used as data by test cases which are actually part of the
trial test suite to verify handling of handling of such cases.
é    N)Úexc_info)ÚFailurec                   @   s6   e Zd Zdd„ Zdd„ Zdd„ Ze d¡dd	„ ƒZd
S )Ú
PyUnitTestc                 C   s   dS )z!
        A passing test.
        N© ©Úselfr   r   úB/tmp/pip-unpacked-wheel-mnhg7r0q/twisted/trial/test/pyunitcases.pyÚ	test_pass   s    zPyUnitTest.test_passc                 C   s   t dƒ‚dS )zE
        A test which raises an exception to cause an error.
        zpyunit errorN)Ú	Exceptionr   r   r   r   Ú
test_error   s    zPyUnitTest.test_errorc                 C   s   |   d¡ dS )zQ
        A test which uses L{unittest.TestCase.fail} to cause a failure.
        zpyunit failureN)Zfailr   r   r   r   Ú	test_fail   s    zPyUnitTest.test_failzpyunit skipc                 C   s   dS )zS
        A test which uses the L{unittest.skip} decorator to cause a skip.
        Nr   r   r   r   r   Ú	test_skip"   s    zPyUnitTest.test_skipN)	Ú__name__Ú
__module__Ú__qualname__r	   r   r   ÚunittestÚskipr   r   r   r   r   r      s
   r   c                   @   s   e Zd ZdZedœdd„ZdS )Ú_NonStringIdzÚ
    A class that looks a little like a TestCase, but not enough so to
    actually be used as one.  This helps L{BrokenRunInfrastructure} use some
    interfaces incorrectly to provoke certain failure conditions.
    )Úreturnc                 C   s   t ƒ S )N)Úobjectr   r   r   r   Úid0   s    z_NonStringId.idN)r   r   r   Ú__doc__r   r   r   r   r   r   r   )   s   r   c                   @   sH   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dS )ÚBrokenRunInfrastructurezu
    A test suite that is broken at the level of integration between
    L{TestCase.run} and the results object.
    c                 C   s   t | | jƒ|ƒS )zß
        Override the normal C{run} behavior to pass the result object
        along to the test method.  Each test method needs the result object so
        that it can implement its particular kind of brokenness.
        )ÚgetattrZ_testMethodName©r   Úresultr   r   r   Úrun:   s    zBrokenRunInfrastructure.runc                 C   s   |  tƒ ¡ dS )zA
        Violate the L{TestResult.addSuccess} interface.
        N)Z
addSuccessr   r   r   r   r   Útest_addSuccessB   s    z'BrokenRunInfrastructure.test_addSuccessc                 C   s:   zt dƒ‚W n tk
r&   tƒ }Y nX | tƒ |¡ dS )z?
        Violate the L{TestResult.addError} interface.
        Útest_addErrorN)r
   ÚBaseExceptionr   ZaddErrorr   ©r   r   Úerrr   r   r   r   I   s
    z%BrokenRunInfrastructure.test_addErrorc                 C   s:   zt dƒ‚W n tk
r&   tƒ }Y nX | tƒ |¡ dS )zA
        Violate the L{TestResult.addFailure} interface.
        Útest_addFailureN)r
   r   r   Z
addFailurer   r    r   r   r   r"   T   s
    z'BrokenRunInfrastructure.test_addFailurec                 C   s   |  tƒ d¡ dS )z>
        Violate the L{TestResult.addSkip} interface.
        Útest_addSkipN)ZaddSkipr   r   r   r   r   r#   _   s    z$BrokenRunInfrastructure.test_addSkipc                 C   s:   zt dƒ‚W n tk
r&   tƒ }Y nX | tƒ |¡ dS )zI
        Violate the L{TestResult.addExpectedFailure} interface.
        Útest_addExpectedFailureN)r
   r   r   ZaddExpectedFailurer   r    r   r   r   r$   e   s
    z/BrokenRunInfrastructure.test_addExpectedFailurec                 C   s   |  tƒ ¡ dS )zK
        Violate the L{TestResult.addUnexpectedSuccess} interface.
        N)ZaddUnexpectedSuccessr   r   r   r   r   Útest_addUnexpectedSuccesso   s    z1BrokenRunInfrastructure.test_addUnexpectedSuccessN)r   r   r   r   r   r   r   r"   r#   r$   r%   r   r   r   r   r   4   s   
r   )
r   r   Úsysr   Ztwisted.python.failurer   ZTestCaser   r   r   r   r   r   r   Ú<module>   s   