B
    18™\' ã               @   sð   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZ d dlmZ d dlZd dlmZmZmZmZmZ d dlmZ e d¡Ze d¡Ze d¡ZG d	d
„ d
eƒZG dd„ dejeeƒZedkrìe  ¡  dS )é    N)Údeepcopy)Úsupport)ÚTestEqualityÚTestHashingÚLoggingResultÚLegacyLoggingResultÚ#ResultWithNoStartTestRunStopTestRun)Úcaptured_stderrÚfoozfoo.barÚquuxc               @   sD   e Zd ZdZG dd„ dejƒZG dd„ deƒZG dd„ dejƒZdS )	ÚTestz5Keep these TestCase classes out of the main namespacec               @   s   e Zd Zdd„ Zdd„ ZdS )zTest.Fooc             C   s   d S )N© )Úselfr   r   ú[/oak/stanford/groups/akundaje/marinovg/programs/Python-3.7.3/Lib/unittest/test/test_case.pyÚrunTest!   ó    zTest.Foo.runTestc             C   s   d S )Nr   )r   r   r   r   Útest1"   r   zTest.Foo.test1N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   ÚFoo    s   r   c               @   s   e Zd Zdd„ ZdS )zTest.Barc             C   s   d S )Nr   )r   r   r   r   Útest2%   r   zTest.Bar.test2N)r   r   r   r   r   r   r   r   ÚBar$   s   r   c                   s8   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Z‡  ZS )
zTest.LoggingTestCasez!A test case which logs its calls.c                s   t tj| ƒ d¡ || _d S )NÚtest)Úsuperr   ÚLoggingTestCaseÚ__init__Úevents)r   r   )Ú	__class__r   r   r   *   s    zTest.LoggingTestCase.__init__c             C   s   | j  d¡ d S )NÚsetUp)r   Úappend)r   r   r   r   r   .   s    zTest.LoggingTestCase.setUpc             C   s   | j  d¡ d S )Nr   )r   r    )r   r   r   r   r   1   s    zTest.LoggingTestCase.testc             C   s   | j  d¡ d S )NÚtearDown)r   r    )r   r   r   r   r!   4   s    zTest.LoggingTestCase.tearDown)	r   r   r   Ú__doc__r   r   r   r!   Ú__classcell__r   r   )r   r   r   '   s
   r   N)	r   r   r   r"   ÚunittestÚTestCaser   r   r   r   r   r   r   r      s   r   c               @   sˆ  e Zd Ze d¡e d¡fgZe d¡e d¡fe d¡e d¡fe d¡e d¡fg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*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Z d6d7„ Z!d8d9„ Z"d:d;„ Z#d<d=„ Z$d>d?„ Z%d@dA„ Z&dBdC„ Z'dDdE„ Z(e) *e+j,j-dFkdG¡dHdI„ ƒZ.e) *e+j,j-dFkdG¡dJdK„ ƒZ/dLdM„ Z0dNdO„ Z1dPdQ„ Z2dRdS„ Z3dTdU„ Z4dVdW„ Z5dXdY„ Z6dZd[„ Z7d\d]„ Z8d^d_„ Z9d`da„ Z:dbdc„ Z;ddde„ Z<dfdg„ Z=dhdi„ Z>djdk„ Z?dldm„ Z@dndo„ ZAdpdq„ ZBdrds„ ZCdtdu„ ZDdvdw„ ZEdxdy„ ZFdzd{„ ZGd|d}„ ZHd~d„ ZId€d„ ZJd‚dƒ„ ZKd„d…„ ZLd†d‡„ ZMdˆd‰„ ZNdŠd‹„ ZOdŒd„ ZPdŽd„ ZQdd‘„ ZRd’d“„ ZSd”d•„ ZTd–d—„ ZUd˜d™„ ZVdšd›„ ZWeXjYdœd„ ƒZZdždŸ„ Z[d d¡„ Z\d¢d£„ Z]d¤d¥„ Z^d¦d§„ Z_d¨d©„ Z`dªd«„ Zad¬d­„ Zbd®d¯„ Zcd°d±„ Zdd²d³„ Zed´dµ„ Zfd¶d·„ Zgd¸d¹„ Zhdºd»„ Zid¼d½„ Zjd¾d¿„ ZkeljmdÀdÁ„ ƒZndÂdÃ„ ZodÄS )ÅÚTest_TestCaser   r   r   c          	   C   s†   G dd„ dt jƒ}|  |ƒ  ¡ dd … d¡ t  ¡ }| dd¡ | |j¡ | dd¡ W d Q R X |  t¡ | ¡  W d Q R X d S )Nc               @   s   e Zd Zdd„ Zdd„ ZdS )z3Test_TestCase.test_init__no_test_name.<locals>.Testc             S   s
   t ƒ ‚d S )N)ÚMyException)r   r   r   r   r   T   r   z;Test_TestCase.test_init__no_test_name.<locals>.Test.runTestc             S   s   d S )Nr   )r   r   r   r   r   U   r   z8Test_TestCase.test_init__no_test_name.<locals>.Test.testN)r   r   r   r   r   r   r   r   r   r   S   s   r   ióÿÿÿz.Test.runTesté   é   )r$   r%   ÚassertEqualÚidÚassertRaisesÚfailureExceptionÚAttributeErrorÚrun)r   r   r   r   r   r   Útest_init__no_test_nameR   s    z%Test_TestCase.test_init__no_test_namec             C   s2   G dd„ dt jƒ}|  |dƒ ¡ dd … d¡ d S )Nc               @   s   e Zd Zdd„ Zdd„ ZdS )z7Test_TestCase.test_init__test_name__valid.<locals>.Testc             S   s
   t ƒ ‚d S )N)r'   )r   r   r   r   r   i   r   z?Test_TestCase.test_init__test_name__valid.<locals>.Test.runTestc             S   s   d S )Nr   )r   r   r   r   r   j   r   z<Test_TestCase.test_init__test_name__valid.<locals>.Test.testN)r   r   r   r   r   r   r   r   r   r   h   s   r   r   iöÿÿÿz
.Test.test)r$   r%   r*   r+   )r   r   r   r   r   Útest_init__test_name__validg   s    z)Test_TestCase.test_init__test_name__validc             C   sB   G dd„ dt jƒ}y|dƒ W n tk
r2   Y nX |  d¡ d S )Nc               @   s   e Zd Zdd„ Zdd„ ZdS )z9Test_TestCase.test_init__test_name__invalid.<locals>.Testc             S   s
   t ƒ ‚d S )N)r'   )r   r   r   r   r   t   r   zATest_TestCase.test_init__test_name__invalid.<locals>.Test.runTestc             S   s   d S )Nr   )r   r   r   r   r   u   r   z>Test_TestCase.test_init__test_name__invalid.<locals>.Test.testN)r   r   r   r   r   r   r   r   r   r   s   s   r   ÚtestfoozFailed to raise ValueError)r$   r%   Ú
ValueErrorÚfail)r   r   r   r   r   Útest_init__test_name__invalidr   s    z+Test_TestCase.test_init__test_name__invalidc             C   s*   G dd„ dt jƒ}|  |dƒ ¡ d¡ d S )Nc               @   s   e Zd Zdd„ ZdS )z.Test_TestCase.test_countTestCases.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r   ‚   r   z3Test_TestCase.test_countTestCases.<locals>.Foo.testN)r   r   r   r   r   r   r   r   r      s   r   r   é   )r$   r%   r*   ÚcountTestCases)r   r   r   r   r   Útest_countTestCases€   s    z!Test_TestCase.test_countTestCasesc             C   s2   G dd„ dt jƒ}|ƒ  ¡ }|  t|ƒt j¡ d S )Nc               @   s   e Zd Zdd„ ZdS )z1Test_TestCase.test_defaultTestResult.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r   Œ   s    z9Test_TestCase.test_defaultTestResult.<locals>.Foo.runTestN)r   r   r   r   r   r   r   r   r   ‹   s   r   )r$   r%   ÚdefaultTestResultr*   ÚtypeÚ
TestResult)r   r   Úresultr   r   r   Útest_defaultTestResultŠ   s    
z$Test_TestCase.test_defaultTestResultc                sL   g }t |ƒ}G ‡ fdd„dtjƒ‰ ˆ |ƒ |¡ ddddg}|  ||¡ d S )Nc                   s   e Zd Z‡‡ fdd„Z‡  ZS )z>Test_TestCase.test_run_call_order__error_in_setUp.<locals>.Fooc                s   t ˆ | ƒ ¡  tdƒ‚d S )Nzraised by Foo.setUp)r   r   ÚRuntimeError)r   )r   r   r   r   r   ž   s    zDTest_TestCase.test_run_call_order__error_in_setUp.<locals>.Foo.setUp)r   r   r   r   r#   r   )r   )r   r   r      s   r   Ú	startTestr   ÚaddErrorÚstopTest)r   r   r   r/   r*   )r   r   r<   Úexpectedr   )r   r   Ú#test_run_call_order__error_in_setUp™   s    z1Test_TestCase.test_run_call_order__error_in_setUpc                sF   g }G ‡ fdd„dt jƒ‰ ˆ |ƒ ¡  ddddddg}|  ||¡ d S )	Nc                   s&   e Zd Zdd„ Z‡‡ fdd„Z‡  ZS )zMTest_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.Fooc             S   s
   t | jƒS )N)r   r   )r   r   r   r   r9   «   s    z_Test_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.Foo.defaultTestResultc                s   t ˆ | ƒ ¡  tdƒ‚d S )Nzraised by Foo.setUp)r   r   r>   )r   )r   r   r   r   r   ®   s    zSTest_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.Foo.setUp)r   r   r   r9   r   r#   r   )r   )r   r   r   ª   s   r   ÚstartTestRunr?   r   r@   rA   ÚstopTestRun)r   r   r/   r*   )r   r   rB   r   )r   r   Ú2test_run_call_order__error_in_setUp_default_result§   s    z@Test_TestCase.test_run_call_order__error_in_setUp_default_resultc                sP   g }t |ƒ}G ‡ fdd„dtjƒ‰ ddddddg}ˆ |ƒ |¡ |  ||¡ d S )	Nc                   s   e Zd Z‡‡ fdd„Z‡  ZS )z=Test_TestCase.test_run_call_order__error_in_test.<locals>.Fooc                s   t ˆ | ƒ ¡  tdƒ‚d S )Nzraised by Foo.test)r   r   r>   )r   )r   r   r   r   r   Ã   s    zBTest_TestCase.test_run_call_order__error_in_test.<locals>.Foo.test)r   r   r   r   r#   r   )r   )r   r   r   Â   s   r   r?   r   r   r!   r@   rA   )r   r   r   r/   r*   )r   r   r<   rB   r   )r   r   Ú"test_run_call_order__error_in_test¾   s    z0Test_TestCase.test_run_call_order__error_in_testc                sJ   g }G ‡ fdd„dt jƒ‰ ddddddd	d
g}ˆ |ƒ ¡  |  ||¡ d S )Nc                   s&   e Zd Zdd„ Z‡‡ fdd„Z‡  ZS )zLTest_TestCase.test_run_call_order__error_in_test_default_result.<locals>.Fooc             S   s
   t | jƒS )N)r   r   )r   r   r   r   r9   Ò   s    z^Test_TestCase.test_run_call_order__error_in_test_default_result.<locals>.Foo.defaultTestResultc                s   t ˆ | ƒ ¡  tdƒ‚d S )Nzraised by Foo.test)r   r   r>   )r   )r   r   r   r   r   Õ   s    zQTest_TestCase.test_run_call_order__error_in_test_default_result.<locals>.Foo.test)r   r   r   r9   r   r#   r   )r   )r   r   r   Ñ   s   r   rD   r?   r   r   r!   r@   rA   rE   )r   r   r/   r*   )r   r   rB   r   )r   r   Ú1test_run_call_order__error_in_test_default_resultÎ   s    z?Test_TestCase.test_run_call_order__error_in_test_default_resultc                sP   g }t |ƒ}G ‡ fdd„dtjƒ‰ ddddddg}ˆ |ƒ |¡ |  ||¡ d S )	Nc                   s   e Zd Z‡‡ fdd„Z‡  ZS )z?Test_TestCase.test_run_call_order__failure_in_test.<locals>.Fooc                s   t ˆ | ƒ ¡  |  d¡ d S )Nzraised by Foo.test)r   r   r4   )r   )r   r   r   r   r   ê   s    zDTest_TestCase.test_run_call_order__failure_in_test.<locals>.Foo.test)r   r   r   r   r#   r   )r   )r   r   r   é   s   r   r?   r   r   r!   Ú
addFailurerA   )r   r   r   r/   r*   )r   r   r<   rB   r   )r   r   Ú$test_run_call_order__failure_in_testå   s    z2Test_TestCase.test_run_call_order__failure_in_testc                sJ   G ‡ fdd„dt jƒ‰ ddddddd	d
g}g }ˆ |ƒ ¡  |  ||¡ d S )Nc                   s&   e Zd Zdd„ Z‡‡ fdd„Z‡  ZS )zNTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Fooc             S   s
   t | jƒS )N)r   r   )r   r   r   r   r9   ÷   s    z`Test_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.defaultTestResultc                s   t ˆ | ƒ ¡  |  d¡ d S )Nzraised by Foo.test)r   r   r4   )r   )r   r   r   r   r   ù   s    zSTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.test)r   r   r   r9   r   r#   r   )r   )r   r   r   ö   s   r   rD   r?   r   r   r!   rI   rA   rE   )r   r   r/   r*   )r   rB   r   r   )r   r   Ú3test_run_call_order__failure_in_test_default_resultô   s    zATest_TestCase.test_run_call_order__failure_in_test_default_resultc                sP   g }t |ƒ}G ‡ fdd„dtjƒ‰ ˆ |ƒ |¡ ddddddg}|  ||¡ d S )	Nc                   s   e Zd Z‡‡ fdd„Z‡  ZS )zATest_TestCase.test_run_call_order__error_in_tearDown.<locals>.Fooc                s   t ˆ | ƒ ¡  tdƒ‚d S )Nzraised by Foo.tearDown)r   r!   r>   )r   )r   r   r   r   r!     s    zJTest_TestCase.test_run_call_order__error_in_tearDown.<locals>.Foo.tearDown)r   r   r   r!   r#   r   )r   )r   r   r     s   r   r?   r   r   r!   r@   rA   )r   r   r   r/   r*   )r   r   r<   rB   r   )r   r   Ú&test_run_call_order__error_in_tearDown
  s    
z4Test_TestCase.test_run_call_order__error_in_tearDownc                sJ   G ‡ fdd„dt jƒ‰ g }ˆ |ƒ ¡  ddddddd	d
g}|  ||¡ d S )Nc                   s&   e Zd Zdd„ Z‡‡ fdd„Z‡  ZS )zPTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.Fooc             S   s
   t | jƒS )N)r   r   )r   r   r   r   r9     s    zbTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.Foo.defaultTestResultc                s   t ˆ | ƒ ¡  tdƒ‚d S )Nzraised by Foo.tearDown)r   r!   r>   )r   )r   r   r   r   r!     s    zYTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.Foo.tearDown)r   r   r   r9   r!   r#   r   )r   )r   r   r     s   r   rD   r?   r   r   r!   r@   rA   rE   )r   r   r/   r*   )r   r   rB   r   )r   r   Ú5test_run_call_order__error_in_tearDown_default_result  s    

zCTest_TestCase.test_run_call_order__error_in_tearDown_default_resultc             C   s"   G dd„ dt jƒ}|dƒ ¡  d S )Nc               @   s   e Zd Zdd„ Zdd„ ZdS )z=Test_TestCase.test_run_call_order_default_result.<locals>.Fooc             S   s   t ƒ S )N)r   )r   r   r   r   r9   -  s    zOTest_TestCase.test_run_call_order_default_result.<locals>.Foo.defaultTestResultc             S   s   d S )Nr   )r   r   r   r   r   /  s    zBTest_TestCase.test_run_call_order_default_result.<locals>.Foo.testN)r   r   r   r9   r   r   r   r   r   r   ,  s   r   r   )r$   r%   r/   )r   r   r   r   r   Ú"test_run_call_order_default_result*  s    z0Test_TestCase.test_run_call_order_default_resultc                s4   G ‡ fdd„dt jƒ‰ ˆ |ƒ |¡ |  ||¡ d S )Nc                   s   e Zd Z‡‡ fdd„Z‡  ZS )z6Test_TestCase._check_call_order__subtests.<locals>.Fooc                sŒ   t ˆ | ƒ ¡  xpdD ]h}| j|dR |dkr8|  d¡ x8dD ]0}| j|d || dkrdtdƒ‚W d Q R X q>W W d Q R X qW dd	  d S )
N)r6   r)   r(   )Úir6   Úfailure)r)   r(   )Újé   zraised by Foo.testr   )r   r   ÚsubTestr4   r>   )r   rO   rQ   )r   r   r   r   r   6  s    


$z;Test_TestCase._check_call_order__subtests.<locals>.Foo.test)r   r   r   r   r#   r   )r   )r   r   r   5  s   r   )r   r   r/   r*   )r   r<   r   Úexpected_eventsr   )r   r   Ú_check_call_order__subtests4  s    z)Test_TestCase._check_call_order__subtestsc             C   s8   g }t |ƒ}dddddddddddg}|  |||¡ d S )	Nr?   r   r   r!   ÚaddSubTestFailureÚaddSubTestSuccessr@   rA   )r   rU   )r   r   r<   rB   r   r   r   Útest_run_call_order__subtestsL  s    
z+Test_TestCase.test_run_call_order__subtestsc             C   s.   g }t |ƒ}ddddddg}|  |||¡ d S )Nr?   r   r   r!   rI   rA   )r   rU   )r   r   r<   rB   r   r   r   Ú$test_run_call_order__subtests_legacyU  s
    z2Test_TestCase.test_run_call_order__subtests_legacyc                s4   G ‡ fdd„dt jƒ‰ ˆ |ƒ |¡ |  ||¡ d S )Nc                   s   e Zd Z‡‡ fdd„Z‡  ZS )z>Test_TestCase._check_call_order__subtests_success.<locals>.Fooc                s^   t ˆ | ƒ ¡  xJdD ]B}| j|d, x$dD ]}| j|d W d Q R X q,W W d Q R X qW d S )N)r6   r)   )rO   )r)   r(   )rQ   )r   r   rS   )r   rO   rQ   )r   r   r   r   r   `  s    

zCTest_TestCase._check_call_order__subtests_success.<locals>.Foo.test)r   r   r   r   r#   r   )r   )r   r   r   _  s   r   )r   r   r/   r*   )r   r<   r   rT   r   )r   r   Ú#_check_call_order__subtests_success^  s    	z1Test_TestCase._check_call_order__subtests_successc             C   s<   g }t |ƒ}ddddgddg  ddg }|  |||¡ d S )	Nr?   r   r   r!   rR   rW   Ú
addSuccessrA   )r   rZ   )r   r   r<   rB   r   r   r   Ú%test_run_call_order__subtests_successk  s    z3Test_TestCase.test_run_call_order__subtests_successc             C   s.   g }t |ƒ}ddddddg}|  |||¡ d S )Nr?   r   r   r!   r[   rA   )r   rZ   )r   r   r<   rB   r   r   r   Ú,test_run_call_order__subtests_success_legacyu  s
    z:Test_TestCase.test_run_call_order__subtests_success_legacyc                sV   g }t |ƒ}d|_G ‡ fdd„dtjƒ‰ dddddd	g}ˆ |ƒ |¡ |  ||¡ d S )
NTc                   s   e Zd Z‡‡ fdd„Z‡  ZS )zATest_TestCase.test_run_call_order__subtests_failfast.<locals>.Fooc          	      s`   t ˆ | ƒ ¡  | jdd |  d¡ W d Q R X | jdd |  d¡ W d Q R X |  d¡ d S )Nr6   )rO   rP   r)   )r   r   rS   r4   )r   )r   r   r   r   r   ƒ  s    zFTest_TestCase.test_run_call_order__subtests_failfast.<locals>.Foo.test)r   r   r   r   r#   r   )r   )r   r   r   ‚  s   r   r?   r   r   r!   rV   rA   )r   Úfailfastr   r   r/   r*   )r   r   r<   rB   r   )r   r   Ú&test_run_call_order__subtests_failfast}  s    	z4Test_TestCase.test_run_call_order__subtests_failfastc                sV   g ‰ G ‡ fdd„dt jƒ}t  ¡ }d|_t  |¡}| |¡ dddg}|  ˆ |¡ d S )Nc                   s0   e Zd Z‡ fdd„Z‡ fdd„Z‡ fdd„ZdS )z1Test_TestCase.test_subtests_failfast.<locals>.Fooc          	      s,   |   ¡  ˆ  d¡ W d Q R X ˆ  d¡ d S )NÚa1Úa2)rS   r    )r   )r   r   r   Útest_a•  s    
z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_ac          	      sJ   |   ¡  ˆ  d¡ W d Q R X |   ¡  |  d¡ W d Q R X ˆ  d¡ d S )NÚb1rP   Zb2)rS   r    r4   )r   )r   r   r   Útest_bš  s
    

z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_bc                s   ˆ   d¡ d S )NÚc)r    )r   )r   r   r   Útest_c¡  s    z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_cN)r   r   r   rb   rd   rf   r   )r   r   r   r   ”  s   r   Tr`   ra   rc   )r$   r%   r;   r^   Ú	makeSuiter/   r*   )r   r   r<   ÚsuiterB   r   )r   r   Útest_subtests_failfast  s    


z$Test_TestCase.test_subtests_failfastc                s:   g ‰ G ‡ fdd„dt jƒ}|dƒ ¡  |  ˆ ddg¡ d S )Nc                   s   e Zd Z‡ fdd„ZdS )z.Test_TestCase.test_subtests_debug.<locals>.Fooc          	      s,   ˆ   d¡ |  ¡  ˆ   d¡ W d Q R X d S )Nz	test casez	subtest 1)r    rS   )r   )r   r   r   rb   ±  s    

z5Test_TestCase.test_subtests_debug.<locals>.Foo.test_aN)r   r   r   rb   r   )r   r   r   r   °  s   r   rb   z	test casez	subtest 1)r$   r%   Údebugr*   )r   r   r   )r   r   Útest_subtests_debug¬  s    z!Test_TestCase.test_subtests_debugc             C   s(   G dd„ dt jƒ}|  |dƒjt¡ d S )Nc               @   s   e Zd Zdd„ ZdS )z9Test_TestCase.test_failureException__default.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r   Á  s    z>Test_TestCase.test_failureException__default.<locals>.Foo.testN)r   r   r   r   r   r   r   r   r   À  s   r   r   )r$   r%   ÚassertIsr-   ÚAssertionError)r   r   r   r   r   Útest_failureException__default¿  s    z,Test_TestCase.test_failureException__defaultc             C   sX   g }t |ƒ}G dd„ dtjƒ}|  |dƒjt¡ |dƒ |¡ dddg}|  ||¡ d S )Nc               @   s   e Zd Zdd„ ZeZdS )zMTest_TestCase.test_failureException__subclassing__explicit_raise.<locals>.Fooc             S   s
   t ƒ ‚d S )N)r>   )r   r   r   r   r   Ñ  s    zRTest_TestCase.test_failureException__subclassing__explicit_raise.<locals>.Foo.testN)r   r   r   r   r>   r-   r   r   r   r   r   Ð  s   r   r   r?   rI   rA   )r   r$   r%   rl   r-   r>   r/   r*   )r   r   r<   r   rB   r   r   r   Ú2test_failureException__subclassing__explicit_raiseÌ  s    
z@Test_TestCase.test_failureException__subclassing__explicit_raisec             C   sX   g }t |ƒ}G dd„ dtjƒ}|  |dƒjt¡ |dƒ |¡ dddg}|  ||¡ d S )Nc               @   s   e Zd Zdd„ ZeZdS )zMTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.Fooc             S   s   |   d¡ d S )Nr
   )r4   )r   r   r   r   r   è  s    zRTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.Foo.testN)r   r   r   r   r>   r-   r   r   r   r   r   ç  s   r   r   r?   rI   rA   )r   r$   r%   rl   r-   r>   r/   r*   )r   r   r<   r   rB   r   r   r   Ú2test_failureException__subclassing__implicit_raiseã  s    
z@Test_TestCase.test_failureException__subclassing__implicit_raisec             C   s    G dd„ dt jƒ}|ƒ  ¡  d S )Nc               @   s   e Zd Zdd„ ZdS )z%Test_TestCase.test_setUp.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r   ÷  s    z-Test_TestCase.test_setUp.<locals>.Foo.runTestN)r   r   r   r   r   r   r   r   r   ö  s   r   )r$   r%   r   )r   r   r   r   r   Ú
test_setUpõ  s    zTest_TestCase.test_setUpc             C   s    G dd„ dt jƒ}|ƒ  ¡  d S )Nc               @   s   e Zd Zdd„ ZdS )z(Test_TestCase.test_tearDown.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r      s    z0Test_TestCase.test_tearDown.<locals>.Foo.runTestN)r   r   r   r   r   r   r   r   r   ÿ  s   r   )r$   r%   r!   )r   r   r   r   r   Útest_tearDownþ  s    zTest_TestCase.test_tearDownc             C   s(   G dd„ dt jƒ}|  |ƒ  ¡ t¡ d S )Nc               @   s   e Zd Zdd„ ZdS )z"Test_TestCase.test_id.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r     s    z*Test_TestCase.test_id.<locals>.Foo.runTestN)r   r   r   r   r   r   r   r   r     s   r   )r$   r%   ÚassertIsInstancer+   Ústr)r   r   r   r   r   Útest_id  s    zTest_TestCase.test_idc                s\   g ‰t ˆƒ‰ G ‡ ‡fdd„dtjƒ}|dƒ ¡ }|  |ˆ ¡ ddddddg}|  ˆ|¡ d S )	Nc                   s$   e Zd Z‡fdd„Z‡ fdd„ZdS )z;Test_TestCase.test_run__uses_defaultTestResult.<locals>.Fooc                s   ˆ   d¡ d S )Nr   )r    )r   )r   r   r   r     s    z@Test_TestCase.test_run__uses_defaultTestResult.<locals>.Foo.testc                s   ˆ S )Nr   )r   )ÚdefaultResultr   r   r9      s    zMTest_TestCase.test_run__uses_defaultTestResult.<locals>.Foo.defaultTestResultN)r   r   r   r   r9   r   )rv   r   r   r   r     s   r   r   rD   r?   r[   rA   rE   )r   r$   r%   r/   rl   r*   )r   r   r<   rB   r   )rv   r   r   Ú test_run__uses_defaultTestResult  s    z.Test_TestCase.test_run__uses_defaultTestResultc             C   s8   G dd„ dt jƒ}t  ¡ }|dƒ |¡}|  ||¡ d S )Nc               @   s   e Zd Zdd„ ZdS )z9Test_TestCase.test_run__returns_given_result.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r   0  s    z>Test_TestCase.test_run__returns_given_result.<locals>.Foo.testN)r   r   r   r   r   r   r   r   r   /  s   r   r   )r$   r%   r;   r/   rl   )r   r   r<   Úretvalr   r   r   Útest_run__returns_given_result-  s    z,Test_TestCase.test_run__returns_given_resultc                sD   t  ¡ ‰ t  ¡ ‰G ‡ ‡fdd„dt jƒ}|dƒˆ ƒ}|  |ˆ¡ d S )Nc                   s"   e Zd Zdd„ Z‡ ‡fdd„ZdS )zKTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Fooc             S   s   d S )Nr   )r   r   r   r   r   @  s    zPTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.testc                s   |   |ˆ ¡ ˆS )N)rl   )r   r<   )ÚresultInÚ	resultOutr   r   r/   C  s    zOTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.runN)r   r   r   r   r/   r   )rz   r{   r   r   r   ?  s   r   r   )r$   r;   r%   rl   )r   r   rx   r   )rz   r{   r   Ú0test_call__invoking_an_instance_delegates_to_run;  s
    z>Test_TestCase.test_call__invoking_an_instance_delegates_to_runc             C   s   |   |  ¡ ¡ d S )N)ÚassertIsNoneÚshortDescription)r   r   r   r   Ú$testShortDescriptionWithoutDocstringL  s    z2Test_TestCase.testShortDescriptionWithoutDocstringr)   z)Docstrings are omitted with -O2 and abovec             C   s   |   |  ¡ d ¡ dS )z7Tests shortDescription() for a method with a docstring.N)r*   r~   )r   r   r   r   Ú(testShortDescriptionWithOneLineDocstringO  s    z6Test_TestCase.testShortDescriptionWithOneLineDocstringc             C   s   |   |  ¡ d¡ dS )zîTests shortDescription() for a method with a longer docstring.

        This method ensures that only the first line of a docstring is
        returned used in the short description, no matter how long the
        whole thing is.
        z>Tests shortDescription() for a method with a longer docstring.N)r*   r~   )r   r   r   r   Ú*testShortDescriptionWithMultiLineDocstringW  s    	z8Test_TestCase.testShortDescriptionWithMultiLineDocstringc                sV   G dd„ dt ƒ‰ ˆ ƒ ˆ ƒ  }}|  ||k¡ d‡ fdd„	}|  ˆ |¡ |  ||¡ d S )Nc               @   s   e Zd ZdZdS )z7Test_TestCase.testAddTypeEqualityFunc.<locals>.SadSnakez)Dummy class for test_addTypeEqualityFunc.N)r   r   r   r"   r   r   r   r   ÚSadSnakef  s   r‚   c                s    t | ƒt |ƒ  koˆ kS   S )N)r:   )ÚaÚbÚmsg)r‚   r   r   ÚAllSnakesCreatedEqualj  s    zDTest_TestCase.testAddTypeEqualityFunc.<locals>.AllSnakesCreatedEqual)N)ÚobjectÚassertFalseÚaddTypeEqualityFuncr*   )r   Ús1Ús2r†   r   )r‚   r   ÚtestAddTypeEqualityFunce  s    z%Test_TestCase.testAddTypeEqualityFuncc             C   s,   t ƒ }|  ||¡ |  | j| j|t ƒ ¡ d S )N)r‡   rl   r,   r-   )r   Úthingr   r   r   ÚtestAssertIsr  s    zTest_TestCase.testAssertIsc             C   s,   t ƒ }|  |t ƒ ¡ |  | j| j||¡ d S )N)r‡   ÚassertIsNotr,   r-   )r   r   r   r   r   ÚtestAssertIsNotw  s    zTest_TestCase.testAssertIsNotc             C   s(   g }|   |t¡ |  | j| j |t¡ d S )N)rs   Úlistr,   r-   Údict)r   r   r   r   r   ÚtestAssertIsInstance|  s    z"Test_TestCase.testAssertIsInstancec             C   s(   g }|   |t¡ |  | j| j |t¡ d S )N)ÚassertNotIsInstancer’   r,   r-   r‘   )r   r   r   r   r   ÚtestAssertNotIsInstance‚  s    z%Test_TestCase.testAssertNotIsInstancec             C   sè   ddddœ}|   dd¡ |   dddd	g¡ |   d
|¡ |  dd¡ |  dddd	g¡ |  d|¡ |  | j| j dd¡ |  | j| j dddd	g¡ |  | j| j d|¡ |  | j| jdd¡ |  | j| jdddd	g¡ |  | j| jd|¡ d S )NZbananaZgrassÚfish)ÚmonkeyÚcowÚsealrƒ   Úabcr)   r6   r(   r—   Údr   ZotterÚxé   Zelephantre   r˜   )ÚassertInÚassertNotInr,   r-   )r   Zanimalsr   r   r   ÚtestAssertInˆ  s    zTest_TestCase.testAssertInc          
   C   s¤  t  ¡  t  dt¡ |  i i ¡ |  i ddi¡ |  ddiddi¡ |  ddidddœ¡ |  dddœdddœ¡ |  | j¡ |  ddii ¡ W d Q R X |  | j¡ |  ddiddi¡ W d Q R X |  | j¡ |  ddiddi¡ W d Q R X |  | j¡ |  dddœddi¡ W d Q R X |  | j¡ |  dddœddi¡ W d Q R X d	 d
d„ tdƒD ƒ¡}|  | j¡ |  d|iddi¡ W d Q R X W d Q R X d S )NÚignorerƒ   r6   r)   )rƒ   r„   Úonere   )rƒ   re   Ú c             s   s   | ]}t |ƒV  qd S )N)Úchr)Ú.0rO   r   r   r   ú	<genexpr>¶  s    z=Test_TestCase.testAssertDictContainsSubset.<locals>.<genexpr>éÿ   r
   u   ï¿½)	ÚwarningsÚcatch_warningsÚsimplefilterÚDeprecationWarningÚassertDictContainsSubsetr,   r-   ÚjoinÚrange)r   r¢   r   r   r   ÚtestAssertDictContainsSubset  s(      z*Test_TestCase.testAssertDictContainsSubsetc          	   C   sš  di i fg g ft ƒ t ƒ ftƒ tƒ fg}xÄ|D ]¼\}}y|  ||¡ W n( | jk
rl   |  d||f ¡ Y nX y| j||dd W n( | jk
rª   |  d||f ¡ Y nX y|  ||d¡ W q, | jk
ræ   |  d||f ¡ Y q,X q,W dg fi t ƒ ft dd	gƒtdd
gƒftddgƒt d
dgƒft ddgƒt ddgƒfg}xT|D ]L\}}|  | j| j||¡ |  | j| j||d¡ | j| j| j||dd qFW d S )N)r   r   zassertEqual(%r, %r) failedr
   )r…   z$assertEqual(%r, %r) with msg= failedz/assertEqual(%r, %r) with third parameter failedr   r   r6   r)   é   r(   )ÚsetÚ	frozensetr*   r-   r4   r,   )r   Zequal_pairsrƒ   r„   Zunequal_pairsr   r   r   ÚtestAssertEqual»  s<    
zTest_TestCase.testAssertEqualc             C   s  |   g g ¡ |  dd¡ |  g d¡ ddg g}g }|  tjj| j ||¡ |  tjj| j t|ƒt|ƒ¡ |  tjj| j|t|ƒ¡ | |¡ |   ||¡ |  t|ƒt|ƒ¡ |  |t|ƒ¡ |  t|ƒ|¡ |  | j| j |t|ƒ¡ |  | j| jt|ƒ|¡ |  | j| j d |¡ |  | j| jd t|ƒ¡ |  | j| jd t|ƒ¡ |  | j| j dd¡ |  | j| jdd¡ |  | j| jdd¡ |  	i i ¡ ddi}i }|  tjj| j	||¡ | 
|¡ |  	||¡ d|d< |  tjj| j	||d¡ |  | j| j	d |¡ |  | j| j	g |¡ |  | j| j	dd¡ d S )Nr   r   rƒ   r6   rœ   zThese are unequal)ÚassertListEqualÚassertTupleEqualÚassertSequenceEqualr,   r$   r%   r-   ÚtupleÚextendÚassertDictEqualÚupdate)r   rƒ   r„   re   r›   r   r   r   ÚtestEqualityà  sT    








zTest_TestCase.testEqualityc          
   C   sÊ  |   | jd¡ ddd  }ddd  }d t t |¡ ¡ t |¡ ¡ ¡¡}tj	j
t|ƒd f }t|ƒd | _y|  ||¡ W n. | jk
r® } z|jd	 }W d d }~X Y nX |  d
¡ |  t|ƒt|ƒ¡ |  ||¡ t|ƒd | _y|  ||¡ W n0 | jk
r( } z|jd	 }W d d }~X Y nX |  d
¡ |  t|ƒt|ƒ¡ |  ||¡ d | _y|  ||¡ W n0 | jk
rš } z|jd	 }W d d }~X Y nX |  d
¡ |  t|ƒt|ƒ¡ |  ||¡ d S )Ni€  rƒ   rœ   i   r„   Ú
r6   r)   r   z!assertSequenceEqual did not fail.)r*   ÚmaxDiffr­   ÚdifflibÚndiffÚpprintÚpformatÚ
splitlinesr$   ÚcaseÚDIFF_OMITTEDÚlenr¶   r-   Úargsr4   Ú
assertLessrž   ÚassertGreaterrŸ   )r   Úseq1Úseq2ÚdiffÚomittedÚer…   r   r   r   ÚtestAssertSequenceEqualMaxDiff  s<    


z,Test_TestCase.testAssertSequenceEqualMaxDiffc             C   sr   d| _ |  dd¡}tjjtdƒ }|  |d| ¡ d | _ |  dd¡}|  |d¡ d| _ |  dd¡}|  |d¡ d S )Nr6   r
   ÚbarÚfoobarr   )r½   Ú_truncateMessager$   rÃ   rÄ   rÅ   r*   )r   ÚmessagerÌ   r   r   r   ÚtestTruncateMessage<  s    z!Test_TestCase.testTruncateMessagec          
   C   sp   t  d¡}dd„ }||_y| i ddi¡ W n4 | jk
r` } z|  t|ƒd¡ W d d }~X Y nX |  d¡ d S )Nr*   c             S   s   dS )Nr
   r   )r…   rË   r   r   r   ÚtruncateL  s    z<Test_TestCase.testAssertDictEqualTruncates.<locals>.truncater6   r   r
   zassertDictEqual did not fail)r$   r%   rÑ   r¹   r-   r*   rt   r4   )r   r   rÔ   rÍ   r   r   r   ÚtestAssertDictEqualTruncatesJ  s    
"z*Test_TestCase.testAssertDictEqualTruncatesc          
   C   sl   t  d¡}dd„ }||_y| dd¡ W n4 | jk
r\ } z|  t|ƒd¡ W d d }~X Y nX |  d¡ d S )Nr*   c             S   s   dS )Nr
   r   )r…   rË   r   r   r   rÔ   X  s    zATest_TestCase.testAssertMultiLineEqualTruncates.<locals>.truncater
   rÏ   z!assertMultiLineEqual did not fail)r$   r%   rÑ   ÚassertMultiLineEqualr-   r*   rt   r4   )r   r   rÔ   rÍ   r   r   r   Ú!testAssertMultiLineEqualTruncatesV  s    
"z/Test_TestCase.testAssertMultiLineEqualTruncatesc          	      s0  ˆ  ˆjd¡ d ˆ_ˆj‰ dˆ_ˆ ‡ ‡fdd„¡ d}ˆ ˆj¡}ˆ  |d |d ¡ W d Q R X ˆ dt|jƒ¡ ˆ  |d |d ¡ d	}d
d„ }ˆj	‰|ˆ_	ˆ ‡‡fdd„¡ |d |d  }}ˆ ˆj¡}ˆ  ||¡ W d Q R X ˆ 
dt|jƒ¡ ˆ  t|jƒd||f ¡ ˆ  |d |d ¡ d S )Ni   é    c                  s   t ˆdˆ ƒS )NÚ_diffThreshold)Úsetattrr   )Úold_thresholdr   r   r   Ú<lambda>k  r   z=Test_TestCase.testAssertEqual_diffThreshold.<locals>.<lambda>Zxxxxxxxxxxxxxxxxrƒ   r„   ú^Z@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc             S   s   t dƒ‚d S )Nzthis should not be raised)ÚSystemError)rÒ   rË   r   r   r   ÚexplodingTruncationy  s    zHTest_TestCase.testAssertEqual_diffThreshold.<locals>.explodingTruncationc                  s   t ˆdˆ ƒS )NrÑ   )rÚ   r   )Úold_truncater   r   r   rÜ   }  r   z%r != %r)r*   rÙ   r½   Ú
addCleanupr,   r-   rž   rt   Ú	exceptionrÑ   rŸ   )r   ÚsÚcmrß   rŠ   r‹   r   )rÛ   rà   r   r   ÚtestAssertEqual_diffThresholdb  s*    z+Test_TestCase.testAssertEqual_diffThresholdc          	      s\  ˆj ‰ dˆ_ ˆ ‡ ‡fdd„¡ d}|d |d  }}ˆ ˆj¡}ˆ ||¡ W d Q R X d}ˆ t|jƒd||f ¡ ˆ |d |d ¡ d	}|d | |d |  }}ˆ ˆj¡}ˆ ||¡ W d Q R X d
}ˆ t|jƒd||||f ¡ d}|d | |d |  }}ˆ ˆj¡}ˆ ||¡ W d Q R X d}d}ˆ t|jƒd||||f ¡ d S )Nr   c                  s   t ˆdˆ ƒS )NrÙ   )rÚ   r   )rÛ   r   r   r   rÜ   Š  r   z7Test_TestCase.testAssertEqual_shorten.<locals>.<lambda>Zdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrƒ   r„   zKxxxx[35 chars]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz'%sa' != '%sb'Z2yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzxxxx[85 chars]xxxxxxxxxxxz'%sa%s' != '%sb%s'Zdyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzxxxx[91 chars]xxxxxz6yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy[56 chars]yyyy)rÙ   rá   r,   r-   r*   rt   râ   )r   rã   rŠ   r‹   rä   re   Úpr›   r   )rÛ   r   r   ÚtestAssertEqual_shorten†  s.    z%Test_TestCase.testAssertEqual_shortenc             C   s  t ƒ }|  dddgdddg¡ |  dddgdddg¡ |  ||dddg|dd|df¡ |  ddddgddd	dg¡ |  | j| jddgdgd
  dgd
 ddg ¡ |  | j| jddddgddd	dg¡ |  | j| jdgddg¡ |  | j| jddgdg¡ |  | j| jdddgddg¡ |  ddgddgdgdddgddgg¡ |  tddg ddgƒtddg ddgƒ¡ |  | j| jg tddddtƒ g¡ |  ddiddigddiddig¡ |  ddtg gtg ddg¡ |  | j| jg tg ddddtƒ g¡ |  | j| jdggdgg¡ |  | j| jdddgddg¡ |  | j| jdddddgddd	dg¡ |  | j| jdddid d	gddid	d g¡ ddhddhg}|d d d… }|  ||¡ ttj	 
dd¡ƒ}ddddh}|  ||¡ tj	 
g gg ¡}|  |ddg fg¡ ttj	 dd¡ƒ}ddddh}|  ||¡ d S )Nr6   r)   r(   r
   rÏ   ÚbazÚ2rƒ   Téd   é
   é   r   r   Frœ   y              @y               @r„   éÿÿÿÿZaaabccdZabbbcce)r(   r6   rƒ   )r6   r(   r„   )r6   r   r›   )r   r6   rÍ   )r‡   ÚassertCountEqualr,   r-   ÚiterÚdivmodr²   r±   r$   ÚutilÚ_count_diff_all_purposer*   Ú_count_diff_hashable)r   rƒ   r„   ÚdiffsrB   r   r   r   ÚtestAssertCountEqual£  sV     $($z"Test_TestCase.testAssertCountEqualc             C   s„  t ƒ }t ƒ }|  ||¡ |  | j| jd |¡ |  | j| jg |¡ |  | j| j|d ¡ |  | j| j|g ¡ t dgƒ}t ƒ }|  | j| j||¡ t dgƒ}t dgƒ}|  ||¡ t dgƒ}t ddgƒ}|  | j| j||¡ t dgƒ}tddgƒ}|  | j| j||¡ t ddgƒ}tddgƒ}|  ||¡ t ƒ }d}|  | j| j||¡ |  | j| j||¡ t ddgƒ}t dgƒ}|  | j| j||¡ d S )Nrƒ   r„   r
   )r   r6   )r)   r(   )r   r°   )r±   ÚassertSetEqualr,   r-   r²   )r   Úset1Úset2r   r   r   ÚtestAssertSetEqualá  s:    





z Test_TestCase.testAssertSetEqualc             C   s  |   dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  | j| j dd¡ |  | j| j dd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |   dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  | j| j dd¡ |  | j| j dd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |   dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  | j| j dd¡ |  | j| j dd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |   dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  dd¡ |  | j| j dd¡ |  | j| j dd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ |  | j| jdd¡ d S )	Nr)   r6   gš™™™™™ñ?g      ð?ZbugZants   bugs   ant)rÈ   ÚassertGreaterEqualrÇ   ÚassertLessEqualr,   r-   )r   r   r   r   ÚtestInequality	  sb    zTest_TestCase.testInequalityc          
   C   sl   d}d}d}d | _ y|  ||¡ W nD | jk
rf } z$t|ƒ dd¡d }|  ||¡ W d d }~X Y nX d S )Nzxhttp://www.python.org/doc/2.3/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...]
z×http://www.python.org/doc/2.4.1/lib/module-unittest.html
test case
    A test case is the smallest unit of testing. [...] You may provide your
    own implementation that does not subclass from TestCase, of course.
aá  - http://www.python.org/doc/2.3/lib/module-unittest.html
?                             ^
+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
?                             ^^^
  test case
-     A test case is the smallest unit of testing. [...]
+     A test case is the smallest unit of testing. [...] You may provide your
?                                                       +++++++++++++++++++++
+     own implementation that does not subclass from TestCase, of course.
r¼   r6   )r½   rÖ   r-   rt   Úsplitr*   )r   Úsample_textÚrevised_sample_textÚsample_text_errorrÍ   Úerrorr   r   r   ÚtestAssertMultiLineEqualC  s    z&Test_TestCase.testAssertMultiLineEqualc          
   C   sf   d}d}d}y|   ||¡ W nD | jk
r` } z$t|ƒ dd¡d }|   ||¡ W d d }~X Y nX d S )Nzladen swallows fly slowlyzunladen swallows fly quicklyzr- laden swallows fly slowly
?                    ^^^^
+ unladen swallows fly quickly
? ++                   ^^^^^
r¼   r6   )r*   r-   rt   rý   )r   rþ   rÿ   r   rÍ   r  r   r   r   ÚtestAssertEqualSingleLineb  s    z'Test_TestCase.testAssertEqualSingleLinec          
      sH  t jjr‡ fdd„}ndd„ }|ƒ * ˆ  ˆ j¡ ˆ  dd¡ W d Q R X W d Q R X |ƒ  ˆ  dd¡ W d Q R X ddg}ddg}|ƒ * ˆ  ˆ j¡ ˆ  ||¡ W d Q R X W d Q R X |ƒ 2 ˆ  ˆ j¡ ˆ  t	|ƒt	|ƒ¡ W d Q R X W d Q R X |ƒ . ˆ  ˆ j¡ ˆ  
|t	|ƒ¡ W d Q R X W d Q R X |ƒ . ˆ  ˆ j¡ ˆ  
t	|ƒ|¡ W d Q R X W d Q R X |ƒ * ˆ  ˆ j¡ ˆ  
dd¡ W d Q R X W d Q R X |ƒ 2 ˆ  ˆ j¡ ˆ  t|ƒt|ƒ¡ W d Q R X W d Q R X ˆ  ˆ j¡ ˆ  |t	|ƒ¡ W d Q R X ˆ  ˆ j¡ ˆ  t	|ƒ|¡ W d Q R X ddg}dg}ˆ  ˆ j¡ ˆ  ||¡ W d Q R X ˆ  ˆ j¡ ˆ  t	|ƒt	|ƒ¡ W d Q R X ˆ  ˆ j¡ ˆ  
|t	|ƒ¡ W d Q R X ˆ  ˆ j¡ ˆ  
t	|ƒ|¡ W d Q R X ˆ  ˆ j¡ ˆ  t|ƒt|ƒ¡ W d Q R X dg}ddg}ˆ  ˆ j¡ ˆ  ||¡ W d Q R X ˆ  ˆ j¡ ˆ  t	|ƒt	|ƒ¡ W d Q R X ˆ  ˆ j¡ ˆ  
|t	|ƒ¡ W d Q R X ˆ  ˆ j¡ ˆ  
t	|ƒ|¡ W d Q R X ˆ  ˆ j¡ ˆ  t|ƒt|ƒ¡ W d Q R X |ƒ 2 ˆ  ˆ j¡ ˆ  ddiddi¡ W d Q R X W d Q R X ˆ  ˆ j¡ ˆ  i ddi¡ W d Q R X ˆ  ˆ j¡ ˆ  ddii ¡ W d Q R X ˆ  ˆ j¡ ˆ  ddgdddg¡ W d Q R X |ƒ  ˆ  ddgddg¡ W d Q R X |ƒ 2 ˆ  ˆ j¡ ˆ  ddgddg¡ W d Q R X W d Q R X |ƒ 6 ˆ  ˆ j¡ ˆ  ddg gddg g¡ W d Q R X W d Q R X d S )Nc                  s   ˆ   td¡S )Nz#Comparison between bytes and string)ÚassertWarnsRegexÚBytesWarningr   )r   r   r   Úbytes_warningt  s    z=Test_TestCase.testEqualityBytesWarning.<locals>.bytes_warningc               S   s   t  ¡ S )N)Ú
contextlibÚ	ExitStackr   r   r   r   r  x  s    rƒ   ó   ar   )ÚsysÚflagsr  r,   r-   r*   ÚassertNotEqualr´   rµ   r·   r¶   rö   r±   r¹   rî   )r   r  rƒ   r„   r   )r   r   ÚtestEqualityBytesWarningr  s~      ($$ (( (z&Test_TestCase.testEqualityBytesWarningc             C   s<   |   d ¡ |  | j| j d¡ |  d¡ |  | j| jd ¡ d S )NFzDjZoPloGears on Rails)r}   r,   r-   ÚassertIsNotNone)r   r   r   r   ÚtestAssertIsNone¾  s    

zTest_TestCase.testAssertIsNonec             C   s$   |   dd¡ |  | j| j dd¡ d S )NZ
asdfabasdfzab+ZsaaasZaaaa)ÚassertRegexr,   r-   )r   r   r   r   ÚtestAssertRegexÄ  s    zTest_TestCase.testAssertRegexc          	      sº   G dd„ dt ƒ‰ ‡ fdd„}|  ˆ |¡ |  tˆ f|¡ | jttddd |  | j¡ |  ˆ dd	„ ¡ W d Q R X |  t¡ |  ˆ d ¡ W d Q R X |  ˆ ¡ |  t|¡ W d Q R X d S )
Nc               @   s   e Zd ZdS )z=Test_TestCase.testAssertRaisesCallable.<locals>.ExceptionMockN)r   r   r   r   r   r   r   ÚExceptionMockÊ  s   r  c                  s   ˆ dƒ‚d S )Nz	We expectr   r   )r  r   r   ÚStubÌ  s    z4Test_TestCase.testAssertRaisesCallable.<locals>.StubÚ19é   )Úbasec               S   s   dS )Nr   r   r   r   r   r   rÜ   Õ  r   z8Test_TestCase.testAssertRaisesCallable.<locals>.<lambda>)Ú	Exceptionr,   r3   Úintr-   ÚassertWarnsr«   )r   r  r   )r  r   ÚtestAssertRaisesCallableÉ  s    z&Test_TestCase.testAssertRaisesCallablec                sl  G dd„ dt ƒ‰ ‡ fdd„}|  ˆ ¡ |ƒ  W d Q R X |  tˆ f¡}|ƒ  W d Q R X |  |jˆ ¡ |  |jjd d¡ |  t¡ tddd	 W d Q R X |  | j¡ |  ˆ ¡ W d Q R X W d Q R X |  	| jd
¡  | jˆ d
d W d Q R X W d Q R X |  
td
¡6 |  t¡  | jˆ dd W d Q R X W d Q R X W d Q R X |  ˆ ¡ |  t|¡ W d Q R X d S )Nc               @   s   e Zd ZdS )z<Test_TestCase.testAssertRaisesContext.<locals>.ExceptionMockN)r   r   r   r   r   r   r   r  Þ  s   r  c                  s   ˆ dƒ‚d S )Nz	We expectr   r   )r  r   r   r  à  s    z3Test_TestCase.testAssertRaisesContext.<locals>.Stubr   z	We expectr  r  )r  rÐ   )r…   é*   )rÐ   )r  r,   r3   rs   râ   r*   rÆ   r  r-   ÚassertRaisesRegexr  r«   rm   )r   r  rä   r   )r  r   ÚtestAssertRaisesContextÝ  s,    z%Test_TestCase.testAssertRaisesContextc          	   C   sª   |   t¡ |   ¡  W d Q R X |   t¡ |   d¡ W d Q R X |   t¡ |   t¡ W d Q R X |   t¡ |   tdf¡ W d Q R X |   t¡ |   ttf¡ W d Q R X d S )Nr6   )r,   Ú	TypeErrorr‡   r3   )r   r   r   r   ÚtestAssertRaisesNoExceptionTypeþ  s    z-Test_TestCase.testAssertRaisesNoExceptionTypec             C   s4   dd„ }t  |¡}|  t|¡ |  |t  |¡¡ d S )Nc               S   s&   yt ‚W n t k
r    t ‚Y nX d S )N)r3   r   r   r   r   Úfunc  s    z4Test_TestCase.testAssertRaisesRefcount.<locals>.func)r
  Úgetrefcountr,   r3   r*   )r   r   Zrefcountr   r   r   ÚtestAssertRaisesRefcount
  s    
z&Test_TestCase.testAssertRaisesRefcountc          	      sf   G dd„ dt ƒ‰ ‡ fdd„}|  ˆ t d¡|¡ |  ˆ d|¡ |  t¡ |  ˆ dd ¡ W d Q R X d S )Nc               @   s   e Zd ZdS )z:Test_TestCase.testAssertRaisesRegex.<locals>.ExceptionMockN)r   r   r   r   r   r   r   r    s   r  c                  s   ˆ dƒ‚d S )Nz	We expectr   r   )r  r   r   r    s    z1Test_TestCase.testAssertRaisesRegex.<locals>.Stubzexpect$)r  r  ÚreÚcompiler  r«   )r   r  r   )r  r   ÚtestAssertRaisesRegex  s    z#Test_TestCase.testAssertRaisesRegexc             C   sÂ   |   | jd| j tt d¡dd„ ¡ |   | jd| j tddd„ ¡ |   | jd¡" | j tddd W d Q R X W d Q R X |  td¡8 |  t¡" | j tdd	d
 W d Q R X W d Q R X W d Q R X d S )Nz"^Exception not raised by <lambda>$rœ   c               S   s   d S )Nr   r   r   r   r   rÜ   '  r   z8Test_TestCase.testAssertNotRaisesRegex.<locals>.<lambda>c               S   s   d S )Nr   r   r   r   r   rÜ   +  r   rÐ   Úexpect)r…   r  )rÐ   )	r  r-   r  r#  r$  r  r«   r,   rm   )r   r   r   r   ÚtestAssertNotRaisesRegex#  s    

z&Test_TestCase.testAssertNotRaisesRegexc             C   s*   G dd„ dt ƒ}|  t| j|dd„ ¡ d S )Nc               @   s   e Zd ZdS )z>Test_TestCase.testAssertRaisesRegexInvalidRegex.<locals>.MyExcN)r   r   r   r   r   r   r   ÚMyExc8  s   r(  c               S   s   dS )NTr   r   r   r   r   rÜ   :  r   zATest_TestCase.testAssertRaisesRegexInvalidRegex.<locals>.<lambda>)r  r,   r  r  )r   r(  r   r   r   Ú!testAssertRaisesRegexInvalidRegex6  s    z/Test_TestCase.testAssertRaisesRegexInvalidRegexc             C   s*   G dd„ dt ƒ}|  t| j|dd„ ¡ d S )Nc               @   s   e Zd ZdS )z>Test_TestCase.testAssertWarnsRegexInvalidRegex.<locals>.MyWarnN)r   r   r   r   r   r   r   ÚMyWarn>  s   r*  c               S   s   dS )NTr   r   r   r   r   rÜ   @  r   z@Test_TestCase.testAssertWarnsRegexInvalidRegex.<locals>.<lambda>)ÚWarningr,   r  r  )r   r*  r   r   r   Ú testAssertWarnsRegexInvalidRegex<  s    z.Test_TestCase.testAssertWarnsRegexInvalidRegexc          	   C   sB   dd„ }|   | jd| j td|¡ |   | jd| j tt d¡|¡ d S )Nc               S   s   t dƒ‚d S )NZ
Unexpected)r  r   r   r   r   r  C  s    z9Test_TestCase.testAssertRaisesRegexMismatch.<locals>.Stubz*"\^Expected\$" does not match "Unexpected"z
^Expected$)r  r-   r  r#  r$  )r   r  r   r   r   ÚtestAssertRaisesRegexMismatchB  s    z+Test_TestCase.testAssertRaisesRegexMismatchc          	      sj   G dd„ dt ƒ‰ ‡ fdd„}d}|  ˆ ¡}| ||ƒ W d Q R X |j}|  |ˆ ¡ |  |jd |¡ d S )Nc               @   s   e Zd ZdS )z=Test_TestCase.testAssertRaisesExcValue.<locals>.ExceptionMockN)r   r   r   r   r   r   r   r  R  s   r  c                s   ˆ | ƒ‚d S )Nr   )r
   )r  r   r   r  U  s    z4Test_TestCase.testAssertRaisesExcValue.<locals>.Stubzparticular valuer   )r  r,   râ   rs   r*   rÆ   )r   r  ÚvÚctxrÍ   r   )r  r   ÚtestAssertRaisesExcValueQ  s    
z&Test_TestCase.testAssertRaisesExcValuec          	   C   sÒ   |   t¡ |  ¡  W d Q R X |   t¡ |  t¡ W d Q R X |   t¡ |  dd¡ W d Q R X |   t¡ |  td¡ W d Q R X |   t¡ |  tdfd¡ W d Q R X |   t¡ |  ttfd¡ W d Q R X d S )Nr6   r&  )r,   r  r  r3   r‡   )r   r   r   r   Ú$testAssertRaisesRegexNoExceptionType`  s    z2Test_TestCase.testAssertRaisesRegexNoExceptionTypec          
   C   s  dd„ }|   t|¡ |   t|¡ |   ttf|¡ | j ttjdtd |  | j¡ |   tdd„ ¡ W d Q R X |   t¡ |   td ¡ W d Q R X t ¡ 6 t dt¡ |  | j¡ |   t|¡ W d Q R X W d Q R X t ¡ 4 t dt¡ |  t¡ |   t|¡ W d Q R X W d Q R X d S )	Nc               S   s   t  dt¡ d S )Nr
   )r¨   ÚwarnÚRuntimeWarningr   r   r   r   Ú_runtime_warno  s    z<Test_TestCase.testAssertWarnsCallable.<locals>._runtime_warnr
   )Úcategoryc               S   s   dS )Nr   r   r   r   r   r   rÜ   {  r   z7Test_TestCase.testAssertWarnsCallable.<locals>.<lambda>Údefaultr  )	r  r3  r«   r¨   r2  r,   r-   r©   rª   )r   r4  r   r   r   ÚtestAssertWarnsCallablen  s$    
 
z%Test_TestCase.testAssertWarnsCallablec             C   s.  dd„ }t  |¡d }|  t¡}|ƒ  W d Q R X |  ttf¡}|ƒ  W d Q R X |  |jt¡ |  |jjd d¡ |  	d|j
¡ |  |j|d ¡ |  t¡ |ƒ  |ƒ  W d Q R X |  t¡ tjdtd W d Q R X |  | j¡ |  t¡ W d Q R X W d Q R X |  | jd¡  | jtdd	 W d Q R X W d Q R X |  td¡6 |  t¡  | jtd
d W d Q R X W d Q R X W d Q R X t ¡ F t dt¡ |  | j¡" |  t¡ |ƒ  W d Q R X W d Q R X W d Q R X t ¡ D t dt¡ |  t¡" |  t¡ |ƒ  W d Q R X W d Q R X W d Q R X d S )Nc               S   s   t  dt¡ d S )Nr
   )r¨   r2  r3  r   r   r   r   r4  Ž  s    z;Test_TestCase.testAssertWarnsContext.<locals>._runtime_warnr6   r   r
   ztest_case.py)r5  rÐ   )r…   r  )rÐ   r6  r  )ÚinspectÚgetsourcelinesr  r3  r«   rs   Úwarningr*   rÆ   rž   ÚfilenameÚlinenor¨   r2  r,   r-   r  r  rm   r©   rª   )r   r4  Ú_runtime_warn_linenorä   r   r   r   ÚtestAssertWarnsContext‹  sF    
$
z$Test_TestCase.testAssertWarnsContextc          	   C   sÎ   |   t¡ |  ¡  W d Q R X |   t¡ |  d¡ W d Q R X |   t¡ |  t¡ W d Q R X |   t¡ |  tdf¡ W d Q R X |   t¡ |  ttf¡ W d Q R X |   t¡ |  ttf¡ W d Q R X d S )Nr6   )r,   r  r  r‡   ÚUserWarningr  )r   r   r   r   ÚtestAssertWarnsNoExceptionType¼  s    z,Test_TestCase.testAssertWarnsNoExceptionTypec          
   C   s&  dd„ }|   td|d¡ |  | j¡ |   tddd„ ¡ W d Q R X |  t¡ |   tdd ¡ W d Q R X t ¡ : t dt¡ |  | j¡ |   td|d¡ W d Q R X W d Q R X |  | j¡ |   td|d¡ W d Q R X t ¡ > t d	t¡ |  t| jf¡ |   td|d¡ W d Q R X W d Q R X d S )
Nc             S   s   t  | t¡ d S )N)r¨   r2  r3  )r…   r   r   r   r4  Ë  s    zATest_TestCase.testAssertWarnsRegexCallable.<locals>._runtime_warnzo+Úfooxc               S   s   dS )Nr   r   r   r   r   r   rÜ   Ò  r   z<Test_TestCase.testAssertWarnsRegexCallable.<locals>.<lambda>r6  Úbarzr  )	r  r3  r,   r-   r  r«   r¨   r©   rª   )r   r4  r   r   r   ÚtestAssertWarnsRegexCallableÊ  s*    

z*Test_TestCase.testAssertWarnsRegexCallablec             C   s  dd„ }t  |¡d }|  td¡}|dƒ W d Q R X |  |jt¡ |  |jjd d¡ |  d|j	¡ |  |j
|d ¡ |  | j¡ |  td¡ W d Q R X W d Q R X |  | jd¡" | jtddd	 W d Q R X W d Q R X |  td¡8 |  t¡" | jtdd
d W d Q R X W d Q R X W d Q R X t ¡ J t dt¡ |  | j¡& |  td¡ |dƒ W d Q R X W d Q R X W d Q R X |  | j¡& |  td¡ |dƒ W d Q R X W d Q R X t ¡ N t dt¡ |  t| jf¡& |  td¡ |dƒ W d Q R X W d Q R X W d Q R X d S )Nc             S   s   t  | t¡ d S )N)r¨   r2  r3  )r…   r   r   r   r4  í  s    z@Test_TestCase.testAssertWarnsRegexContext.<locals>._runtime_warnr6   zo+rA  r   ztest_case.pyrÐ   )r…   r  )rÐ   r6  rB  r  )r8  r9  r  r3  rs   r:  r*   rÆ   rž   r;  r<  r,   r-   r  r«   rm   r¨   r©   rª   )r   r4  r=  rä   r   r   r   ÚtestAssertWarnsRegexContextë  s>    
&
z)Test_TestCase.testAssertWarnsRegexContextc          	   C   sø   |   t¡ |  ¡  W d Q R X |   t¡ |  t¡ W d Q R X |   t¡ |  dd¡ W d Q R X |   t¡ |  td¡ W d Q R X |   t¡ |  tdfd¡ W d Q R X |   t¡ |  ttfd¡ W d Q R X |   t¡ |  ttfd¡ W d Q R X d S )Nr6   r&  )r,   r  r  r?  r‡   r  )r   r   r   r   Ú#testAssertWarnsRegexNoExceptionType  s    z1Test_TestCase.testAssertWarnsRegexNoExceptionTypec          	   c   s,   t ƒ }d V  W d Q R X |  | ¡ d¡ d S )Nr£   )r	   r*   Úgetvalue)r   Úbufr   r   r   ÚassertNoStderr(  s    zTest_TestCase.assertNoStderrc             C   sf   |   t|ƒt|ƒ¡ xLt||ƒD ]>\}}|  |tj¡ x&| ¡ D ]\}}|   t||ƒ|¡ q@W q W d S )N)r*   rÅ   Úziprs   ÚloggingÚ	LogRecordÚitemsÚgetattr)r   ÚrecordsÚmatchesZrecÚmatchÚkr.  r   r   r   ÚassertLogRecords.  s
    zTest_TestCase.assertLogRecordsc          
   C   sd   |   ¡ R |  ¡ }t d¡ t d¡ W d Q R X |  |jdg¡ |  |j	ddig¡ W d Q R X d S )NÚ1ré   z
INFO:foo:1Únamer
   )
rH  Ú
assertLogsÚlog_fooÚinfoÚ
log_foobarrj   r*   ÚoutputrR  rN  )r   rä   r   r   r   ÚtestAssertLogsDefaults5  s    


z$Test_TestCase.testAssertLogsDefaultsc          
   C   sv   |   ¡ d |  ¡ $}t d¡ t d¡ t d¡ W d Q R X |  |j	ddg¡ |  
|jddiddig¡ W d Q R X d S )	NrS  ré   Ú3z
INFO:foo:1zWARNING:quux:3rT  r
   r   )rH  rU  rV  rW  rX  rj   Úlog_quuxr:  r*   rY  rR  rN  )r   rä   r   r   r   Ú!testAssertLogsTwoMatchingMessages>  s    



z/Test_TestCase.testAssertLogsTwoMatchingMessagesc          
   C   sz   |   ¡ h | j|d$}t d¡ t d¡ t d¡ W d Q R X |  |j	ddg¡ |  
|jddidd	ig¡ W d Q R X d S )
N)ÚlevelrS  ré   r[  zERROR:foo.bar:2zCRITICAL:quux:3rT  zfoo.barr   )rH  rU  rV  r:  rX  r  r\  Úcriticalr*   rY  rR  rN  )r   r^  rä   r   r   r   ÚcheckAssertLogsPerLevelI  s    


z%Test_TestCase.checkAssertLogsPerLevelc             C   s   |   tj¡ |   d¡ d S )NÚERROR)r`  rJ  ra  )r   r   r   r   ÚtestAssertLogsPerLevelT  s    z$Test_TestCase.testAssertLogsPerLevelc             C   s¤   |   ¡ ’ | jddj}| j|dd$}t d¡ t d¡ t d¡ W d Q R X |  |j	ddg¡ |  
|jdd	idd
ig¡ W d Q R X |  |j	dg¡ W d Q R X d S )NÚDEBUG)r^  rS  ré   r[  z
INFO:foo:1zDEBUG:foo.bar:2rT  r
   zfoo.barzWARNING:quux:3)rH  rU  rV  rW  rX  rj   r\  r:  r*   rY  rR  rN  )r   ÚloggerZouter_cmrä   r   r   r   ÚcheckAssertLogsPerLoggerX  s    


z&Test_TestCase.checkAssertLogsPerLoggerc             C   s   |   t d¡¡ |   d¡ d S )Nr
   )re  rJ  Ú	getLogger)r   r   r   r   ÚtestAssertLogsPerLoggerf  s    z%Test_TestCase.testAssertLogsPerLoggerc             C   sD   |   ¡ 2 |  | j¡ |  ¡  W d Q R X W d Q R X W d Q R X d S )N)rH  r,   r-   rU  )r   r   r   r   ÚtestAssertLogsFailureNoLogsj  s    

z)Test_TestCase.testAssertLogsFailureNoLogsc             C   sR   |   ¡ @ |  | j¡( | jdd t d¡ W d Q R X W d Q R X W d Q R X d S )NÚWARNING)r^  rS  )rH  r,   r-   rU  rV  rW  )r   r   r   r   Ú!testAssertLogsFailureLevelTooHighq  s    
z/Test_TestCase.testAssertLogsFailureLevelTooHighc             C   sV   | j ddd> |  | j¡& |   d¡ t d¡ W d Q R X W d Q R X W d Q R X d S )Nr   ra  )r^  r
   rS  )rU  r,   r-   r\  r  )r   r   r   r   Ú&testAssertLogsFailureMismatchingLoggerx  s    z4Test_TestCase.testAssertLogsFailureMismatchingLoggerc             C   sØ   | j df| jdf| jdf| jdf| jdf| jdf| jdf| jdf| jdf| j	df| j
tdd„ ff| jdf| jtd	d
dtd	d
ddff| jtddd„ ff| jdff}x.|D ]&\}}|  t¡ ||Ž  W dQ R X qªW dS )zY
        Test that the deprecated methods raise a DeprecationWarning. See #9424.
        )r(   r°   )r(   r(   )g       @g       @)g      @g      @)Tc             S   s   dd S )Ng…ëQ¸	@Zspamr   )Ú_r   r   r   rÜ     r   z9Test_TestCase.testDeprecatedMethodNames.<locals>.<lambda>)Fr6   r)   )rƒ   r„   r(   )rƒ   r„   re   r
   c               S   s   i d S )Nr
   r   r   r   r   r   rÜ   ’  r   )rÏ   rÏ   N)ÚfailIfEqualÚassertNotEqualsÚfailUnlessEqualÚassertEqualsÚfailUnlessAlmostEqualÚassertAlmostEqualsÚfailIfAlmostEqualÚassertNotAlmostEqualsÚ
failUnlessÚassert_ÚfailUnlessRaisesr  ÚfailIfr¬   r’   ÚassertRaisesRegexpÚKeyErrorÚassertRegexpMatchesr  r«   )r   ÚoldÚmethrÆ   r   r   r   ÚtestDeprecatedMethodNames€  s$    z'Test_TestCase.testDeprecatedMethodNamesc          
   C   s\   t jdd… dk rdS dddddd	d
dg}x,|D ]$}|  t¡ t| |ƒ W dQ R X q0W dS )z9Test that the deprecated fail* methods get removed in 3.xNr)   )r(   r(   rm  ro  rq  rs  ru  rw  rx  r¬   )r
  Úversion_infor,   r.   rM  )r   Zdeprecated_namesZdeprecated_namer   r   r   Ú_testDeprecatedFailMethods›  s    
z(Test_TestCase._testDeprecatedFailMethodsc             C   s&   G dd„ dt jƒ}|dƒ}t|ƒ d S )Nc               @   s   e Zd Zdd„ ZdS )z0Test_TestCase.testDeepcopy.<locals>.TestableTestc             S   s   d S )Nr   )r   r   r   r   ÚtestNothing«  s    z<Test_TestCase.testDeepcopy.<locals>.TestableTest.testNothingN)r   r   r   r  r   r   r   r   ÚTestableTestª  s   r‚  r  )r$   r%   r   )r   r‚  r   r   r   r   ÚtestDeepcopy¨  s    zTest_TestCase.testDeepcopyc             C   sZ   t  d¡}xJttjd ƒD ]8}tj||d}t |¡}|  ||¡ | tƒ tƒ ¡ qW d S )Nr/   r6   )Úprotocol)	r$   r%   r®   ÚpickleÚHIGHEST_PROTOCOLÚdumpsÚloadsr*   r±   )r   r   r„  Zpickled_testZunpickled_testr   r   r   Ú
testPickle³  s    

zTest_TestCase.testPicklec          
      sª   ddd„‰ dd„ ‰G ‡ fdd„dt jƒ}G ‡ ‡fdd„dt jƒ}G ‡ ‡fd	d
„d
t jƒ}G ‡ fdd„dt jƒ}x6||||fD ]&}|  t¡ |dƒ ¡  W d Q R X q|W d S )Nc             S   s   t ‚d S )N)ÚKeyboardInterrupt)r   r   r   r   Ú_raiseÅ  s    z3Test_TestCase.testKeyboardInterrupt.<locals>._raisec             S   s   d S )Nr   )r   r   r   r   ÚnothingÇ  s    z4Test_TestCase.testKeyboardInterrupt.<locals>.nothingc                   s   e Zd Z” ZdS )z2Test_TestCase.testKeyboardInterrupt.<locals>.Test1N)r   r   r   Útest_somethingr   )r‹  r   r   ÚTest1Ê  s   rŽ  c                   s   e Zd Z” Z”ZdS )z2Test_TestCase.testKeyboardInterrupt.<locals>.Test2N)r   r   r   r   r  r   )r‹  rŒ  r   r   ÚTest2Í  s   r  c                   s   e Zd Z”Z” ZdS )z2Test_TestCase.testKeyboardInterrupt.<locals>.Test3N)r   r   r   r  r!   r   )r‹  rŒ  r   r   ÚTest3Ñ  s   r  c                   s   e Zd Z‡ fdd„ZdS )z2Test_TestCase.testKeyboardInterrupt.<locals>.Test4c                s   |   ˆ ¡ d S )N)rá   )r   )r‹  r   r   r  Ö  s    zATest_TestCase.testKeyboardInterrupt.<locals>.Test4.test_somethingN)r   r   r   r  r   )r‹  r   r   ÚTest4Õ  s   r‘  r  )N)r$   r%   r,   rŠ  r/   )r   rŽ  r  r  r‘  Úklassr   )r‹  rŒ  r   ÚtestKeyboardInterruptÄ  s    
z#Test_TestCase.testKeyboardInterruptc                s¾   ddd„‰ dd„ ‰G ‡ fdd„dt jƒ}G ‡ ‡fdd„dt jƒ}G ‡ ‡fd	d
„d
t jƒ}G ‡ fdd„dt jƒ}xJ||||fD ]:}t  ¡ }|dƒ |¡ |  t|jƒd¡ |  |jd¡ q|W d S )Nc             S   s   t  d¡‚d S )Nzsome reason)r$   ÚSkipTest)r   r   r   r   Ú_skipÞ  s    z3Test_TestCase.testSkippingEverywhere.<locals>._skipc             S   s   d S )Nr   )r   r   r   r   rŒ  à  s    z5Test_TestCase.testSkippingEverywhere.<locals>.nothingc                   s   e Zd Z” ZdS )z3Test_TestCase.testSkippingEverywhere.<locals>.Test1N)r   r   r   r  r   )r•  r   r   rŽ  ã  s   rŽ  c                   s   e Zd Z” Z”ZdS )z3Test_TestCase.testSkippingEverywhere.<locals>.Test2N)r   r   r   r   r  r   )r•  rŒ  r   r   r  æ  s   r  c                   s   e Zd Z”Z” ZdS )z3Test_TestCase.testSkippingEverywhere.<locals>.Test3N)r   r   r   r  r!   r   )r•  rŒ  r   r   r  ê  s   r  c                   s   e Zd Z‡ fdd„ZdS )z3Test_TestCase.testSkippingEverywhere.<locals>.Test4c                s   |   ˆ ¡ d S )N)rá   )r   )r•  r   r   r  ï  s    zBTest_TestCase.testSkippingEverywhere.<locals>.Test4.test_somethingN)r   r   r   r  r   )r•  r   r   r‘  î  s   r‘  r  r6   )N)r$   r%   r;   r/   r*   rÅ   ÚskippedÚtestsRun)r   rŽ  r  r  r‘  r’  r<   r   )r•  rŒ  r   ÚtestSkippingEverywhereÝ  s    
z$Test_TestCase.testSkippingEverywherec                s¾   ddd„‰ dd„ ‰G ‡ fdd„dt jƒ}G ‡ ‡fdd„dt jƒ}G ‡ ‡fd	d
„d
t jƒ}G ‡ fdd„dt jƒ}xJ||||fD ]:}t  ¡ }|dƒ |¡ |  t|jƒd¡ |  |jd¡ q|W d S )Nc             S   s   t ‚d S )N)Ú
SystemExit)r   r   r   r   r‹  ù  s    z,Test_TestCase.testSystemExit.<locals>._raisec             S   s   d S )Nr   )r   r   r   r   rŒ  û  s    z-Test_TestCase.testSystemExit.<locals>.nothingc                   s   e Zd Z” ZdS )z+Test_TestCase.testSystemExit.<locals>.Test1N)r   r   r   r  r   )r‹  r   r   rŽ  þ  s   rŽ  c                   s   e Zd Z” Z”ZdS )z+Test_TestCase.testSystemExit.<locals>.Test2N)r   r   r   r   r  r   )r‹  rŒ  r   r   r    s   r  c                   s   e Zd Z”Z” ZdS )z+Test_TestCase.testSystemExit.<locals>.Test3N)r   r   r   r  r!   r   )r‹  rŒ  r   r   r    s   r  c                   s   e Zd Z‡ fdd„ZdS )z+Test_TestCase.testSystemExit.<locals>.Test4c                s   |   ˆ ¡ d S )N)rá   )r   )r‹  r   r   r  
  s    z:Test_TestCase.testSystemExit.<locals>.Test4.test_somethingN)r   r   r   r  r   )r‹  r   r   r‘  	  s   r‘  r  r6   )N)r$   r%   r;   r/   r*   rÅ   Úerrorsr—  )r   rŽ  r  r  r‘  r’  r<   r   )r‹  rŒ  r   ÚtestSystemExitø  s    
zTest_TestCase.testSystemExitc          	   C   s8   t  ¡ }t |¡}t ¡  ~|  |ƒ ¡ W d Q R X d S )N)r$   r%   ÚweakrefÚrefr   Ú
disable_gcrˆ   )r   rÃ   Úwrr   r   r   ÚtestNoCycles  s
    

zTest_TestCase.testNoCyclesc                sZ   G ‡ fdd„dt ƒ‰ G ‡ fdd„dtjƒ}x*dD ]"}||ƒ}| ¡  |  ˆ jd¡ q0W d S )Nc                   s(   e Zd ZdZ‡ fdd„Z‡ fdd„ZdS )z9Test_TestCase.test_no_exception_leak.<locals>.MyExceptionr   c                s   ˆ  j d7  _ t | ¡ d S )Nr6   )Ú	ninstancer  r   )r   )r'   r   r   r   !  s    zBTest_TestCase.test_no_exception_leak.<locals>.MyException.__init__c                s   ˆ  j d8  _ d S )Nr6   )r¡  )r   )r'   r   r   Ú__del__%  s    zATest_TestCase.test_no_exception_leak.<locals>.MyException.__del__N)r   r   r   r¡  r   r¢  r   )r'   r   r   r'     s   r'   c                   s*   e Zd Z‡ fdd„Zej‡ fdd„ƒZdS )z6Test_TestCase.test_no_exception_leak.<locals>.TestCasec                s
   ˆ ƒ ‚d S )Nr   )r   )r'   r   r   r   )  s    z<Test_TestCase.test_no_exception_leak.<locals>.TestCase.test1c                s
   ˆ ƒ ‚d S )Nr   )r   )r'   r   r   r   ,  s    z<Test_TestCase.test_no_exception_leak.<locals>.TestCase.test2N)r   r   r   r   r$   ÚexpectedFailurer   r   )r'   r   r   r%   (  s   r%   )r   r   r   )r  r$   r%   r/   r*   r¡  )r   r%   Úmethod_nameÚtestcaser   )r'   r   Útest_no_exception_leak  s    

z$Test_TestCase.test_no_exception_leakN)pr   r   r   r   r   Úeq_pairsr   Úne_pairsr0   r1   r5   r8   r=   rC   rF   rG   rH   rJ   rK   rL   rM   rN   rU   rX   rY   rZ   r\   r]   r_   ri   rk   rn   ro   rp   rq   rr   ru   rw   ry   r|   r   r$   ÚskipIfr
  r  Úoptimizer€   r   rŒ   rŽ   r   r“   r•   r    r¯   r³   r»   rÎ   rÓ   rÕ   r×   rå   rç   rõ   rù   rü   r  r  r  r  r  r  r  r  r"  r%  r'  r)  r,  r-  r0  r1  r7  r>  r@  rC  rD  rE  r  ÚcontextmanagerrH  rR  rZ  r]  r`  rb  re  rg  rh  rj  rk  r~  r€  rƒ  r‰  r“  r˜  r›  r   Úcpython_onlyr   r¦  r   r   r   r   r&   8   sÊ   

		
	%4($>(:L!1!-	r&   Ú__main__)!r  r¾   rÀ   r…  r#  r
  rJ  r¨   rœ  r8  Úcopyr   r   r   r$   Úunittest.test.supportr   r   r   r   r   Ztest.supportr	   rf  rV  rX  r\  r‡   r   r%   r&   r   Úmainr   r   r   r   Ú<module>   sF   


              