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.pyc



��Yf��@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@s^eZdZdZGdd�dej�ZGdd�de�ZGdd�dej�ZdS)	�Testz5Keep these TestCase classes out of the main namespacec@s(eZdZdd�Zdd�ZdS)zTest.FoocCsdS)N�)�selfr
r
�</opt/alt/python35/lib64/python3.5/unittest/test/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rcsLeZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�S)
zTest.LoggingTestCasez!A test case which logs its calls.cs&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)rrr�__doc__rrrr r
r
)rrr's
rN)	rrrr!�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))rrr:�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
rr7�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)rrrr7rr
)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))rrr:r@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
rr7�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)rrrr7rr
)r)rrr�srrBr=rrr r>r?rC)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)rrr3)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))rrr:r@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
rr7�sz`Test_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.defaultTestResultcs$t�|�j�|jd�dS)Nzraised by Foo.test)rrr3)r)rrr
rr�szSTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.test)rrrr7rr
)r)rrr�srrBr=rrr rGr?rC)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))rrr:r@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
rr7szbTest_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)rrrr7r r
)r)rrrsrrBr=rrr r>r?rC)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
rr7-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)rrrr7rr
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)
Nr5r(r'�i�failure�j�zraised by Foo.testr)rr�subTestr3r<)rrMrO)rrr
rr6s
"z;Test_TestCase._check_call_order__subtests.<locals>.Foo.test)rrrrr
)r)rrr5sr)rrr.r))rr:r�expected_eventsr
)rr�_check_call_order__subtests4sz)Test_TestCase._check_call_order__subtestscCsPg}t|�}dddddddddddg}|j|||�dS)	Nr=rrr �addSubTestFailure�addSubTestSuccessr>r?)rrS)rrr:r@r
r
r�test_run_call_order__subtestsLsz+Test_TestCase.test_run_call_order__subtestscCsAg}t|�}ddddddg}|j|||�dS)Nr=rrr rGr?)rrS)rrr:r@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)Nr5r(rMr'rO)rrrQ)rrMrO)rrr
rr`szCTest_TestCase._check_call_order__subtests_success.<locals>.Foo.test)rrrrr
)r)rrr_sr)rrr.r))rr:rrRr
)rr�#_check_call_order__subtests_success^s	z1Test_TestCase._check_call_order__subtests_successcCsPg}t|�}ddddgddgddg}|j|||�dS)	Nr=rrr rPrU�
addSuccessr?)rrX)rrr:r@r
r
r�%test_run_call_order__subtests_successks'z3Test_TestCase.test_run_call_order__subtests_successcCsAg}t|�}ddddddg}|j|||�dS)Nr=rrr rYr?)rrX)rrr:r@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)NrMr5rNr()rrrQr3)r)rrr
rr�szFTest_TestCase.test_run_call_order__subtests_failfast.<locals>.Foo.test)rrrrr
)r)rrr�srr=rrr rTr?)r�failfastrrr.r))rrr:r@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)rQr)r)rr
r�test_a�s
z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_acsS|j���jd�WdQRX|j��|jd�WdQRX�jd�dS)N�b1rNZb2)rQrr3)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`rbrdr
)rr
rr�srTr^r_ra)r"r#r9r\Z	makeSuiter.r))rrr:Zsuiter@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=rGr?)rr"r#rfr,r<r.r))rrr:rr@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
)r3)rr
r
rr�szRTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.Foo.testN)rrrrr<r,r
r
r
rr�srrr=rGr?)rr"r#rfr,r<r.r))rrr:rr@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
rr7szMTest_TestCase.test_run__uses_defaultTestResult.<locals>.Foo.defaultTestResultN)rrrrr7r
)rprr
rrsrrrBr=rYr?rC)rr"r#r.rfr))rrr:r@r
)rprr� 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#r9r.rf)rrr:�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)rf)rr:)�resultIn�	resultOutr
rr.5szOTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.runN)rrrrr.r
)rtrur
rr1srr)r"r9r#rf)rrrrr
)rtrur�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)z7Tests shortDescription() for a method with a docstring.N)r)rx)rr
r
r�(testShortDescriptionWithOneLineDocstringAs	z6Test_TestCase.testShortDescriptionWithOneLineDocstringcCs|j|j�d�dS)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)rx)rr
r
r�*testShortDescriptionWithMultiLineDocstringIs		z8Test_TestCase.testShortDescriptionWithMultiLineDocstringcsuGdd�dt������}}|j||k�d�fdd�}|j�|�|j||�dS)Nc@seZdZdZdS)z7Test_TestCase.testAddTypeEqualityFunc.<locals>.SadSnakez)Dummy class for test_addTypeEqualityFunc.N)rrrr!r
r
r
r�SadSnakeXsr|cs$t|�t|�ko!�kSS)N)r8)�a�b�msg)r|r
r�AllSnakesCreatedEqual\szDTest_TestCase.testAddTypeEqualityFunc.<locals>.AllSnakesCreatedEqual)�object�assertFalseZaddTypeEqualityFuncr))r�s1�s2r�r
)r|r�testAddTypeEqualityFuncWsz%Test_TestCase.testAddTypeEqualityFunccCs<t�}|j||�|j|j|j|t��dS)N)r�rfr+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)rm�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(r5r'�drZotter�x�Zelephantrc)�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}r5r~r(�onerc�css|]}t|�VqdS)N)�chr)�.0rMr
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) failedrr
z$assertEqual(%r, %r) with msg= failedz/assertEqual(%r, %r) with third parameter failedr�r5r(�r')�set�	frozensetr)r,r3r+)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}r5r�zThese are unequal)�assertListEqual�assertTupleEqual�assertSequenceEqualr+r"r#r,�tuple�extend�assertDictEqual�update)rr}r~rcr�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~�
r5rz!assertSequenceEqual did not fail.i�ii)r)�maxDiffr��difflibZndiff�pprintZpformat�
splitlinesr"�case�DIFF_OMITTED�lenr�r,�argsr3�
assertLessr��
assertGreaterr�)rZseq1Zseq2�diff�omitted�err
r
r�testAssertSequenceEqualMaxDiffs< 
 
	 
z,Test_TestCase.testAssertSequenceEqualMaxDiffcCs�d|_|jdd�}tjjtd�}|j|d|�d|_|jdd�}|j|d�d|_|jdd�}|j|d�dS)Nr5r
�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
)rr�r
r
r�truncate>sz<Test_TestCase.testAssertDictEqualTruncates.<locals>.truncater5rr
zassertDictEqual did not fail)r"r#r�r�r,r)rnr3)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
)rr�r
r
rr�JszATest_TestCase.testAssertMultiLineEqualTruncates.<locals>.truncater
r�z!assertMultiLineEqual did not fail)r"r#r��assertMultiLineEqualr,r)rnr3)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~�^rPcSstd��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�rn�	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)rnr�)rr�r�r�r�rc�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)!Nr5r(r'r
r�Zbaz�2r}Tr�r0�r�rFr�y@y@r~ZaaabccdZabbbccer�r����)r'r5r})r5r'r~)r5rr�)rr5r�)r'r5r})r5r'r~)r5rr�)rr5r�)
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
rr5r(r'r�r�)rr5)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(r5g�������?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�r5)r�r�r,rn�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�r5)r)r,rnr�)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)rwr+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+r2�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�rr�r�r�*)
rr+r2rmr�r)r�rr,�assertRaisesRegexr�r�rg)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)Nr5)r+�	TypeErrorr�r2)rr
r
r�testAssertRaisesNoExceptionType�sz-Test_TestCase.testAssertRaisesNoExceptionTypecCsHdd�}tj|�}|jt|�|j|tj|��dS)NcSs)y
t�Wntk
r$t�YnXdS)N)r2r
r
r
r�func�s

z4Test_TestCase.testAssertRaisesRefcount.<locals>.func)r��getrefcountr+r2r))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��expectrr)	rr,rr
rr�r�r+rg)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�rmr)r�)rr��vZctxr�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)Nr5r)r+rrr2r�)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_warnr5rr
ztest_case.pyrr�rrrr�)�inspect�getsourcelinesrrr�rm�warningr)r�r��filename�linenor�rr+r,rr�rgr�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)Nr5)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)rr
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)rr
r
rr�sz@Test_TestCase.testAssertWarnsRegexContext.<locals>._runtime_warnr5zo+r*rztest_case.pyr�rrrr+r�)r!r"r�rrmr#r)r�r�r$r%r+r,rr�rgr�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)Nr5r)r+rr�r(r�r)rr
r
r�#testAssertWarnsRegexNoExceptionType
sz1Test_TestCase.testAssertWarnsRegexNoExceptionTypec
cs2t��}dVWdQRX|j|j�d�dS)Nr�)r	r)�getvalue)rZbufr
r
r�assertNoStderrszTest_TestCase.assertNoStderrcCs�|jt|�t|��xft||�D]U\}}|j|tj�x3|j�D]%\}}|jt||�|�qXWq,WdS)N)r)r��ziprm�loggingZ	LogRecord�items�getattr)r�recordsZmatchesZrec�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
)
r0�
assertLogs�log_foo�info�
log_foobar�debugr)�outputr8r5)rr�r
r
r�testAssertLogsDefaults's

z$Test_TestCase.testAssertLogsDefaultscCs�|j���|j��.}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jddiddig�WdQRXdS)	Nr9r��3z
INFO:foo:1zWARNING:quux:3r:r
r)r0r;r<r=r>r?�log_quuxr#r)r@r8r5)rr�r
r
r�!testAssertLogsTwoMatchingMessages0s


z/Test_TestCase.testAssertLogsTwoMatchingMessagescCs�|j���|jd|��.}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jddidd	ig�WdQRXdS)
N�levelr9r�rBzERROR:foo.bar:2zCRITICAL:quux:3r:zfoo.barr)r0r;r<r#r>r�rCZcriticalr)r@r8r5)rrEr�r
r
r�checkAssertLogsPerLevel;s


z%Test_TestCase.checkAssertLogsPerLevelcCs!|jtj�|jd�dS)N�ERROR)rFr2rG)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)NrE�DEBUGr9r�rBz
INFO:foo:1zDEBUG:foo.bar:2r:r
zfoo.barzWARNING:quux:3)r0r;r<r=r>r?rCr#r)r@r8r5)rZloggerZouter_cmr�r
r
r�checkAssertLogsPerLoggerJs


 z&Test_TestCase.checkAssertLogsPerLoggercCs'|jtjd��|jd�dS)Nr
)rJr2�	getLogger)rr
r
r�testAssertLogsPerLoggerXsz%Test_TestCase.testAssertLogsPerLoggercCsF|j��3|j|j��|j��WdQRXWdQRXWdQRXdS)N)r0r+r,r;)rr
r
r�testAssertLogsFailureNoLogs\s

z)Test_TestCase.testAssertLogsFailureNoLogscCsY|j��F|j|j��,|jdd��tjd�WdQRXWdQRXWdQRXdS)NrEZWARNINGr9)r0r+r,r;r<r=)rr
r
r�!testAssertLogsFailureLevelTooHighcs
z/Test_TestCase.testAssertLogsFailureLevelTooHighcCs_|jddd��C|j|j��)|jd��tjd�WdQRXWdQRXWdQRXdS)NrrErGr
r9)r;r+r,rCr�)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)zY
        Test that the deprecated methods raise a DeprecationWarning. See #9424.
        r'r��@�@�@TcSsddS)Ng��Q�	@Zspamr
)�_r
r
rr��sz9Test_TestCase.testDeprecatedMethodNames.<locals>.<lambda>Fr}r5r~r(rcr
cSsidS)Nr
r
r
r
r
rr��sr�N)r'r�)r'r�)r'r')r'r')rPrP)rPrP)rQrR)rQrR)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�dkrdSdddddd	d
dg}x2|D]*}|jt��t||�WdQRXqBWdS)
z9Test that the deprecated fail* methods get removed in 3.xNr(r'rTrUrVrWrXrYrZr�)r'r')r��version_infor+r-r4)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)rrrrar
r
r
r�TestableTest�srbra)r"r#r)rrbrr
r
r�testDeepcopy�szTest_TestCase.testDeepcopycCs{tjd�}xettjd�D]P}tj|d|�}tj|�}|j||�|jt�t��q#WdS)Nr.r5�protocol)	r"r#r��pickleZHIGHEST_PROTOCOL�dumps�loadsr)r�)rrrdZ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
)rjr
r�Test1�srmcseZdZ�Z�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test2N)rrrrrlr
)rjrkr
r�Test2�srncseZdZ�Z�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test3N)rrrrlr r
)rjrkr
r�Test3�srocs"eZdZ�fdd�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test4cs|j��dS)N)r�)r)rjr
rrl�szATest_TestCase.testKeyboardInterrupt.<locals>.Test4.test_somethingN)rrrrlr
)rjr
r�Test4�srprl)r"r#r+rir.)rrmrnrorp�klassr
)rjrkr�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
rrk�sz5Test_TestCase.testSkippingEverywhere.<locals>.nothingcseZdZ�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test1N)rrrrlr
)rsr
rrm�srmcseZdZ�Z�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test2N)rrrrrlr
)rsrkr
rrn�srncseZdZ�Z�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test3N)rrrrlr r
)rsrkr
rro�srocs"eZdZ�fdd�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test4cs|j��dS)N)r�)r)rsr
rrl�szBTest_TestCase.testSkippingEverywhere.<locals>.Test4.test_somethingN)rrrrlr
)rsr
rrp�srprlr5)r"r#r9r.r)r�Zskipped�testsRun)rrmrnrorprqr:r
)rsrkr�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
rrj�sz,Test_TestCase.testSystemExit.<locals>._raisecSsdS)Nr
)rr
r
rrk�sz-Test_TestCase.testSystemExit.<locals>.nothingcseZdZ�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test1N)rrrrlr
)rjr
rrm�srmcseZdZ�Z�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test2N)rrrrrlr
)rjrkr
rrn�srncseZdZ�Z�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test3N)rrrrlr r
)rjrkr
rro�srocs"eZdZ�fdd�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test4cs|j��dS)N)r�)r)rjr
rrl�sz:Test_TestCase.testSystemExit.<locals>.Test4.test_somethingN)rrrrlr
)rjr
rrp�srprlr5)r"r#r9r.r)r��errorsrt)rrmrnrorprqr:r
)rjrkr�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)Nr5)�	ninstancerr)r)r%r
rrszBTest_TestCase.test_no_exception_leak.<locals>.MyException.__init__cs�jd8_dS)Nr5)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/r1r4r6r;rArDrErFrHrIrJrKrLrSrVrWrXrZr[r]rerhrirjrkrlrorqrsrvryr"ZskipIfr�r��optimizerzr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rrrrrrrrr r'r)r,r-r.r��contextmanagerr0r8rArDrFrHrJrLrMrNrOr^r`rcrhrrrurxrZcpython_onlyr|rr
r
r
rr$8s�!!

		

!
	

%4($>(:L!
1!-	
r$�__main__)!r�r�r�rer
r�r2r�ryr!�copyrrrr"Zunittest.test.supportrrrrrZtest.supportr	rKr<r>rCr�rr#r$r�mainr
r
r
r�<module>s6(�������