B
    v9aw@  γ               @   sF   d dl Z d dlZd dlZdd ZG dd dejZedkrBe ‘  dS )ι    Nc              G   s   t  ‘ S )N)ΪunittestZ
TestResult)Ϊ_© r   ϊ!/usr/lib/python3.7/test_setups.pyΪresultFactory   s    r   c               @   s€   e 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d Z
dd Zdd Zdd Zd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 )(Ϊ
TestSetupsc             C   s   t jtt ‘ dS )N)ZresultclassΪstream)r   ZTextTestRunnerr   ΪioΪStringIO)Ϊselfr   r   r   Ϊ	getRunner   s    zTestSetups.getRunnerc             G   sl   t  ‘ }x"|D ]}t j |‘}| |‘ qW |  ‘ }t  ‘ }| |‘ | t  ‘ ‘ | t  ‘ ‘ | |‘S )N)r   Ϊ	TestSuiteΪdefaultTestLoaderΪloadTestsFromTestCaseZaddTestsr   ZaddTestΪrun)r   ZcasesΪsuiteZcaseZtestsΪrunnerZ	realSuiter   r   r   ΪrunTests   s    

zTestSetups.runTestsc                sR   G  fdddt j |   ‘}|   jd‘ |  |jd‘ |  t|jd‘ d S )Nc                   s0   e Zd ZdZe fddZdd Zdd ZdS )	z)TestSetups.test_setup_class.<locals>.Testr   c                s     j d7  _ tj ‘  d S )Nι   )ΪsetUpCalledr   ΪTestCaseΪ
setUpClass)Ϊcls)ΪTestr   r   r   #   s    z4TestSetups.test_setup_class.<locals>.Test.setUpClassc             S   s   d S )Nr   )r   r   r   r   Ϊtest_one'   s    z2TestSetups.test_setup_class.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   Ϊtest_two)   s    z2TestSetups.test_setup_class.<locals>.Test.test_twoN)Ϊ__name__Ϊ
__module__Ϊ__qualname__r   Ϊclassmethodr   r   r   r   )r   r   r   r   !   s   r   r   ι   r   )r   r   r   ΪassertEqualr   ΪtestsRunΪlenΪerrors)r   Ϊresultr   )r   r   Ϊtest_setup_class    s
    
zTestSetups.test_setup_classc                sR   G  fdddt j |   ‘}|   jd‘ |  |jd‘ |  t|jd‘ d S )Nc                   s0   e Zd ZdZe fddZdd Zdd ZdS )	z,TestSetups.test_teardown_class.<locals>.Testr   c                s     j d7  _ tj ‘  d S )Nr   )ΪtearDownCalledr   r   ΪtearDownClass)r   )r   r   r   r(   5   s    z:TestSetups.test_teardown_class.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   9   s    z5TestSetups.test_teardown_class.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   ;   s    z5TestSetups.test_teardown_class.<locals>.Test.test_twoN)r   r   r   r'   r   r(   r   r   r   )r   r   r   r   3   s   r   r   r    r   )r   r   r   r!   r'   r"   r#   r$   )r   r%   r   )r   r   Ϊtest_teardown_class2   s
    
zTestSetups.test_teardown_classc                sx   G  fdddt j G fdddt j|   ‘}|   jd‘ |  jd‘ |  |jd‘ |  t|jd‘ d S )Nc                   s0   e Zd ZdZe fddZdd Zdd ZdS )	z8TestSetups.test_teardown_class_two_classes.<locals>.Testr   c                s     j d7  _ tj ‘  d S )Nr   )r'   r   r   r(   )r   )r   r   r   r(   G   s    zFTestSetups.test_teardown_class_two_classes.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   K   s    zATestSetups.test_teardown_class_two_classes.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   M   s    zATestSetups.test_teardown_class_two_classes.<locals>.Test.test_twoN)r   r   r   r'   r   r(   r   r   r   )r   r   r   r   E   s   r   c                   s0   e Zd ZdZe fddZdd Zdd ZdS )	z9TestSetups.test_teardown_class_two_classes.<locals>.Test2r   c                s     j d7  _ tj ‘  d S )Nr   )r'   r   r   r(   )r   )ΪTest2r   r   r(   R   s    zGTestSetups.test_teardown_class_two_classes.<locals>.Test2.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   V   s    zBTestSetups.test_teardown_class_two_classes.<locals>.Test2.test_onec             S   s   d S )Nr   )r   r   r   r   r   X   s    zBTestSetups.test_teardown_class_two_classes.<locals>.Test2.test_twoN)r   r   r   r'   r   r(   r   r   r   )r*   r   r   r*   P   s   r*   r   ι   r   )r   r   r   r!   r'   r"   r#   r$   )r   r%   r   )r   r*   r   Ϊtest_teardown_class_two_classesD   s    z*TestSetups.test_teardown_class_two_classesc             C   sh   G dd dt j}|  |‘}|  |jd‘ |  t|jd‘ |jd \}}|  t|dt|j	f ‘ d S )Nc               @   s(   e Zd Zedd Zdd Zdd ZdS )z7TestSetups.test_error_in_setupclass.<locals>.BrokenTestc             S   s   t dd S )NΪfoo)Ϊ	TypeError)r   r   r   r   r   d   s    zBTestSetups.test_error_in_setupclass.<locals>.BrokenTest.setUpClassc             S   s   d S )Nr   )r   r   r   r   r   g   s    z@TestSetups.test_error_in_setupclass.<locals>.BrokenTest.test_onec             S   s   d S )Nr   )r   r   r   r   r   i   s    z@TestSetups.test_error_in_setupclass.<locals>.BrokenTest.test_twoN)r   r   r   r   r   r   r   r   r   r   r   Ϊ
BrokenTestc   s   r/   r   r   zsetUpClass (%s.%s))
r   r   r   r!   r"   r#   r$   Ϊstrr   r   )r   r/   r%   Ϊerrorr   r   r   r   Ϊtest_error_in_setupclassb   s    	

z#TestSetups.test_error_in_setupclassc                s    G  fdddt j G fdddt j|   ‘}|  |jd‘ |  t|jd‘ |   jd‘ |  jd‘ |jd \}}|  t|d	t	 j
f ‘ d S )
Nc                   s0   e Zd ZdZe fddZdd Zdd ZdS )	z5TestSetups.test_error_in_teardown_class.<locals>.Testr   c                s     j d7  _ tdd S )Nr   r-   )ΪtornDownr.   )r   )r   r   r   r(   w   s    zCTestSetups.test_error_in_teardown_class.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   {   s    z>TestSetups.test_error_in_teardown_class.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   }   s    z>TestSetups.test_error_in_teardown_class.<locals>.Test.test_twoN)r   r   r   r3   r   r(   r   r   r   )r   r   r   r   u   s   r   c                   s0   e Zd ZdZe fddZdd Zdd ZdS )	z6TestSetups.test_error_in_teardown_class.<locals>.Test2r   c                s     j d7  _ tdd S )Nr   r-   )r3   r.   )r   )r*   r   r   r(      s    zDTestSetups.test_error_in_teardown_class.<locals>.Test2.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r      s    z?TestSetups.test_error_in_teardown_class.<locals>.Test2.test_onec             S   s   d S )Nr   )r   r   r   r   r      s    z?TestSetups.test_error_in_teardown_class.<locals>.Test2.test_twoN)r   r   r   r3   r   r(   r   r   r   )r*   r   r   r*      s   r*   r+   r    r   r   ztearDownClass (%s.%s))r   r   r   r!   r"   r#   r$   r3   r0   r   r   )r   r%   r1   r   r   )r   r*   r   Ϊtest_error_in_teardown_classt   s    
z'TestSetups.test_error_in_teardown_classc                s0   G  fdddt j |   ‘ |   j‘ d S )Nc                   s4   e Zd ZdZedd Ze fddZdd ZdS )	zATestSetups.test_class_not_torndown_when_setup_fails.<locals>.TestFc             S   s   t d S )N)r.   )r   r   r   r   r      s    zLTestSetups.test_class_not_torndown_when_setup_fails.<locals>.Test.setUpClassc                s   d _ tdd S )NTr-   )r3   r.   )r   )r   r   r   r(      s    zOTestSetups.test_class_not_torndown_when_setup_fails.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r      s    zJTestSetups.test_class_not_torndown_when_setup_fails.<locals>.Test.test_oneN)r   r   r   r3   r   r   r(   r   r   )r   r   r   r      s   r   )r   r   r   ΪassertFalser3   )r   r   )r   r   Ϊ(test_class_not_torndown_when_setup_fails   s    
z3TestSetups.test_class_not_torndown_when_setup_failsc                sJ   G  fdddt j t  d‘  |   ‘ |   j‘ |   j‘ d S )Nc                   s<   e Zd ZdZdZe fddZe fddZdd ZdS )	zFTestSetups.test_class_not_setup_or_torndown_when_skipped.<locals>.TestFc                s
   d _ d S )NT)Ϊ
classSetUp)r   )r   r   r   r   ©   s    zQTestSetups.test_class_not_setup_or_torndown_when_skipped.<locals>.Test.setUpClassc                s
   d _ d S )NT)r3   )r   )r   r   r   r(   ¬   s    zTTestSetups.test_class_not_setup_or_torndown_when_skipped.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   ―   s    zOTestSetups.test_class_not_setup_or_torndown_when_skipped.<locals>.Test.test_oneN)	r   r   r   r7   r3   r   r   r(   r   r   )r   r   r   r   ¦   s
   r   Zhop)r   r   Ϊskipr   r5   r7   r3   )r   r   )r   r   Ϊ-test_class_not_setup_or_torndown_when_skipped₯   s
    
z8TestSetups.test_class_not_setup_or_torndown_when_skippedc                sl  g  G  fdddt }G  fdddt }G  fdddtj}G  fdddtj}G  fd	d
d
tj}d |_|_d|_|tjd< |tjd< t |df‘}t |df‘}t |df‘}t |df‘}	t |df‘}
t |df‘}t ||||	|
|f‘}|  ‘ }| |‘}|  	|j
d‘ |  	t|jd‘ |  	 ddddddddddddddddg‘ d S ) Nc                   s,   e Zd Ze fddZe fddZdS )zMTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module1c                  s      d‘ d S )NzModule1.setUpModule)Ϊappendr   )Ϊresultsr   r   ΪsetUpModule»   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module1.setUpModulec                  s      d‘ d S )NzModule1.tearDownModule)r:   r   )r;   r   r   ΪtearDownModuleΎ   s    z\TestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module1.tearDownModuleN)r   r   r   Ϊstaticmethodr<   r=   r   )r;   r   r   ΪModule1Ί   s   r?   c                   s,   e Zd Ze fddZe fddZdS )zMTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module2c                  s      d‘ d S )NzModule2.setUpModule)r:   r   )r;   r   r   r<   Γ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module2.setUpModulec                  s      d‘ d S )NzModule2.tearDownModule)r:   r   )r;   r   r   r=   Ζ   s    z\TestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module2.tearDownModuleN)r   r   r   r>   r<   r=   r   )r;   r   r   ΪModule2Β   s   r@   c                   sD   e Zd Ze fddZe fddZ fddZ fddZd	S )
zKTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1c                s      d‘ d S )Nzsetup 1)r:   )r   )r;   r   r   r   Λ   s    zVTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.setUpClassc                s      d‘ d S )Nz
teardown 1)r:   )r   )r;   r   r   r(   Ξ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.tearDownClassc                s      d‘ d S )NzTest1.testOne)r:   )r   )r;   r   r   ΪtestOneΡ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.testOnec                s      d‘ d S )NzTest1.testTwo)r:   )r   )r;   r   r   ΪtestTwoΣ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.testTwoN)r   r   r   r   r   r(   rA   rB   r   )r;   r   r   ΪTest1Κ   s   rC   c                   sD   e Zd Ze fddZe fddZ fddZ fddZd	S )
zKTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2c                s      d‘ d S )Nzsetup 2)r:   )r   )r;   r   r   r   Χ   s    zVTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.setUpClassc                s      d‘ d S )Nz
teardown 2)r:   )r   )r;   r   r   r(   Ϊ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.tearDownClassc                s      d‘ d S )NzTest2.testOne)r:   )r   )r;   r   r   rA   έ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.testOnec                s      d‘ d S )NzTest2.testTwo)r:   )r   )r;   r   r   rB   ί   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.testTwoN)r   r   r   r   r   r(   rA   rB   r   )r;   r   r   r*   Φ   s   r*   c                   sD   e Zd Ze fddZe fddZ fddZ fddZd	S )
zKTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3c                s      d‘ d S )Nzsetup 3)r:   )r   )r;   r   r   r   γ   s    zVTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.setUpClassc                s      d‘ d S )Nz
teardown 3)r:   )r   )r;   r   r   r(   ζ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.tearDownClassc                s      d‘ d S )NzTest3.testOne)r:   )r   )r;   r   r   rA   ι   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.testOnec                s      d‘ d S )NzTest3.testTwo)r:   )r   )r;   r   r   rB   λ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.testTwoN)r   r   r   r   r   r(   rA   rB   r   )r;   r   r   ΪTest3β   s   rD   ΪModulerA   rB   ι   r   zModule1.setUpModulezsetup 1zTest1.testOnezTest1.testTwoz
teardown 1zsetup 2zTest2.testOnezTest2.testTwoz
teardown 2zModule1.tearDownModulezModule2.setUpModulezsetup 3zTest3.testOnezTest3.testTwoz
teardown 3zModule2.tearDownModule)Ϊobjectr   r   r   ΪsysΪmodulesr   r   r   r!   r"   r#   r$   )r   r?   r@   rC   r*   rD   ΪfirstΪsecondZthirdZfourthZfifthZsixthr   r   r%   r   )r;   r   Ϊ1test_setup_teardown_order_with_pathological_suite·   s:    


z<TestSetups.test_setup_teardown_order_with_pathological_suitec                sr   G  fdddt  G dd dtj}d|_ tjd< |  |‘}|   jd‘ |  |j	d‘ |  t
|jd‘ d S )Nc                   s    e Zd ZdZe fddZdS )z,TestSetups.test_setup_module.<locals>.Moduler   c                  s     j d7  _ d S )Nr   )ΪmoduleSetupr   )rE   r   r   r<     s    z8TestSetups.test_setup_module.<locals>.Module.setUpModuleN)r   r   r   rM   r>   r<   r   )rE   r   r   rE   
  s   rE   c               @   s   e Zd Zdd Zdd ZdS )z*TestSetups.test_setup_module.<locals>.Testc             S   s   d S )Nr   )r   r   r   r   r     s    z3TestSetups.test_setup_module.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r     s    z3TestSetups.test_setup_module.<locals>.Test.test_twoN)r   r   r   r   r   r   r   r   r   r     s   r   r   r    r   )rG   r   r   r   rH   rI   r   r!   rM   r"   r#   r$   )r   r   r%   r   )rE   r   Ϊtest_setup_module	  s    

zTestSetups.test_setup_modulec                sΤ   G  fdddt  G fdddtjG dd dtj}d_d|_ tjd< |  |‘}|   jd‘ |   j	d‘ |  |j
d‘ |  j‘ |  j‘ |  t|jd‘ |jd \}}|  t|d	‘ d S )
Nc                   s4   e Zd ZdZdZe fddZe fddZdS )z5TestSetups.test_error_in_setup_module.<locals>.Moduler   c                  s     j d7  _ tdd S )Nr   r-   )rM   r.   r   )rE   r   r   r<   !  s    zATestSetups.test_error_in_setup_module.<locals>.Module.setUpModulec                  s     j d7  _ d S )Nr   )ΪmoduleTornDownr   )rE   r   r   r=   %  s    zDTestSetups.test_error_in_setup_module.<locals>.Module.tearDownModuleN)r   r   r   rM   rO   r>   r<   r=   r   )rE   r   r   rE     s   rE   c                   sD   e Zd ZdZdZe fddZe fddZdd Zdd	 Z	d
S )z3TestSetups.test_error_in_setup_module.<locals>.TestFc                s
   d _ d S )NT)r7   )r   )r   r   r   r   ,  s    z>TestSetups.test_error_in_setup_module.<locals>.Test.setUpClassc                s
   d _ d S )NT)ΪclassTornDown)r   )r   r   r   r(   /  s    zATestSetups.test_error_in_setup_module.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   2  s    z<TestSetups.test_error_in_setup_module.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   4  s    z<TestSetups.test_error_in_setup_module.<locals>.Test.test_twoN)
r   r   r   r7   rP   r   r   r(   r   r   r   )r   r   r   r   )  s   r   c               @   s   e Zd Zdd Zdd ZdS )z4TestSetups.test_error_in_setup_module.<locals>.Test2c             S   s   d S )Nr   )r   r   r   r   r   8  s    z=TestSetups.test_error_in_setup_module.<locals>.Test2.test_onec             S   s   d S )Nr   )r   r   r   r   r   :  s    z=TestSetups.test_error_in_setup_module.<locals>.Test2.test_twoN)r   r   r   r   r   r   r   r   r   r*   7  s   r*   r   r   zsetUpModule (Module))rG   r   r   r   rH   rI   r   r!   rM   rO   r"   r5   r7   rP   r#   r$   r0   )r   r*   r%   r1   r   r   )rE   r   r   Ϊtest_error_in_setup_module  s    
z%TestSetups.test_error_in_setup_modulec             C   sB   G dd dt j}d|_tj dd ‘ |  |‘}|  |jd‘ d S )Nc               @   s   e Zd Zdd Zdd ZdS )z:TestSetups.test_testcase_with_missing_module.<locals>.Testc             S   s   d S )Nr   )r   r   r   r   r   L  s    zCTestSetups.test_testcase_with_missing_module.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   N  s    zCTestSetups.test_testcase_with_missing_module.<locals>.Test.test_twoN)r   r   r   r   r   r   r   r   r   r   K  s   r   rE   r    )	r   r   r   rH   rI   Ϊpopr   r!   r"   )r   r   r%   r   r   r   Ϊ!test_testcase_with_missing_moduleJ  s
    
z,TestSetups.test_testcase_with_missing_modulec                sr   G  fdddt  G dd dtj}d|_ tjd< |  |‘}|   jd‘ |  |j	d‘ |  t
|jd‘ d S )Nc                   s    e Zd ZdZe fddZdS )z/TestSetups.test_teardown_module.<locals>.Moduler   c                  s     j d7  _ d S )Nr   )rO   r   )rE   r   r   r=   Y  s    z>TestSetups.test_teardown_module.<locals>.Module.tearDownModuleN)r   r   r   rO   r>   r=   r   )rE   r   r   rE   W  s   rE   c               @   s   e Zd Zdd Zdd ZdS )z-TestSetups.test_teardown_module.<locals>.Testc             S   s   d S )Nr   )r   r   r   r   r   ^  s    z6TestSetups.test_teardown_module.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   `  s    z6TestSetups.test_teardown_module.<locals>.Test.test_twoN)r   r   r   r   r   r   r   r   r   r   ]  s   r   r   r    r   )rG   r   r   r   rH   rI   r   r!   rO   r"   r#   r$   )r   r   r%   r   )rE   r   Ϊtest_teardown_moduleV  s    

zTestSetups.test_teardown_modulec                sΖ   G  fdddt  G fdddtjG dd dtj}d_d|_ tjd< |  |‘}|   jd‘ |  |j	d‘ |  
j‘ |  
j‘ |  t|jd‘ |jd	 \}}|  t|d
‘ d S )Nc                   s    e Zd ZdZe fddZdS )z8TestSetups.test_error_in_teardown_module.<locals>.Moduler   c                  s     j d7  _ tdd S )Nr   r-   )rO   r.   r   )rE   r   r   r=   m  s    zGTestSetups.test_error_in_teardown_module.<locals>.Module.tearDownModuleN)r   r   r   rO   r>   r=   r   )rE   r   r   rE   k  s   rE   c                   sD   e Zd ZdZdZe fddZe fddZdd Zdd	 Z	d
S )z6TestSetups.test_error_in_teardown_module.<locals>.TestFc                s
   d _ d S )NT)r7   )r   )r   r   r   r   u  s    zATestSetups.test_error_in_teardown_module.<locals>.Test.setUpClassc                s
   d _ d S )NT)rP   )r   )r   r   r   r(   x  s    zDTestSetups.test_error_in_teardown_module.<locals>.Test.tearDownClassc             S   s   d S )Nr   )r   r   r   r   r   {  s    z?TestSetups.test_error_in_teardown_module.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   }  s    z?TestSetups.test_error_in_teardown_module.<locals>.Test.test_twoN)
r   r   r   r7   rP   r   r   r(   r   r   r   )r   r   r   r   r  s   r   c               @   s   e Zd Zdd Zdd ZdS )z7TestSetups.test_error_in_teardown_module.<locals>.Test2c             S   s   d S )Nr   )r   r   r   r   r     s    z@TestSetups.test_error_in_teardown_module.<locals>.Test2.test_onec             S   s   d S )Nr   )r   r   r   r   r     s    z@TestSetups.test_error_in_teardown_module.<locals>.Test2.test_twoN)r   r   r   r   r   r   r   r   r   r*     s   r*   r   r+   r   ztearDownModule (Module))rG   r   r   r   rH   rI   r   r!   rO   r"   Z
assertTruer7   rP   r#   r$   r0   )r   r*   r%   r1   r   r   )rE   r   r   Ϊtest_error_in_teardown_modulej  s    
z(TestSetups.test_error_in_teardown_modulec             C   sz   G dd dt j}|  |‘}|  |jd‘ |  t|jd‘ |  t|jd‘ |jd d }|  t|dt	|j
f ‘ d S )Nc               @   s(   e Zd Zedd Zdd Zdd ZdS )z4TestSetups.test_skiptest_in_setupclass.<locals>.Testc             S   s   t  d‘d S )Nr-   )r   ΪSkipTest)r   r   r   r   r     s    z?TestSetups.test_skiptest_in_setupclass.<locals>.Test.setUpClassc             S   s   d S )Nr   )r   r   r   r   r     s    z=TestSetups.test_skiptest_in_setupclass.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r     s    z=TestSetups.test_skiptest_in_setupclass.<locals>.Test.test_twoN)r   r   r   r   r   r   r   r   r   r   r   r     s   r   r   r   zsetUpClass (%s.%s))r   r   r   r!   r"   r#   r$   Ϊskippedr0   r   r   )r   r   r%   rW   r   r   r   Ϊtest_skiptest_in_setupclass  s    	

z&TestSetups.test_skiptest_in_setupclassc             C   s   G dd dt j}G dd dt}d|_|tjd< |  |‘}|  |jd‘ |  t	|j
d‘ |  t	|jd‘ |jd d }|  t|d‘ d S )Nc               @   s   e Zd Zdd Zdd ZdS )z5TestSetups.test_skiptest_in_setupmodule.<locals>.Testc             S   s   d S )Nr   )r   r   r   r   r   ¦  s    z>TestSetups.test_skiptest_in_setupmodule.<locals>.Test.test_onec             S   s   d S )Nr   )r   r   r   r   r   ¨  s    z>TestSetups.test_skiptest_in_setupmodule.<locals>.Test.test_twoN)r   r   r   r   r   r   r   r   r   r   ₯  s   r   c               @   s   e Zd Zedd ZdS )z7TestSetups.test_skiptest_in_setupmodule.<locals>.Modulec               S   s   t  d‘d S )Nr-   )r   rV   r   r   r   r   r<   ¬  s    zCTestSetups.test_skiptest_in_setupmodule.<locals>.Module.setUpModuleN)r   r   r   r>   r<   r   r   r   r   rE   «  s   rE   r   r   zsetUpModule (Module))r   r   rG   r   rH   rI   r   r!   r"   r#   r$   rW   r0   )r   r   rE   r%   rW   r   r   r   Ϊtest_skiptest_in_setupmodule€  s    

z'TestSetups.test_skiptest_in_setupmodulec                sp   g  G  fdddt }G  fdddtj}d|_|tjd< tj |‘}| ‘  ddddd	g}|  	 |‘ d S )
Nc                   s,   e Zd Ze fddZe fddZdS )zITestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Modulec                  s      d‘ d S )Nr<   )r:   r   )Ϊorderingr   r   r<   Ύ  s    zUTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Module.setUpModulec                  s      d‘ d S )Nr=   )r:   r   )rZ   r   r   r=   Α  s    zXTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Module.tearDownModuleN)r   r   r   r>   r<   r=   r   )rZ   r   r   rE   ½  s   rE   c                   s8   e Zd Ze fddZe fddZ fddZdS )zGTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Testc                s      d‘ d S )Nr   )r:   )r   )rZ   r   r   r   Ζ  s    zRTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Test.setUpClassc                s      d‘ d S )Nr(   )r:   )r   )rZ   r   r   r(   Ι  s    zUTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Test.tearDownClassc                s      d‘ d S )NΪtest_something)r:   )r   )rZ   r   r   r[   Μ  s    zVTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Test.test_somethingN)r   r   r   r   r   r(   r[   r   )rZ   r   r   r   Ε  s   r   r<   r   r[   r(   r=   )
rG   r   r   r   rH   rI   r   r   Ϊdebugr!   )r   rE   r   r   ZexpectedOrderr   )rZ   r   Ϊ.test_suite_debug_executes_setups_and_teardownsΊ  s    

z9TestSetups.test_suite_debug_executes_setups_and_teardownsc          
      s   G  fdddt }G  fdddtj}d|_|tjd< d}xLt|D ]@\ }tj |‘}t 	|g‘}|  
t|‘ | ‘  W d Q R X qHW d S )Nc                   s,   e Zd Ze fddZe fddZdS )zATestSetups.test_suite_debug_propagates_exceptions.<locals>.Modulec                  s    dkrt dd S )Nr   r<   )Ϊ	Exceptionr   )Ϊphaser   r   r<   Ω  s    zMTestSetups.test_suite_debug_propagates_exceptions.<locals>.Module.setUpModulec                  s    dkrt dd S )Nr   r=   )r^   r   )r_   r   r   r=   έ  s    zPTestSetups.test_suite_debug_propagates_exceptions.<locals>.Module.tearDownModuleN)r   r   r   r>   r<   r=   r   )r_   r   r   rE   Ψ  s   rE   c                   s8   e Zd Ze fddZe fddZ fddZdS )z?TestSetups.test_suite_debug_propagates_exceptions.<locals>.Testc                s    dkrt dd S )Nr    r   )r^   )r   )r_   r   r   r   γ  s    zJTestSetups.test_suite_debug_propagates_exceptions.<locals>.Test.setUpClassc                s    dkrt dd S )Nι   r(   )r^   )r   )r_   r   r   r(   η  s    zMTestSetups.test_suite_debug_propagates_exceptions.<locals>.Test.tearDownClassc                s    dkrt dd S )Nr+   r[   )r^   )r   )r_   r   r   r[   λ  s    zNTestSetups.test_suite_debug_propagates_exceptions.<locals>.Test.test_somethingN)r   r   r   r   r   r(   r[   r   )r_   r   r   r   β  s   r   )r<   r=   r   r(   r[   )rG   r   r   r   rH   rI   Ϊ	enumerater   r   r   ZassertRaisesRegexr^   r\   )r   rE   r   ΪmessagesΪmsgZ_suiter   r   )r_   r   Ϊ&test_suite_debug_propagates_exceptionsΧ  s    

z1TestSetups.test_suite_debug_propagates_exceptionsN)r   r   r   r   r   r&   r)   r,   r2   r4   r6   r9   rL   rN   rQ   rS   rT   rU   rX   rY   r]   rd   r   r   r   r   r      s&   !R-(r   Ϊ__main__)r	   rH   r   r   r   r   r   Ϊmainr   r   r   r   Ϊ<module>   s      r