Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/unittest/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/unittest/test/__pycache__/test_case.cpython-35.opt-2.pyc



���]��@sXddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlZddlmZmZmZmZmZddlmZejd�Zejd�Zejd�ZGd	d
�d
e�ZGdd�dejee�Zed
krTej �dS)�N)�deepcopy)�support)�TestEquality�TestHashing�
LoggingResult�LegacyLoggingResult�#ResultWithNoStartTestRunStopTestRun)�captured_stderr�foozfoo.bar�quuxc@sXeZdZGdd�dej�ZGdd�de�ZGdd�dej�ZdS)�Testc@s(eZdZdd�Zdd�ZdS)zTest.FoocCsdS)N�)�selfr
r
�./opt/alt/python35/lib64/python3.5/test_case.py�runTest!szTest.Foo.runTestcCsdS)Nr
)rr
r
r�test1"szTest.Foo.test1N)�__name__�
__module__�__qualname__rrr
r
r
r�Foo src@seZdZdd�ZdS)zTest.BarcCsdS)Nr
)rr
r
r�test2%szTest.Bar.test2N)rrrrr
r
r
r�Bar$srcsFeZdZ�fdd�Zdd�Zdd�Zdd�Z�S)	zTest.LoggingTestCasecs&ttj|�jd�||_dS)N�test)�superr�LoggingTestCase�__init__�events)rr)�	__class__r
rr*szTest.LoggingTestCase.__init__cCs|jjd�dS)N�setUp)r�append)rr
r
rr.szTest.LoggingTestCase.setUpcCs|jjd�dS)Nr)rr)rr
r
rr1szTest.LoggingTestCase.testcCs|jjd�dS)N�tearDown)rr)rr
r
rr 4szTest.LoggingTestCase.tearDown)rrrrrrr r
r
)rrr'srN)rrr�unittest�TestCaserrrr
r
r
rrsrc@s>eZdZejd�ejd�fgZejd�ejd�fejd�ejd�fejd�ejd�fgZdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#d<d=�Z$d>d?�Z%d@dA�Z&dBdC�Z'e(j)e*j+j,dDkdE�dFdG��Z-e(j)e*j+j,dDkdE�dHdI��Z.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��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVeWjXd�d���ZYd�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��Zjekjld�d���Zmd�d��Znd�S)��
Test_TestCaserrrcCs�Gdd�dtj�}|j|�j�dd�d�tj�}|jdd�|j|j��|jdd�WdQRX|jt��|j�WdQRXdS)Nc@s(eZdZdd�Zdd�ZdS)z3Test_TestCase.test_init__no_test_name.<locals>.TestcSs
t��dS)N)�MyException)rr
r
rrTsz;Test_TestCase.test_init__no_test_name.<locals>.Test.runTestcSsdS)Nr
)rr
r
rrUsz8Test_TestCase.test_init__no_test_name.<locals>.Test.testN)rrrrrr
r
r
rrSsr�
z
.Test.runTest��i�)r!r"�assertEqual�id�assertRaises�failureException�AttributeError�run)rrrr
r
r�test_init__no_test_nameRs#z%Test_TestCase.test_init__no_test_namecCsCGdd�dtj�}|j|d�j�dd�d�dS)Nc@s(eZdZdd�Zdd�ZdS)z7Test_TestCase.test_init__test_name__valid.<locals>.TestcSs
t��dS)N)r$)rr
r
rrisz?Test_TestCase.test_init__test_name__valid.<locals>.Test.runTestcSsdS)Nr
)rr
r
rrjsz<Test_TestCase.test_init__test_name__valid.<locals>.Test.testN)rrrrrr
r
r
rrhsrr�
z
.Test.testi����)r!r"r(r))rrr
r
r�test_init__test_name__validgsz)Test_TestCase.test_init__test_name__validcCsMGdd�dtj�}y|d�Wntk
r;YnX|jd�dS)Nc@s(eZdZdd�Zdd�ZdS)z9Test_TestCase.test_init__test_name__invalid.<locals>.TestcSs
t��dS)N)r$)rr
r
rrtszATest_TestCase.test_init__test_name__invalid.<locals>.Test.runTestcSsdS)Nr
)rr
r
rrusz>Test_TestCase.test_init__test_name__invalid.<locals>.Test.testN)rrrrrr
r
r
rrssrZtestfoozFailed to raise ValueError)r!r"�
ValueError�fail)rrr
r
r�test_init__test_name__invalidrs
z+Test_TestCase.test_init__test_name__invalidcCs9Gdd�dtj�}|j|d�j�d�dS)Nc@seZdZdd�ZdS)z.Test_TestCase.test_countTestCases.<locals>.FoocSsdS)Nr
)rr
r
rr�sz3Test_TestCase.test_countTestCases.<locals>.Foo.testN)rrrrr
r
r
rr�srr�)r!r"r(ZcountTestCases)rrr
r
r�test_countTestCases�sz!Test_TestCase.test_countTestCasescCsEGdd�dtj�}|�j�}|jt|�tj�dS)Nc@seZdZdd�ZdS)z1Test_TestCase.test_defaultTestResult.<locals>.FoocSsdS)Nr
)rr
r
rr�sz9Test_TestCase.test_defaultTestResult.<locals>.Foo.runTestN)rrrrr
r
r
rr�sr)r!r"�defaultTestResultr(�type�
TestResult)rr�resultr
r
r�test_defaultTestResult�sz$Test_TestCase.test_defaultTestResultcsjg}t|�}G�fdd�dtj���|�j|�ddddg}|j||�dS)Ncs%eZdZ��fdd�Z�S)z>Test_TestCase.test_run_call_order__error_in_setUp.<locals>.Foocs#t�|�j�td��dS)Nzraised by Foo.setUp)rr�RuntimeError)r)rrr
rr�szDTest_TestCase.test_run_call_order__error_in_setUp.<locals>.Foo.setUp)rrrrr
)r)rrr�sr�	startTestr�addError�stopTest)rrrr-r()rrr9�expectedr
)rr�#test_run_call_order__error_in_setUp�sz1Test_TestCase.test_run_call_order__error_in_setUpcsag}G�fdd�dtj���|�j�ddddddg}|j||�dS)	Ncs1eZdZdd�Z��fdd�Z�S)zMTest_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr6�sz_Test_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.Foo.defaultTestResultcs#t�|�j�td��dS)Nzraised by Foo.setUp)rrr;)r)rrr
rr�szSTest_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.Foo.setUp)rrrr6rr
)r)rrr�sr�startTestRunr<rr=r>�stopTestRun)rrr-r()rrr?r
)rr�2test_run_call_order__error_in_setUp_default_result�sz@Test_TestCase.test_run_call_order__error_in_setUp_default_resultcspg}t|�}G�fdd�dtj��ddddddg}�|�j|�|j||�dS)	Ncs%eZdZ��fdd�Z�S)z=Test_TestCase.test_run_call_order__error_in_test.<locals>.Foocs#t�|�j�td��dS)Nzraised by Foo.test)rrr;)r)rrr
rr�szBTest_TestCase.test_run_call_order__error_in_test.<locals>.Foo.test)rrrrr
)r)rrr�srr<rrr r=r>)rrrr-r()rrr9r?r
)rr�"test_run_call_order__error_in_test�sz0Test_TestCase.test_run_call_order__error_in_testcsgg}G�fdd�dtj��ddddddd	d
g}�|�j�|j||�dS)Ncs1eZdZdd�Z��fdd�Z�S)zLTest_TestCase.test_run_call_order__error_in_test_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr6�sz^Test_TestCase.test_run_call_order__error_in_test_default_result.<locals>.Foo.defaultTestResultcs#t�|�j�td��dS)Nzraised by Foo.test)rrr;)r)rrr
rr�szQTest_TestCase.test_run_call_order__error_in_test_default_result.<locals>.Foo.test)rrrr6rr
)r)rrr�srrAr<rrr r=r>rB)rrr-r()rrr?r
)rr�1test_run_call_order__error_in_test_default_result�sz?Test_TestCase.test_run_call_order__error_in_test_default_resultcspg}t|�}G�fdd�dtj��ddddddg}�|�j|�|j||�dS)	Ncs%eZdZ��fdd�Z�S)z?Test_TestCase.test_run_call_order__failure_in_test.<locals>.Foocs$t�|�j�|jd�dS)Nzraised by Foo.test)rrr2)r)rrr
rr�szDTest_TestCase.test_run_call_order__failure_in_test.<locals>.Foo.test)rrrrr
)r)rrr�srr<rrr �
addFailurer>)rrrr-r()rrr9r?r
)rr�$test_run_call_order__failure_in_test�sz2Test_TestCase.test_run_call_order__failure_in_testcsgG�fdd�dtj��ddddddd	d
g}g}�|�j�|j||�dS)Ncs1eZdZdd�Z��fdd�Z�S)zNTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr6�sz`Test_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.defaultTestResultcs$t�|�j�|jd�dS)Nzraised by Foo.test)rrr2)r)rrr
rr�szSTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.test)rrrr6rr
)r)rrr�srrAr<rrr rFr>rB)rrr-r()rr?rr
)rr�3test_run_call_order__failure_in_test_default_result�szATest_TestCase.test_run_call_order__failure_in_test_default_resultcspg}t|�}G�fdd�dtj���|�j|�ddddddg}|j||�dS)	Ncs%eZdZ��fdd�Z�S)zATest_TestCase.test_run_call_order__error_in_tearDown.<locals>.Foocs#t�|�j�td��dS)Nzraised by Foo.tearDown)rr r;)r)rrr
rr szJTest_TestCase.test_run_call_order__error_in_tearDown.<locals>.Foo.tearDown)rrrr r
)r)rrrsrr<rrr r=r>)rrrr-r()rrr9r?r
)rr�&test_run_call_order__error_in_tearDown
s	z4Test_TestCase.test_run_call_order__error_in_tearDowncsgG�fdd�dtj��g}�|�j�ddddddd	d
g}|j||�dS)Ncs1eZdZdd�Z��fdd�Z�S)zPTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr6szbTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.Foo.defaultTestResultcs#t�|�j�td��dS)Nzraised by Foo.tearDown)rr r;)r)rrr
rr szYTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.Foo.tearDown)rrrr6r r
)r)rrrsrrAr<rrr r=r>rB)rrr-r()rrr?r
)rr�5test_run_call_order__error_in_tearDown_default_resultszCTest_TestCase.test_run_call_order__error_in_tearDown_default_resultcCs-Gdd�dtj�}|d�j�dS)Nc@s(eZdZdd�Zdd�ZdS)z=Test_TestCase.test_run_call_order_default_result.<locals>.FoocSst�S)N)r)rr
r
rr6-szOTest_TestCase.test_run_call_order_default_result.<locals>.Foo.defaultTestResultcSsdS)Nr
)rr
r
rr/szBTest_TestCase.test_run_call_order_default_result.<locals>.Foo.testN)rrrr6rr
r
r
rr,srr)r!r"r-)rrr
r
r�"test_run_call_order_default_result*sz0Test_TestCase.test_run_call_order_default_resultcsFG�fdd�dtj���|�j|�|j||�dS)Ncs%eZdZ��fdd�Z�S)z6Test_TestCase._check_call_order__subtests.<locals>.Foocs�t�|�j�x�dddgD]�}|jd|��k|dkrU|jd�xJddgD]<}|jd|��!||dkr�td��WdQRXqbWWdQRXq#Wdd	dS)
Nr4r'r&�i�failure�j�zraised by Foo.testr)rr�subTestr2r;)rrLrN)rrr
rr6s
"z;Test_TestCase._check_call_order__subtests.<locals>.Foo.test)rrrrr
)r)rrr5sr)rrr-r()rr9r�expected_eventsr
)rr�_check_call_order__subtests4sz)Test_TestCase._check_call_order__subtestscCsPg}t|�}dddddddddddg}|j|||�dS)	Nr<rrr �addSubTestFailure�addSubTestSuccessr=r>)rrR)rrr9r?r
r
r�test_run_call_order__subtestsLsz+Test_TestCase.test_run_call_order__subtestscCsAg}t|�}ddddddg}|j|||�dS)Nr<rrr rFr>)rrR)rrr9r?r
r
r�$test_run_call_order__subtests_legacyUs
z2Test_TestCase.test_run_call_order__subtests_legacycsFG�fdd�dtj���|�j|�|j||�dS)Ncs%eZdZ��fdd�Z�S)z>Test_TestCase._check_call_order__subtests_success.<locals>.Foocsyt�|�j�x_ddgD]Q}|jd|��6x.ddgD] }|jd|��WdQRXqFWWdQRXq WdS)Nr4r'rLr&rN)rrrP)rrLrN)rrr
rr`szCTest_TestCase._check_call_order__subtests_success.<locals>.Foo.test)rrrrr
)r)rrr_sr)rrr-r()rr9rrQr
)rr�#_check_call_order__subtests_success^s	z1Test_TestCase._check_call_order__subtests_successcCsPg}t|�}ddddgddgddg}|j|||�dS)	Nr<rrr rOrT�
addSuccessr>)rrW)rrr9r?r
r
r�%test_run_call_order__subtests_successks'z3Test_TestCase.test_run_call_order__subtests_successcCsAg}t|�}ddddddg}|j|||�dS)Nr<rrr rXr>)rrW)rrr9r?r
r
r�,test_run_call_order__subtests_success_legacyus
z:Test_TestCase.test_run_call_order__subtests_success_legacycsyg}t|�}d|_G�fdd�dtj��dddddd	g}�|�j|�|j||�dS)
NTcs%eZdZ��fdd�Z�S)zATest_TestCase.test_run_call_order__subtests_failfast.<locals>.Foocsrt�|�j�|jdd��|jd�WdQRX|jdd��|jd�WdQRX|jd�dS)NrLr4rMr')rrrPr2)r)rrr
rr�szFTest_TestCase.test_run_call_order__subtests_failfast.<locals>.Foo.test)rrrrr
)r)rrr�srr<rrr rSr>)r�failfastrrr-r()rrr9r?r
)rr�&test_run_call_order__subtests_failfast}s		z4Test_TestCase.test_run_call_order__subtests_failfastcsyg�G�fdd�dtj�}tj�}d|_tj|�}|j|�dddg}|j�|�dS)NcsFeZdZ�fdd�Z�fdd�Z�fdd�ZdS)z1Test_TestCase.test_subtests_failfast.<locals>.Fooc	s2|j���jd�WdQRX�jd�dS)N�a1�a2)rPr)r)rr
r�test_a�s
z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_acsS|j���jd�WdQRX|j��|jd�WdQRX�jd�dS)N�b1rMZb2)rPrr2)r)rr
r�test_b�s


z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_bcs�jd�dS)N�c)r)r)rr
r�test_c�sz8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_cN)rrrr_rarcr
)rr
rr�srTr]r^r`)r!r"r8r[Z	makeSuiter-r()rrr9Zsuiter?r
)rr�test_subtests_failfast�s	
z$Test_TestCase.test_subtests_failfastcCs6Gdd�dtj�}|j|d�jt�dS)Nc@seZdZdd�ZdS)z9Test_TestCase.test_failureException__default.<locals>.FoocSsdS)Nr
)rr
r
rr�sz>Test_TestCase.test_failureException__default.<locals>.Foo.testN)rrrrr
r
r
rr�srr)r!r"�assertIsr+�AssertionError)rrr
r
r�test_failureException__default�sz,Test_TestCase.test_failureException__defaultcCszg}t|�}Gdd�dtj�}|j|d�jt�|d�j|�dddg}|j||�dS)Nc@s"eZdZdd�ZeZdS)zMTest_TestCase.test_failureException__subclassing__explicit_raise.<locals>.FoocSs
t��dS)N)r;)rr
r
rr�szRTest_TestCase.test_failureException__subclassing__explicit_raise.<locals>.Foo.testN)rrrrr;r+r
r
r
rr�srrr<rFr>)rr!r"rer+r;r-r()rrr9rr?r
r
r�2test_failureException__subclassing__explicit_raise�sz@Test_TestCase.test_failureException__subclassing__explicit_raisecCszg}t|�}Gdd�dtj�}|j|d�jt�|d�j|�dddg}|j||�dS)Nc@s"eZdZdd�ZeZdS)zMTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.FoocSs|jd�dS)Nr
)r2)rr
r
rr�szRTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.Foo.testN)rrrrr;r+r
r
r
rr�srrr<rFr>)rr!r"rer+r;r-r()rrr9rr?r
r
r�2test_failureException__subclassing__implicit_raise�sz@Test_TestCase.test_failureException__subclassing__implicit_raisecCs*Gdd�dtj�}|�j�dS)Nc@seZdZdd�ZdS)z%Test_TestCase.test_setUp.<locals>.FoocSsdS)Nr
)rr
r
rr�sz-Test_TestCase.test_setUp.<locals>.Foo.runTestN)rrrrr
r
r
rr�sr)r!r"r)rrr
r
r�
test_setUp�szTest_TestCase.test_setUpcCs*Gdd�dtj�}|�j�dS)Nc@seZdZdd�ZdS)z(Test_TestCase.test_tearDown.<locals>.FoocSsdS)Nr
)rr
r
rr�sz0Test_TestCase.test_tearDown.<locals>.Foo.runTestN)rrrrr
r
r
rr�sr)r!r"r )rrr
r
r�
test_tearDown�szTest_TestCase.test_tearDowncCs6Gdd�dtj�}|j|�j�t�dS)Nc@seZdZdd�ZdS)z"Test_TestCase.test_id.<locals>.FoocSsdS)Nr
)rr
r
rrsz*Test_TestCase.test_id.<locals>.Foo.runTestN)rrrrr
r
r
rr�sr)r!r"�assertIsInstancer)�str)rrr
r
r�test_id�szTest_TestCase.test_idcs�g�t���G��fdd�dtj�}|d�j�}|j|��ddddddg}|j�|�dS)	Ncs4eZdZ�fdd�Z�fdd�ZdS)z;Test_TestCase.test_run__uses_defaultTestResult.<locals>.Foocs�jd�dS)Nr)r)r)rr
rrsz@Test_TestCase.test_run__uses_defaultTestResult.<locals>.Foo.testcs�S)Nr
)r)�
defaultResultr
rr6szMTest_TestCase.test_run__uses_defaultTestResult.<locals>.Foo.defaultTestResultN)rrrrr6r
)rorr
rrsrrrAr<rXr>rB)rr!r"r-rer()rrr9r?r
)rorr� test_run__uses_defaultTestResult
s"z.Test_TestCase.test_run__uses_defaultTestResultcCsNGdd�dtj�}tj�}|d�j|�}|j||�dS)Nc@seZdZdd�ZdS)z9Test_TestCase.test_run__returns_given_result.<locals>.FoocSsdS)Nr
)rr
r
rr"sz>Test_TestCase.test_run__returns_given_result.<locals>.Foo.testN)rrrrr
r
r
rr!srr)r!r"r8r-re)rrr9�retvalr
r
r�test_run__returns_given_resultsz,Test_TestCase.test_run__returns_given_resultcs`tj��tj��G��fdd�dtj�}|d���}|j|��dS)Ncs1eZdZdd�Z��fdd�ZdS)zKTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.FoocSsdS)Nr
)rr
r
rr2szPTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.testcs|j|���S)N)re)rr9)�resultIn�	resultOutr
rr-5szOTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.runN)rrrrr-r
)rsrtr
rr1srr)r!r8r"re)rrrqr
)rsrtr�0test_call__invoking_an_instance_delegates_to_run-s
"z>Test_TestCase.test_call__invoking_an_instance_delegates_to_runcCs|j|j��dS)N)�assertIsNone�shortDescription)rr
r
r�$testShortDescriptionWithoutDocstring>sz2Test_TestCase.testShortDescriptionWithoutDocstringr'z)Docstrings are omitted with -O2 and abovecCs|j|j�d�dS)Nz7Tests shortDescription() for a method with a docstring.)r(rw)rr
r
r�(testShortDescriptionWithOneLineDocstringAs	z6Test_TestCase.testShortDescriptionWithOneLineDocstringcCs|j|j�d�dS)Nz>Tests shortDescription() for a method with a longer docstring.)r(rw)rr
r
r�*testShortDescriptionWithMultiLineDocstringIs		z8Test_TestCase.testShortDescriptionWithMultiLineDocstringcsuGdd�dt������}}|j||k�d�fdd�}|j�|�|j||�dS)Nc@seZdZdS)z7Test_TestCase.testAddTypeEqualityFunc.<locals>.SadSnakeN)rrrr
r
r
r�SadSnakeXsr{cs$t|�t|�ko!�kSS)N)r7)�a�b�msg)r{r
r�AllSnakesCreatedEqual\szDTest_TestCase.testAddTypeEqualityFunc.<locals>.AllSnakesCreatedEqual)�object�assertFalseZaddTypeEqualityFuncr()r�s1�s2rr
)r{r�testAddTypeEqualityFuncWsz%Test_TestCase.testAddTypeEqualityFunccCs<t�}|j||�|j|j|j|t��dS)N)r�rer*r+)r�thingr
r
r�testAssertIsds	zTest_TestCase.testAssertIscCs<t�}|j|t��|j|j|j||�dS)N)r�ZassertIsNotr*r+)rr�r
r
r�testAssertIsNotis	zTest_TestCase.testAssertIsNotcCs6g}|j|t�|j|j|j|t�dS)N)rl�listr*r+�dict)rr�r
r
r�testAssertIsInstancensz"Test_TestCase.testAssertIsInstancecCs6g}|j|t�|j|j|j|t�dS)N)ZassertNotIsInstancer�r*r+r�)rr�r
r
r�testAssertNotIsInstancetsz%Test_TestCase.testAssertNotIsInstancecCsHddddddi}|jdd�|jd	d
d	dg�|jd|�|jdd�|jd
d
d	dg�|jd|�|j|j|jdd�|j|j|jdd
d	dg�|j|j|jd|�|j|j|jdd�|j|j|jd
d
d	dg�|j|j|jd|�dS)NZmonkeyZbananaZcowZgrassZsealZfishr|�abcr'r4r&�drZotter�x�Zelephantrb)�assertIn�assertNotInr*r+)rZanimalsr
r
r�testAssertInzs%%zTest_TestCase.testAssertInc5Cs tj��
tjdt�|jii�|jiddi�|jddiddi�|jddiddddi�|jddddiddddi�|j|j��|jddii�WdQRX|j|j��!|jddiddi�WdQRX|j|j��!|jddiddi�WdQRX|j|j��'|jddddiddi�WdQRX|j|j��'|jddddiddi�WdQRXdjd	d
�td�D��}|j|j��!|jd|idd
i�WdQRXWdQRXdS)N�ignorer|r4r}r'�onerb�css|]}t|�VqdS)N)�chr)�.0rLr
r
r�	<genexpr>�sz=Test_TestCase.testAssertDictContainsSubset.<locals>.<genexpr>�r
u�)	�warnings�catch_warnings�simplefilter�DeprecationWarning�assertDictContainsSubsetr*r+�join�range)rr�r
r
r�testAssertDictContainsSubset�s(
"(##))"z*Test_TestCase.testAssertDictContainsSubsetcCsfffiifggft�t�ft�t�fg}x�|D]�\}}y|j||�Wn,|jk
r�|jd||f�YnXy|j||dd�Wn,|jk
r�|jd||f�YnXy|j||d�WqF|jk
r#|jd||f�YqFXqFWfgfit�ftddg�tddg�ftdd	g�tdd
g�ftd
dg�td	dg�fg}xq|D]i\}}|j|j|j||�|j|j|j||d�|j|j|j||dd�q�WdS)NzassertEqual(%r, %r) failedr~r
z$assertEqual(%r, %r) with msg= failedz/assertEqual(%r, %r) with third parameter failedr�r4r'�r&)�set�	frozensetr(r+r2r*)rZequal_pairsr|r}Z
unequal_pairsr
r
r�testAssertEqual�s<					!!'zTest_TestCase.testAssertEqualcCs�|jgg�|jff�|jgf�ddgg}g}|jtjj|j||�|jtjj|jt|�t|��|jtjj|j|t|��|j|�|j||�|jt|�t|��|j|t|��|jt|�|�|j|j|j|t|��|j|j|jt|�|�|j|j|jd|�|j|j|jdt|��|j|j|jdt|��|j|j|jdd�|j|j|jdd�|j|j|jdd�|j	ii�ddi}i}|jtjj|j	||�|j
|�|j	||�d|d<|jtjj|j	||d�|j|j|j	d|�|j|j|j	g|�|j|j|j	dd�dS)Nrr|r4r�zThese are unequal)�assertListEqual�assertTupleEqual�assertSequenceEqualr*r!r"r+�tuple�extend�assertDictEqual�update)rr|r}rbr�r
r
r�testEquality�sT




zTest_TestCase.testEqualityc.CsG|j|jd�ddd}ddd
}djtjtj|�j�tj|�j���}tj	j
t|�df}t|�d|_y|j||�Wn5|j
k
r�}z|jd	}WYdd}~XnX|jd
�|jt|�t|��|j||�t|�d|_y|j||�Wn5|j
k
r{}z|jd	}WYdd}~XnX|jd
�|jt|�t|��|j||�d|_y|j||�Wn5|j
k
r	}z|jd	}WYdd}~XnX|jd
�|jt|�t|��|j||�dS)N�P�r|r�r'r}�
r4rz!assertSequenceEqual did not fail.i�ii)r(�maxDiffr��difflibZndiff�pprintZpformat�
splitlinesr!�case�DIFF_OMITTED�lenr�r+�argsr2�
assertLessr��
assertGreaterr�)rZseq1Zseq2�diff�omitted�er~r
r
r�testAssertSequenceEqualMaxDiffs< 
 
	 
z,Test_TestCase.testAssertSequenceEqualMaxDiffcCs�d|_|jdd�}tjjtd�}|j|d|�d|_|jdd�}|j|d�d|_|jdd�}|j|d�dS)Nr4r
�bar�foobarr�)r��_truncateMessager!r�r�r�r()r�messager�r
r
r�testTruncateMessage.s			z!Test_TestCase.testTruncateMessagecCs�tjd�}dd�}||_y|jiddi�Wn>|jk
r~}z|jt|�d�WYdd}~XnX|jd�dS)Nr(cSsdS)Nr
r
)r~r�r
r
r�truncate>sz<Test_TestCase.testAssertDictEqualTruncates.<locals>.truncater4rr
zassertDictEqual did not fail)r!r"r�r�r+r(rmr2)rrr�r�r
r
r�testAssertDictEqualTruncates<s	)z*Test_TestCase.testAssertDictEqualTruncatescCs�tjd�}dd�}||_y|jdd�Wn>|jk
rx}z|jt|�d�WYdd}~XnX|jd�dS)Nr(cSsdS)Nr
r
)r~r�r
r
rr�JszATest_TestCase.testAssertMultiLineEqualTruncates.<locals>.truncater
r�z!assertMultiLineEqual did not fail)r!r"r��assertMultiLineEqualr+r(rmr2)rrr�r�r
r
r�!testAssertMultiLineEqualTruncatesHs	)z/Test_TestCase.testAssertMultiLineEqualTruncatescs��j�jd�d�_�j�d�_�j��fdd��d}�j�j��}�j|d|d	�WdQRX�jd
t|j���j|d|d�dd}dd
�}�j	�|�_	�j��fdd��|d|d	}}�j�j��}�j||�WdQRX�j
d
t|j���jt|j�d||f��j|d|d�dS)Nr'�r�cst�d��S)N�_diffThreshold)�setattrr
)�
old_thresholdrr
r�<lambda>]sz=Test_TestCase.testAssertEqual_diffThreshold.<locals>.<lambda>r�r�r|r}�^rOcSstd��dS)Nzthis should not be raised)�SystemError)r�r�r
r
r�explodingTruncationkszHTest_TestCase.testAssertEqual_diffThreshold.<locals>.explodingTruncationcst�d��S)Nr�)r�r
)�old_truncaterr
rr�osz%r != %ri� r�Zxxxxxxxxxxxxxxxx�@)r(r�r��
addCleanupr*r+r�rm�	exceptionr�r�)r�s�cmr�r�r�r
)r�r�rr�testAssertEqual_diffThresholdTs*			
		#z+Test_TestCase.testAssertEqual_diffThresholdcs��j�d�_�j��fdd��dd}|d|d}}�j�j��}�j||�WdQRXddd	}�jt|j�d
||f��j|d|d�dd}|d||d|}}�j�j��}�j||�WdQRXd
}�jt|j�d||||f�dd}|d||d|}}�j�j��}�j||�WdQRXd}ddd}�jt|j�d||||f�dS)Nrcst�d��S)Nr�)r�r
)r�rr
rr�|sz7Test_TestCase.testAssertEqual_shorten.<locals>.<lambda>r��dr|r}zxxxx[35 chars]�=z'%sa' != '%sb'�y�2zxxxx[85 chars]xxxxxxxxxxxz'%sa%s' != '%sb%s'zxxxx[91 chars]xxxxx�(z[56 chars]yyyy)r�r�r*r+r(rmr�)rr�r�r�r�rb�pr�r
)r�rr�testAssertEqual_shortenxs.		
#
)
z%Test_TestCase.testAssertEqual_shortencCsst�}|jdddgdddg�|jdddgdddg�|j||dddg|dd|df�|jddddgddd	dg�|j|j|jddgdgd
dgd
ddg�|j|j|jddddgddd	dg�|j|j|jdgddg�|j|j|jddgdg�|j|j|jdddgddg�|jddgdd
gdgddd
gddgg�|jtddgdd
g�tddgdd
g��|j|j|jgtddddt�g�|jddiddigddiddig�|jddtggtgddg�|j|j|jgtgddddt�g�|j|j|jdggdgg�|j|j|jdddgddg�|j|j|jdddddgddd	dg�|j|j|jdddidd	gddid	dg�dd
hddhg}|ddd�}|j||�ttj	j
dd��}ddddh}|j||�tj	j
ggg�}|j|ddgfg�ttj	jdd��}dddd h}|j||�dS)!Nr4r'r&r
r�Zbaz�2r|Tr�r/�r�rFr�y@y@r}ZaaabccdZabbbccer�r����)r&r4r|)r4r&r})r4rr�)rr4r�)r&r4r|)r4r&r})r4rr�)rr4r�)
r��assertCountEqualr*r+�iter�divmodr�r�r!�utilZ_count_diff_all_purposer(Z_count_diff_hashable)rr|r}Zdiffsr?r
r
r�testAssertCountEqual�sV	"".(,":4("%+z"Test_TestCase.testAssertCountEqualcCs*t�}t�}|j||�|j|j|jd|�|j|j|jg|�|j|j|j|d�|j|j|j|g�tdg�}t�}|j|j|j||�tdg�}tdg�}|j||�tdg�}tddg�}|j|j|j||�tdg�}tddg�}|j|j|j||�tddg�}tddg�}|j||�t�}d}|j|j|j||�|j|j|j||�td
dg�}tdg�}|j|j|j||�dS)
Nr|r}r
rr4r'r&r�r�)rr4)r'r&)r�r�)r��assertSetEqualr*r+r�)rZset1Zset2r
r
r�testAssertSetEqual�s:				z Test_TestCase.testAssertSetEqualcCs$|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�|j|j|jdd�dS)	Nr'r4g�������?g�?ZbugZantsbugsant)r�ZassertGreaterEqualr�ZassertLessEqualr*r+)rr
r
r�testInequality�sbzTest_TestCase.testInequalitycCs�d}d}d}d|_y|j||�WnT|jk
r�}z1t|�jdd�d}|j||�WYdd}~XnXdS)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�r4)r�r�r+rm�splitr()r�sample_text�revised_sample_text�sample_text_errorr��errorr
r
r�testAssertMultiLineEqual5s	z&Test_TestCase.testAssertMultiLineEqualcCs�d}d}d}y|j||�WnT|jk
r|}z1t|�jdd�d}|j||�WYdd}~XnXdS)Nzladen swallows fly slowlyzunladen swallows fly quicklyzr- laden swallows fly slowly
?                    ^^^^
+ unladen swallows fly quickly
? ++                   ^^^^^
r�r4)r(r+rmr�)rr�r�r�r�r�r
r
r�testAssertEqualSingleLineTsz'Test_TestCase.testAssertEqualSingleLinecsBtjjr!�fdd�}ndd�}|��/�j�j���jdd�WdQRXWdQRX|���jdd�WdQRXddg}ddg}|��/�j�j���j||�WdQRXWdQRX|��;�j�j��!�jt	|�t	|��WdQRXWdQRX|��5�j�j���j
|t	|��WdQRXWdQRX|��5�j�j���j
t	|�|�WdQRXWdQRX|��/�j�j���j
dd�WdQRXWdQRX|��;�j�j��!�jt|�t|��WdQRXWdQRX�j�j���j|t	|��WdQRX�j�j���jt	|�|�WdQRXddg}dg}�j�j���j||�WdQRX�j�j��!�jt	|�t	|��WdQRX�j�j���j
|t	|��WdQRX�j�j���j
t	|�|�WdQRX�j�j��!�jt|�t|��WdQRXdg}ddg}�j�j���j||�WdQRX�j�j��!�jt	|�t	|��WdQRX�j�j���j
|t	|��WdQRX�j�j���j
t	|�|�WdQRX�j�j��!�jt|�t|��WdQRX|��;�j�j��!�j
ddiddi�WdQRXWdQRX�j�j���j
iddi�WdQRX�j�j���j
ddii�WdQRX�j�j��$�jddgdddg�WdQRX|��!�jddgddg�WdQRX|��;�j�j��!�jddgddg�WdQRXWdQRX|��A�j�j��'�jddggddgg�WdQRXWdQRXdS)Ncs�jtd�S)Nz#Comparison between bytes and string)�assertWarnsRegex�BytesWarningr
)rr
r�
bytes_warningfs	z=Test_TestCase.testEqualityBytesWarning.<locals>.bytes_warningcSs
tj�S)N)�
contextlib�	ExitStackr
r
r
rr�jsr|�ar)�sys�flagsr�r*r+r(ZassertNotEqualr�r�r�r�r�r�r�r�)rr�r|r}r
)rr�testEqualityBytesWarningds~
*$$*	##	##*&
#*z&Test_TestCase.testEqualityBytesWarningcCsP|jd�|j|j|jd�|jd�|j|j|jd�dS)NFzDjZoPloGears on Rails)rvr*r+ZassertIsNotNone)rr
r
r�testAssertIsNone�s

zTest_TestCase.testAssertIsNonecCs0|jdd�|j|j|jdd�dS)NZ
asdfabasdfzab+ZsaaasZaaaa)ZassertRegexr*r+)rr
r
r�testAssertRegex�szTest_TestCase.testAssertRegexcs�Gdd�dt���fdd�}|j�|�|jt�f|�|jttddd�|j|j��|j�dd	��WdQRX|jt��|j�d�WdQRX|j���|jt|�WdQRXdS)
Nc@seZdZdS)z=Test_TestCase.testAssertRaisesCallable.<locals>.ExceptionMockN)rrrr
r
r
r�
ExceptionMock�sr�cs�d��dS)Nz	We expectr
r
)r�r
r�Stub�sz4Test_TestCase.testAssertRaisesCallable.<locals>.Stub�19�baser�cSsdS)Nrr
r
r
r
rr��sz8Test_TestCase.testAssertRaisesCallable.<locals>.<lambda>)�	Exceptionr*r1�intr+�assertWarnsr�)rr�r
)r�r�testAssertRaisesCallable�sz&Test_TestCase.testAssertRaisesCallablecPs�Gdd�dt���fdd�}|j���|�WdQRX|jt�f��}|�WdQRX|j|j��|j|jjdd�|jt��tddd	�WdQRX|j|j��|j���WdQRXWdQRX|j	|jd
��"|j�dd
��WdQRXWdQRX|j
td
��9|jt��"|j�d
d��WdQRXWdQRXWdQRX|j���|jt|�WdQRXdS)
Nc@seZdZdS)z<Test_TestCase.testAssertRaisesContext.<locals>.ExceptionMockN)rrrr
r
r
rr��sr�cs�d��dS)Nz	We expectr
r
)r�r
rr��sz3Test_TestCase.testAssertRaisesContext.<locals>.Stubrz	We expectr�r�r�r�r~�*)
rr*r1rlr�r(r�rr+�assertRaisesRegexr�r�rf)rr�r�r
)r�r�testAssertRaisesContext�s,z%Test_TestCase.testAssertRaisesContextc&Cs�|jt��|j�WdQRX|jt��|jd�WdQRX|jt��|jt�WdQRX|jt��|jtdf�WdQRX|jt��|jttf�WdQRXdS)Nr4)r*�	TypeErrorr�r1)rr
r
r�testAssertRaisesNoExceptionType�sz-Test_TestCase.testAssertRaisesNoExceptionTypecCsHdd�}tj|�}|jt|�|j|tj|��dS)NcSs)y
t�Wntk
r$t�YnXdS)N)r1r
r
r
r�func�s

z4Test_TestCase.testAssertRaisesRefcount.<locals>.func)r��getrefcountr*r1r()rr	Zrefcountr
r
r�testAssertRaisesRefcount�sz&Test_TestCase.testAssertRaisesRefcountcs�Gdd�dt���fdd�}|j�tjd�|�|j�d|�|jt��|j�dd�WdQRXdS)Nc@seZdZdS)z:Test_TestCase.testAssertRaisesRegex.<locals>.ExceptionMockN)rrrr
r
r
rr�
sr�cs�d��dS)Nz	We expectr
r
)r�r
rr�
sz1Test_TestCase.testAssertRaisesRegex.<locals>.Stubzexpect$)rr�re�compilerr�)rr�r
)r�r�testAssertRaisesRegex	sz#Test_TestCase.testAssertRaisesRegexc%Cs�|j|jd|jttjd�dd��|j|jd|jtddd��|j|jd��%|jtddd��WdQRXWdQRX|jtd��<|jt��%|jtddd	��WdQRXWdQRXWdQRXdS)
Nz"^Exception not raised by <lambda>$r�cSsdS)Nr
r
r
r
rr�sz8Test_TestCase.testAssertNotRaisesRegex.<locals>.<lambda>cSsdS)Nr
r
r
r
rr�sr��expectr~r)	rr+rrr
r�r�r*rf)rr
r
r�testAssertNotRaisesRegexs	
	
z&Test_TestCase.testAssertNotRaisesRegexcCs9Gdd�dt�}|jt|j|dd��dS)Nc@seZdZdS)z>Test_TestCase.testAssertRaisesRegexInvalidRegex.<locals>.MyExcN)rrrr
r
r
r�MyExc*srcSsdS)NTr
r
r
r
rr�,szATest_TestCase.testAssertRaisesRegexInvalidRegex.<locals>.<lambda>)rr*rr)rrr
r
r�!testAssertRaisesRegexInvalidRegex(sz/Test_TestCase.testAssertRaisesRegexInvalidRegexcCs9Gdd�dt�}|jt|j|dd��dS)Nc@seZdZdS)z>Test_TestCase.testAssertWarnsRegexInvalidRegex.<locals>.MyWarnN)rrrr
r
r
r�MyWarn0srcSsdS)NTr
r
r
r
rr�2sz@Test_TestCase.testAssertWarnsRegexInvalidRegex.<locals>.<lambda>)�Warningr*rr�)rrr
r
r� testAssertWarnsRegexInvalidRegex.sz.Test_TestCase.testAssertWarnsRegexInvalidRegexcCs]dd�}|j|jd|jtd|�|j|jd|jttjd�|�dS)NcSstd��dS)NZ
Unexpected)rr
r
r
rr�5sz9Test_TestCase.testAssertRaisesRegexMismatch.<locals>.Stubz*"\^Expected\$" does not match "Unexpected"z
^Expected$)rr+rrr
)rr�r
r
r�testAssertRaisesRegexMismatch4s	z+Test_TestCase.testAssertRaisesRegexMismatchc
s�Gdd�dt���fdd�}d}|j��}|�||�WdQRX|j}|j|��|j|jd|�dS)Nc@seZdZdS)z=Test_TestCase.testAssertRaisesExcValue.<locals>.ExceptionMockN)rrrr
r
r
rr�Dsr�cs�|��dS)Nr
)r
)r�r
rr�Gsz4Test_TestCase.testAssertRaisesExcValue.<locals>.Stubzparticular valuer)rr*r�rlr(r�)rr��v�ctxr�r
)r�r�testAssertRaisesExcValueCs	z&Test_TestCase.testAssertRaisesExcValuec-Cs�|jt��|j�WdQRX|jt��|jt�WdQRX|jt��|jdd�WdQRX|jt��|jtd�WdQRX|jt��|jtdfd�WdQRX|jt��|jttfd�WdQRXdS)Nr4r)r*rrr1r�)rr
r
r�$testAssertRaisesRegexNoExceptionTypeRsz2Test_TestCase.testAssertRaisesRegexNoExceptionTypec-CsRdd�}|jt|�|jt|�|jttf|�|jttjddt�|j|j��|jtdd��WdQRX|jt��|jtd�WdQRXtj��?tjdt�|j|j��|jt|�WdQRXWdQRXtj��<tjdt�|jt��|jt|�WdQRXWdQRXdS)	NcSstjdt�dS)Nr
)r��warn�RuntimeWarningr
r
r
r�
_runtime_warnasz<Test_TestCase.testAssertWarnsCallable.<locals>._runtime_warnr
�categorycSsdS)Nrr
r
r
r
rr�msz7Test_TestCase.testAssertWarnsCallable.<locals>.<lambda>�defaultr�)	rrr�r�rr*r+r�r�)rrr
r
r�testAssertWarnsCallable`s$	

z%Test_TestCase.testAssertWarnsCallablecyCs}dd�}tj|�d}|jt��}|�WdQRX|jttf��}|�WdQRX|j|jt�|j|jjdd�|j	d|j
�|j|j|d�|jt��|�|�WdQRX|jt��tj
ddt�WdQRX|j|j��|jt��WdQRXWdQRX|j|jd��"|jtd	d��WdQRXWdQRX|jtd��9|jt��"|jtdd
��WdQRXWdQRXWdQRXtj��Mtjdt�|j|j��#|jt��|�WdQRXWdQRXWdQRXtj��Jtjdt�|jt��#|jt��|�WdQRXWdQRXWdQRXdS)
NcSstjdt�dS)Nr
)r�rrr
r
r
rr�sz;Test_TestCase.testAssertWarnsContext.<locals>._runtime_warnr4rr
ztest_case.pyrr�r~rrr�)�inspect�getsourcelinesrrr�rl�warningr(r�r��filename�linenor�rr*r+rr�rfr�r�)rr�_runtime_warn_linenor�r
r
r�testAssertWarnsContext}sF

z$Test_TestCase.testAssertWarnsContextc-Cs�|jt��|j�WdQRX|jt��|jd�WdQRX|jt��|jt�WdQRX|jt��|jtdf�WdQRX|jt��|jttf�WdQRX|jt��|jttf�WdQRXdS)Nr4)r*rrr��UserWarningr)rr
r
r�testAssertWarnsNoExceptionType�sz,Test_TestCase.testAssertWarnsNoExceptionTypec6Csadd�}|jtd|d�|j|j��|jtddd��WdQRX|jt��|jtdd�WdQRXtj��Etjdt�|j|j��|jtd|d�WdQRXWdQRX|j|j��|jtd|d�WdQRXtj��Ktjd	t�|jt|jf��|jtd|d�WdQRXWdQRXdS)
NcSstj|t�dS)N)r�rr)r~r
r
rr�szATest_TestCase.testAssertWarnsRegexCallable.<locals>._runtime_warnzo+�fooxcSsdS)Nrr
r
r
r
rr��sz<Test_TestCase.testAssertWarnsRegexCallable.<locals>.<lambda>r�barzr�)	r�rr*r+rr�r�r�r�)rrr
r
r�testAssertWarnsRegexCallable�s*


z*Test_TestCase.testAssertWarnsRegexCallablecrCsjdd�}tj|�d}|jtd��}|d�WdQRX|j|jt�|j|jjdd�|jd|j	�|j|j
|d�|j|j��|jtd��WdQRXWdQRX|j
|jd��%|jtdd	d��WdQRXWdQRX|jtd��<|jt��%|jtddd
��WdQRXWdQRXWdQRXtj��Stjdt�|j|j��)|jtd��|d�WdQRXWdQRXWdQRX|j|j��)|jtd��|d�WdQRXWdQRXtj��Ytjd
t�|jt|jf��)|jtd��|d�WdQRXWdQRXWdQRXdS)NcSstj|t�dS)N)r�rr)r~r
r
rr�sz@Test_TestCase.testAssertWarnsRegexContext.<locals>._runtime_warnr4zo+r*rztest_case.pyr�r~rrr+r�)r!r"r�rrlr#r(r�r�r$r%r*r+rr�rfr�r�r�)rrr&r�r
r
r�testAssertWarnsRegexContext�s>

z)Test_TestCase.testAssertWarnsRegexContextc4Cs|jt��|j�WdQRX|jt��|jt�WdQRX|jt��|jdd�WdQRX|jt��|jtd�WdQRX|jt��|jtdfd�WdQRX|jt��|jttfd�WdQRX|jt��|jttfd�WdQRXdS)Nr4r)r*rr�r(r�r)rr
r
r�#testAssertWarnsRegexNoExceptionType
sz1Test_TestCase.testAssertWarnsRegexNoExceptionTypec
cs2t��}dVWdQRX|j|j�d�dS)Nr�)r	r(�getvalue)r�bufr
r
r�assertNoStderrszTest_TestCase.assertNoStderrcCs�|jt|�t|��xft||�D]U\}}|j|tj�x3|j�D]%\}}|jt||�|�qXWq,WdS)N)r(r��ziprl�logging�	LogRecord�items�getattr)r�records�matchesZrec�match�krr
r
r�assertLogRecords s
zTest_TestCase.assertLogRecordscCsz|j��g|j��!}tjd�tjd�WdQRX|j|jdg�|j|j	ddig�WdQRXdS)N�1r�z
INFO:foo:1�namer
)
r1�
assertLogs�log_foo�info�
log_foobar�debugr(�outputr;r7)rr�r
r
r�testAssertLogsDefaults's

z$Test_TestCase.testAssertLogsDefaultscCs�|j���|j��.}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jddiddig�WdQRXdS)	Nr<r��3z
INFO:foo:1zWARNING:quux:3r=r
r)r1r>r?r@rArB�log_quuxr#r(rCr;r7)rr�r
r
r�!testAssertLogsTwoMatchingMessages0s


z/Test_TestCase.testAssertLogsTwoMatchingMessagescCs�|j���|jd|��.}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jddidd	ig�WdQRXdS)
N�levelr<r�rEzERROR:foo.bar:2zCRITICAL:quux:3r=zfoo.barr)r1r>r?r#rAr�rF�criticalr(rCr;r7)rrHr�r
r
r�checkAssertLogsPerLevel;s


z%Test_TestCase.checkAssertLogsPerLevelcCs!|jtj�|jd�dS)N�ERROR)rJr3rK)rr
r
r�testAssertLogsPerLevelFsz$Test_TestCase.testAssertLogsPerLevelcCs�|j���|jdd���}|j|dd��.}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jdd	idd
ig�WdQRX|j|j	dg�WdQRXdS)NrH�DEBUGr<r�rEz
INFO:foo:1zDEBUG:foo.bar:2r=r
zfoo.barzWARNING:quux:3)r1r>r?r@rArBrFr#r(rCr;r7)r�loggerZouter_cmr�r
r
r�checkAssertLogsPerLoggerJs


 z&Test_TestCase.checkAssertLogsPerLoggercCs'|jtjd��|jd�dS)Nr
)rOr3�	getLogger)rr
r
r�testAssertLogsPerLoggerXsz%Test_TestCase.testAssertLogsPerLoggercCsF|j��3|j|j��|j��WdQRXWdQRXWdQRXdS)N)r1r*r+r>)rr
r
r�testAssertLogsFailureNoLogs\s

z)Test_TestCase.testAssertLogsFailureNoLogscCsY|j��F|j|j��,|jdd��tjd�WdQRXWdQRXWdQRXdS)NrH�WARNINGr<)r1r*r+r>r?r@)rr
r
r�!testAssertLogsFailureLevelTooHighcs
z/Test_TestCase.testAssertLogsFailureLevelTooHighcCs_|jddd��C|j|j��)|jd��tjd�WdQRXWdQRXWdQRXdS)NrrHrKr
r<)r>r*r+rFr�)rr
r
r�&testAssertLogsFailureMismatchingLoggerjsz4Test_TestCase.testAssertLogsFailureMismatchingLoggercCs;|jdf|jdf|jdf|jdf|jdf|jdf|jdf|jdf|jdf|j	df|j
tdd�ff|jdf|j
td
ddd
�td
ddd
dd�ff|jtddd�ff|jdff}x5|D]-\}}|jt��||�WdQRXqWdS)Nr&r��@�@�@TcSsddS)Ng��Q�	@Zspamr
)�_r
r
rr��sz9Test_TestCase.testDeprecatedMethodNames.<locals>.<lambda>Fr|r4r}r'rbr
cSsidS)Nr
r
r
r
r
rr��sr�)r&r�)r&r�)r&r&)r&r&)rVrV)rVrV)rWrX)rWrX)T)T)F)r�r�)�failIfEqualZassertNotEquals�failUnlessEqualZassertEquals�failUnlessAlmostEqualZassertAlmostEquals�failIfAlmostEqualZassertNotAlmostEquals�
failUnlessZassert_�failUnlessRaisesr�failIfr�r�ZassertRaisesRegexp�KeyErrorZassertRegexpMatchesrr�)r�old�methr�r
r
r�testDeprecatedMethodNamesrs$6z'Test_TestCase.testDeprecatedMethodNamescCsttjdd�dkrdSddddddd	d
g}x2|D]*}|jt��t||�WdQRXqBWdS)Nr'r&rZr[r\r]r^r_r`r�)r&r&)r��version_infor*r,r6)rZdeprecated_namesZdeprecated_namer
r
r�_testDeprecatedFailMethods�s		
z(Test_TestCase._testDeprecatedFailMethodscCs3Gdd�dtj�}|d�}t|�dS)Nc@seZdZdd�ZdS)z0Test_TestCase.testDeepcopy.<locals>.TestableTestcSsdS)Nr
)rr
r
r�testNothing�sz<Test_TestCase.testDeepcopy.<locals>.TestableTest.testNothingN)rrrrgr
r
r
r�TestableTest�srhrg)r!r"r)rrhrr
r
r�testDeepcopy�szTest_TestCase.testDeepcopycCs{tjd�}xettjd�D]P}tj|d|�}tj|�}|j||�|jt�t��q#WdS)Nr-r4�protocol)	r!r"r��pickle�HIGHEST_PROTOCOL�dumps�loadsr(r�)rrrjZpickled_testZunpickled_testr
r
r�
testPickle�szTest_TestCase.testPicklec
s�ddd��dd��G�fdd�dtj�}G��fdd�dtj�}G��fd	d
�d
tj�}G�fdd�dtj�}xA||||fD]-}|jt��|d
�j�WdQRXq�WdS)NcSs
t�dS)N)�KeyboardInterrupt)rr
r
r�_raise�sz3Test_TestCase.testKeyboardInterrupt.<locals>._raisecSsdS)Nr
)rr
r
r�nothing�sz4Test_TestCase.testKeyboardInterrupt.<locals>.nothingcseZdZ�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test1N)rrr�test_somethingr
)rqr
r�Test1�srtcseZdZ�Z�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test2N)rrrrrsr
)rqrrr
r�Test2�srucseZdZ�Z�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test3N)rrrrsr r
)rqrrr
r�Test3�srvcs"eZdZ�fdd�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test4cs|j��dS)N)r�)r)rqr
rrs�szATest_TestCase.testKeyboardInterrupt.<locals>.Test4.test_somethingN)rrrrsr
)rqr
r�Test4�srwrs)r!r"r*rpr-)rrtrurvrw�klassr
)rqrrr�testKeyboardInterrupt�s""z#Test_TestCase.testKeyboardInterruptcs	ddd��dd��G�fdd�dtj�}G��fdd�dtj�}G��fd	d
�d
tj�}G�fdd�dtj�}xe||||fD]Q}tj�}|d
�j|�|jt|j�d�|j|jd�q�WdS)NcSstjd��dS)Nzsome reason)r!ZSkipTest)rr
r
r�_skip�sz3Test_TestCase.testSkippingEverywhere.<locals>._skipcSsdS)Nr
)rr
r
rrr�sz5Test_TestCase.testSkippingEverywhere.<locals>.nothingcseZdZ�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test1N)rrrrsr
)rzr
rrt�srtcseZdZ�Z�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test2N)rrrrrsr
)rzrrr
rru�srucseZdZ�Z�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test3N)rrrrsr r
)rzrrr
rrv�srvcs"eZdZ�fdd�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test4cs|j��dS)N)r�)r)rzr
rrs�szBTest_TestCase.testSkippingEverywhere.<locals>.Test4.test_somethingN)rrrrsr
)rzr
rrw�srwrsr4)r!r"r8r-r(r�Zskipped�testsRun)rrtrurvrwrxr9r
)rzrrr�testSkippingEverywhere�s""z$Test_TestCase.testSkippingEverywherecs	ddd��dd��G�fdd�dtj�}G��fdd�dtj�}G��fd	d
�d
tj�}G�fdd�dtj�}xe||||fD]Q}tj�}|d
�j|�|jt|j�d�|j|jd�q�WdS)NcSs
t�dS)N)�
SystemExit)rr
r
rrq�sz,Test_TestCase.testSystemExit.<locals>._raisecSsdS)Nr
)rr
r
rrr�sz-Test_TestCase.testSystemExit.<locals>.nothingcseZdZ�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test1N)rrrrsr
)rqr
rrt�srtcseZdZ�Z�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test2N)rrrrrsr
)rqrrr
rru�srucseZdZ�Z�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test3N)rrrrsr r
)rqrrr
rrv�srvcs"eZdZ�fdd�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test4cs|j��dS)N)r�)r)rqr
rrs�sz:Test_TestCase.testSystemExit.<locals>.Test4.test_somethingN)rrrrsr
)rqr
rrw�srwrsr4)r!r"r8r-r(r��errorsr{)rrtrurvrwrxr9r
)rqrrr�testSystemExit�s""zTest_TestCase.testSystemExitc	CsFtj�}tj|�}tj��~|j|��WdQRXdS)N)r!r"�weakref�refrZ
disable_gcr�)rr��wrr
r
r�testNoCycless

zTest_TestCase.testNoCyclescsyG�fdd�dt��G�fdd�dtj�}x7dD]/}||�}|j�|j�jd�qBWdS)	Ncs:eZdZdZ�fdd�Z�fdd�ZdS)z9Test_TestCase.test_no_exception_leak.<locals>.MyExceptionrcs �jd7_tj|�dS)Nr4)�	ninstancerr)r)r$r
rrszBTest_TestCase.test_no_exception_leak.<locals>.MyException.__init__cs�jd8_dS)Nr4)r�)r)r$r
r�__del__szATest_TestCase.test_no_exception_leak.<locals>.MyException.__del__N)rrrr�rr�r
)r$r
rr$sr$cs=eZdZ�fdd�Zej�fdd��ZdS)z6Test_TestCase.test_no_exception_leak.<locals>.TestCasecs
���dS)Nr
)r)r$r
rrsz<Test_TestCase.test_no_exception_leak.<locals>.TestCase.test1cs
���dS)Nr
)r)r$r
rrsz<Test_TestCase.test_no_exception_leak.<locals>.TestCase.test2N)rrrrr!ZexpectedFailurerr
)r$r
rr"sr"rrr)rr)rr!r"r-r(r�)rr"Zmethod_nameZtestcaser
)r$r�test_no_exception_leak
s


z$Test_TestCase.test_no_exception_leakN)orrrrrZeq_pairsrZne_pairsr.r0r3r5r:r@rCrDrErGrHrIrJrKrRrUrVrWrYrZr\rdrgrhrirjrkrnrprrrurxr!ZskipIfr�r��optimizeryrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrrrr r'r)r,r-r.r��contextmanagerr1r;rDrGrJrLrOrQrRrTrUrdrfriroryr|rrZcpython_onlyr�r�r
r
r
rr#8s�!!

		

!
	

%4($>(:L!
1!-	
r#�__main__)!r�r�r�rkrr�r3r�r�r!�copyrrrr!Zunittest.test.supportrrrrrZtest.supportr	rPr?rArFr�rr"r#r�mainr
r
r
r�<module>s6(�������