B
    18\w@  γ               @   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)ΪunittestΪ
TestResult)Ϊ_© r   ϊ]/oak/stanford/groups/akundaje/marinovg/programs/Python-3.7.3/Lib/unittest/test/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)ΪresultclassΪstream)r   Ϊ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ΪloadTestsFromTestCaseΪaddTestsr   ΪaddTestΪrun)r   ΪcasesΪsuiteΪcaseΪ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   r0   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'   r0   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   r0   )r    )r!   r   r   r0   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'   r0   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   r0   )r    )ΪTest2r   r   r0   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'   r0   r"   r#   r   )r2   r   r   r2   P   s   r2   r   ι   r   )r   r   r   r)   r/   r*   r+   r,   )r   r-   r   )r!   r2   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   r7   r   r   zsetUpClass (%s.%s))
r   r   r   r)   r*   r+   r,   Ϊstrr$   r&   )r   r7   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   r5   )ΪtornDownr6   )r    )r!   r   r   r0   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&   r;   r'   r0   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   r5   )r;   r6   )r    )r2   r   r   r0      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&   r;   r'   r0   r"   r#   r   )r2   r   r   r2      s   r2   r3   r(   r   r   ztearDownClass (%s.%s))r   r   r   r)   r*   r+   r,   r;   r8   r$   r&   )r   r-   r9   r   r   )r!   r2   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)r6   )r    r   r   r   r      s    zLTestSetups.test_class_not_torndown_when_setup_fails.<locals>.Test.setUpClassc                s   d _ tdd S )NTr5   )r;   r6   )r    )r!   r   r   r0      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&   r;   r'   r   r0   r"   r   )r!   r   r   r!      s   r!   )r   r   r   ΪassertFalser;   )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)r;   )r    )r!   r   r   r0   ¬   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&   r?   r;   r'   r   r0   r"   r   )r!   r   r   r!   ¦   s
   r!   Zhop)r   r   Ϊskipr   r=   r?   r;   )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)rB   r   )rC   r   r   ΪtearDownModuleΎ   s    z\TestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module1.tearDownModuleN)r$   r%   r&   ΪstaticmethodrD   rE   r   )rC   r   r   ΪModule1Ί   s   rG   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)rB   r   )rC   r   r   rD   Γ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module2.setUpModulec                  s      d‘ d S )NzModule2.tearDownModule)rB   r   )rC   r   r   rE   Ζ   s    z\TestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Module2.tearDownModuleN)r$   r%   r&   rF   rD   rE   r   )rC   r   r   ΪModule2Β   s   rH   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)rB   )r    )rC   r   r   r   Λ   s    zVTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.setUpClassc                s      d‘ d S )Nz
teardown 1)rB   )r    )rC   r   r   r0   Ξ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.tearDownClassc                s      d‘ d S )NzTest1.testOne)rB   )r   )rC   r   r   ΪtestOneΡ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.testOnec                s      d‘ d S )NzTest1.testTwo)rB   )r   )rC   r   r   ΪtestTwoΣ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test1.testTwoN)r$   r%   r&   r'   r   r0   rI   rJ   r   )rC   r   r   ΪTest1Κ   s   rK   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)rB   )r    )rC   r   r   r   Χ   s    zVTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.setUpClassc                s      d‘ d S )Nz
teardown 2)rB   )r    )rC   r   r   r0   Ϊ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.tearDownClassc                s      d‘ d S )NzTest2.testOne)rB   )r   )rC   r   r   rI   έ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.testOnec                s      d‘ d S )NzTest2.testTwo)rB   )r   )rC   r   r   rJ   ί   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test2.testTwoN)r$   r%   r&   r'   r   r0   rI   rJ   r   )rC   r   r   r2   Φ   s   r2   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)rB   )r    )rC   r   r   r   γ   s    zVTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.setUpClassc                s      d‘ d S )Nz
teardown 3)rB   )r    )rC   r   r   r0   ζ   s    zYTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.tearDownClassc                s      d‘ d S )NzTest3.testOne)rB   )r   )rC   r   r   rI   ι   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.testOnec                s      d‘ d S )NzTest3.testTwo)rB   )r   )rC   r   r   rJ   λ   s    zSTestSetups.test_setup_teardown_order_with_pathological_suite.<locals>.Test3.testTwoN)r$   r%   r&   r'   r   r0   rI   rJ   r   )rC   r   r   ΪTest3β   s   rL   ΪModulerI   rJ   ι   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   rG   rH   rK   r2   rL   ΪfirstΪsecondZthirdZfourthZfifthZsixthr   r   r-   r   )rC   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   )rM   r   r   rD     s    z8TestSetups.test_setup_module.<locals>.Module.setUpModuleN)r$   r%   r&   rU   rF   rD   r   )rM   r   r   rM   
  s   rM   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   )rO   r   r   r%   rP   rQ   r   r)   rU   r*   r+   r,   )r   r!   r-   r   )rM   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   r5   )rU   r6   r   )rM   r   r   rD   !  s    zATestSetups.test_error_in_setup_module.<locals>.Module.setUpModulec                  s     j d7  _ d S )Nr   )ΪmoduleTornDownr   )rM   r   r   rE   %  s    zDTestSetups.test_error_in_setup_module.<locals>.Module.tearDownModuleN)r$   r%   r&   rU   rW   rF   rD   rE   r   )rM   r   r   rM     s   rM   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)r?   )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   r0   /  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&   r?   rX   r'   r   r0   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   r2   7  s   r2   r   r   zsetUpModule (Module))rO   r   r   r%   rP   rQ   r   r)   rU   rW   r*   r=   r?   rX   r+   r,   r8   )r   r2   r-   r9   r   r   )rM   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!   rM   r(   )	r   r   r%   rP   rQ   Ϊ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   )rW   r   )rM   r   r   rE   Y  s    z>TestSetups.test_teardown_module.<locals>.Module.tearDownModuleN)r$   r%   r&   rW   rF   rE   r   )rM   r   r   rM   W  s   rM   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   )rO   r   r   r%   rP   rQ   r   r)   rW   r*   r+   r,   )r   r!   r-   r   )rM   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   r5   )rW   r6   r   )rM   r   r   rE   m  s    zGTestSetups.test_error_in_teardown_module.<locals>.Module.tearDownModuleN)r$   r%   r&   rW   rF   rE   r   )rM   r   r   rM   k  s   rM   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)r?   )r    )r!   r   r   r   u  s    zATestSetups.test_error_in_teardown_module.<locals>.Test.setUpClassc                s
   d _ d S )NT)rX   )r    )r!   r   r   r0   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&   r?   rX   r'   r   r0   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   r2     s   r2   r   r3   r   ztearDownModule (Module))rO   r   r   r%   rP   rQ   r   r)   rW   r*   Ϊ
assertTruer?   rX   r+   r,   r8   )r   r2   r-   r9   r   r   )rM   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 )Nr5   )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,   Ϊskippedr8   r$   r&   )r   r!   r-   r`   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 )Nr5   )r   r_   r   r   r   r   rD   ¬  s    zCTestSetups.test_skiptest_in_setupmodule.<locals>.Module.setUpModuleN)r$   r%   r&   rF   rD   r   r   r   r   rM   «  s   rM   r   r   zsetUpModule (Module))r   r   rO   r%   rP   rQ   r   r)   r*   r+   r,   r`   r8   )r   r!   rM   r-   r`   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 )NrD   )rB   r   )Ϊorderingr   r   rD   Ύ  s    zUTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Module.setUpModulec                  s      d‘ d S )NrE   )rB   r   )rc   r   r   rE   Α  s    zXTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Module.tearDownModuleN)r$   r%   r&   rF   rD   rE   r   )rc   r   r   rM   ½  s   rM   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   )rB   )r    )rc   r   r   r   Ζ  s    zRTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Test.setUpClassc                s      d‘ d S )Nr0   )rB   )r    )rc   r   r   r0   Ι  s    zUTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Test.tearDownClassc                s      d‘ d S )NΪtest_something)rB   )r   )rc   r   r   rd   Μ  s    zVTestSetups.test_suite_debug_executes_setups_and_teardowns.<locals>.Test.test_somethingN)r$   r%   r&   r'   r   r0   rd   r   )rc   r   r   r!   Ε  s   r!   rD   r   rd   r0   rE   )
rO   r   r   r%   rP   rQ   r   r   Ϊdebugr)   )r   rM   r!   r   ZexpectedOrderr   )rc   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   rD   )Ϊ	Exceptionr   )Ϊphaser   r   rD   Ω  s    zMTestSetups.test_suite_debug_propagates_exceptions.<locals>.Module.setUpModulec                  s    dkrt dd S )Nr   rE   )rg   r   )rh   r   r   rE   έ  s    zPTestSetups.test_suite_debug_propagates_exceptions.<locals>.Module.tearDownModuleN)r$   r%   r&   rF   rD   rE   r   )rh   r   r   rM   Ψ  s   rM   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   )rg   )r    )rh   r   r   r   γ  s    zJTestSetups.test_suite_debug_propagates_exceptions.<locals>.Test.setUpClassc                s    dkrt dd S )Nι   r0   )rg   )r    )rh   r   r   r0   η  s    zMTestSetups.test_suite_debug_propagates_exceptions.<locals>.Test.tearDownClassc                s    dkrt dd S )Nr3   rd   )rg   )r   )rh   r   r   rd   λ  s    zNTestSetups.test_suite_debug_propagates_exceptions.<locals>.Test.test_somethingN)r$   r%   r&   r'   r   r0   rd   r   )rh   r   r   r!   β  s   r!   )rD   rE   r   r0   rd   )rO   r   r   r%   rP   rQ   Ϊ	enumerater   r   r   ΪassertRaisesRegexrg   re   )r   rM   r!   ΪmessagesΪmsgZ_suiter   r   )rh   r   Ϊ&test_suite_debug_propagates_exceptionsΧ  s    

z1TestSetups.test_suite_debug_propagates_exceptionsN)r$   r%   r&   r   r   r.   r1   r4   r:   r<   r>   rA   rT   rV   rY   r[   r\   r^   ra   rb   rf   rn   r   r   r   r   r      s&   !R-(r   Ϊ__main__)r   rP   r   r   r   r   r$   Ϊmainr   r   r   r   Ϊ<module>   s      r