U
    
W[Ä  ã                   @   s‚   d Z ddlmZmZ ddlmZ ddlmZ ddlmZm	Z	 G dd„ dej
ƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZdS )z.
Tests for interrupting tests with Control-C.
é    )Úabsolute_importÚdivision)ÚNativeStringIO)Úunittest)ÚreporterÚrunnerc                   @   s   e Zd Zdd„ ZdS )Ú	TrialTestc                 C   s    t ƒ | _t ¡ | _t ¡ | _d S ©N)r   Úoutputr   Z
TestResultr   Z
TestLoaderÚloader©Úself© r   úB/usr/lib/python3/dist-packages/twisted/trial/test/test_keyboard.pyÚsetUp   s    
zTrialTest.setUpN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r      s   r   c                       s>   e Zd ZG dd„ dejƒZ‡ fdd„Zdd„ Zdd„ Z‡  Z	S )	ÚInterruptInTestTestsc                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )z$InterruptInTestTests.InterruptedTestc                 C   s   t ‚d S r	   )ÚKeyboardInterruptr   r   r   r   Útest_02_raiseInterrupt   s    z;InterruptInTestTests.InterruptedTest.test_02_raiseInterruptc                 C   s   d S r	   r   r   r   r   r   Útest_01_doNothing   s    z6InterruptInTestTests.InterruptedTest.test_01_doNothingc                 C   s
   dt _d S )NT)r   Útest_03_doNothing_runr   r   r   r   Útest_03_doNothing   s    z6InterruptInTestTests.InterruptedTest.test_03_doNothingN)r   r   r   r   r   r   r   r   r   r   ÚInterruptedTest   s   r   c                    s(   t t| ƒ ¡  | j tj¡| _d t_d S r	   )Úsuperr   r   r   Ú	loadClassr   Úsuiter   r   ©Ú	__class__r   r   r   "   s    zInterruptInTestTests.setUpc                 C   s4   |   d| j ¡ ¡ |   d| jj¡ |  | jj¡ d S )Né   r   )ÚassertEqualr   ÚcountTestCasesr   ÚtestsRunÚassertFalseÚ
shouldStopr   r   r   r   Útest_setUpOK'   s    z!InterruptInTestTests.test_setUpOKc                 C   sF   t  | jg¡ | j¡ |  | jj¡ |  d| jj¡ |  	t
jd¡ d S )Né   ztest_03_doNothing ran.)r   Ú
TrialSuiter   Úrunr   Ú
assertTruer%   r!   r#   r$   r   r   r   r   r   r   Útest_interruptInTest,   s    ÿz)InterruptInTestTests.test_interruptInTest)
r   r   r   r   ÚTestCaser   r   r&   r+   Ú__classcell__r   r   r   r   r      s   
r   c                       sB   e Zd ZdZG dd„ dejƒZ‡ fdd„Zdd„ Zdd	„ Z	‡  Z
S )
ÚInterruptInSetUpTestsr   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )z%InterruptInSetUpTests.InterruptedTestc                 C   s   t jdkrt‚d S ©Nr   )r.   r#   r   r   r   r   r   r   8   s    
z+InterruptInSetUpTests.InterruptedTest.setUpc                 C   s   t  jd7  _d S ©Né   )r.   r#   r   r   r   r   Útest_01<   s    z-InterruptInSetUpTests.InterruptedTest.test_01c                 C   s   t  jd7  _dt _d S ©Nr1   T)r.   r#   Útest_02_runr   r   r   r   Útest_02?   s    z-InterruptInSetUpTests.InterruptedTest.test_02N)r   r   r   r   r2   r5   r   r   r   r   r   7   s   r   c                    s.   t t| ƒ ¡  | j tj¡| _dt_dt_d S )NFr   )	r   r.   r   r   r   r   r   r4   r#   r   r   r   r   r   C   s    ÿzInterruptInSetUpTests.setUpc                 C   sB   |   dtj¡ |   d| j ¡ ¡ |   d| jj¡ |  | jj¡ d S ©Nr   r'   )r!   r.   r#   r   r"   r   r$   r%   r   r   r   r   r&   J   s    z"InterruptInSetUpTests.test_setUpOKc                 C   sF   t  | jg¡ | j¡ |  | jj¡ |  d| jj¡ |  	t
jd¡ d S )Nr'   útest_02 ran)r   r(   r   r)   r   r*   r%   r!   r#   r$   r.   r4   r   r   r   r   Útest_interruptInSetUpP   s    ÿz+InterruptInSetUpTests.test_interruptInSetUp)r   r   r   r#   r   r,   r   r   r&   r8   r-   r   r   r   r   r.   4   s
   r.   c                       sB   e Zd ZdZG dd„ dejƒZ‡ fdd„Zdd„ Zdd	„ Z	‡  Z
S )
ÚInterruptInTearDownTestsr   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )z(InterruptInTearDownTests.InterruptedTestc                 C   s   t jdkrt‚d S r/   )r9   r#   r   r   r   r   r   ÚtearDown\   s    
z1InterruptInTearDownTests.InterruptedTest.tearDownc                 C   s   t  jd7  _d S r0   )r9   r#   r   r   r   r   r2   `   s    z0InterruptInTearDownTests.InterruptedTest.test_01c                 C   s   t  jd7  _dt _d S r3   )r9   r#   r4   r   r   r   r   r5   c   s    z0InterruptInTearDownTests.InterruptedTest.test_02N)r   r   r   r:   r2   r5   r   r   r   r   r   [   s   r   c                    s.   t t| ƒ ¡  | j tj¡| _dt_dt_d S )Nr   F)	r   r9   r   r   r   r   r   r#   r4   r   r   r   r   r   g   s    ÿzInterruptInTearDownTests.setUpc                 C   sB   |   dtj¡ |   d| j ¡ ¡ |   d| jj¡ |  | jj¡ d S r6   )r!   r9   r#   r   r"   r   r$   r%   r   r   r   r   r&   n   s    z%InterruptInTearDownTests.test_setUpOKc                 C   sF   t  | jg¡ | j¡ |  d| jj¡ |  | jj¡ |  	t
jd¡ d S )Nr1   r7   )r   r(   r   r)   r   r!   r#   r*   r%   r$   r9   r4   r   r   r   r   Útest_interruptInTearDownt   s    ÿz1InterruptInTearDownTests.test_interruptInTearDown)r   r   r   r#   r   r,   r   r   r&   r;   r-   r   r   r   r   r9   X   s
   r9   N)Ú__doc__Z
__future__r   r   Ztwisted.python.compatr   Ztwisted.trialr   r   r   ZSynchronousTestCaser   r   r.   r9   r   r   r   r   Ú<module>   s   $