Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/unittest/test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/unittest/test/__pycache__/test_case.cpython-36.pyc

3

� f&�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlZddlmZmZmZmZmZddlmZejd�Zejd�Zejd�ZGd	d
�d
e�ZGdd�dejee�Zed
kr�ej �dS)�N)�deepcopy)�support)�TestEquality�TestHashing�
LoggingResult�LegacyLoggingResult�#ResultWithNoStartTestRunStopTestRun)�captured_stderr�foozfoo.bar�quuxc@sDeZdZdZGdd�dej�ZGdd�de�ZGdd�dej�ZdS)	�Testz5Keep these TestCase classes out of the main namespacec@seZdZdd�Zdd�ZdS)zTest.FoocCsdS)N�)�selfr
r
�</opt/alt/python36/lib64/python3.6/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 src@seZdZdd�ZdS)zTest.BarcCsdS)Nr
)rr
r
r�test2%szTest.Bar.test2N)rrrrr
r
r
r�Bar$srcs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
zTest.LoggingTestCasez!A test case which logs its calls.csttj|�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 �
__classcell__r
r
)rrr's
rN)	rrrr!�unittest�TestCaserrrr
r
r
rrsr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'dDdE�Z(e)j*e+j,j-dFkdG�dHdI��Z.e)j*e+j,j-dFkdG�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��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_TestCaserrrcCs�Gdd�dtj�}|j|�j�dd�d�tj�}|jdd�|j|j��|jdd�WdQRX|jt��|j�WdQRXdS)Nc@seZdZdd�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Ssr�
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_namecCs2Gdd�dtj�}|j|d�j�dd�d�dS)Nc@seZdZdd�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hsrr�
z
.Test.testi����)r#r$r*r+)rrr
r
r�test_init__test_name__validgsz)Test_TestCase.test_init__test_name__validcCsBGdd�dtj�}y|d�Wntk
r2YnX|jd�dS)Nc@seZdZdd�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ssrZtestfoozFailed to raise ValueError)r#r$�
ValueError�fail)rrr
r
r�test_init__test_name__invalidrsz+Test_TestCase.test_init__test_name__invalidcCs*Gdd�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�srr�)r#r$r*ZcountTestCases)rrr
r
r�test_countTestCases�sz!Test_TestCase.test_countTestCasescCs2Gdd�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�sr)r#r$�defaultTestResultr*�type�
TestResult)rr�resultr
r
r�test_defaultTestResult�s
z$Test_TestCase.test_defaultTestResultcsLg}t|�}G�fdd�dtj���|�j|�ddddg}|j||�dS)NcseZdZ��fdd�Z�ZS)z>Test_TestCase.test_run_call_order__error_in_setUp.<locals>.Foocst�|�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
)r)rrr�sr�	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_setUpcsFg}G�fdd�dtj���|�j�ddddddg}|j||�dS)	Ncs&eZdZdd�Z��fdd�Z�ZS)zMTest_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr8�sz_Test_TestCase.test_run_call_order__error_in_setUp_default_result.<locals>.Foo.defaultTestResultcst�|�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)rrrr8rr"r
)r)rrr�sr�startTestRunr>rr?r@�stopTestRun)rrr/r*)rrrAr
)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)	NcseZdZ��fdd�Z�ZS)z=Test_TestCase.test_run_call_order__error_in_test.<locals>.Foocst�|�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
)r)rrr�srr>rrr r?r@)rrrr/r*)rrr;rAr
)rr�"test_run_call_order__error_in_test�sz0Test_TestCase.test_run_call_order__error_in_testcsJg}G�fdd�dtj��ddddddd	d
g}�|�j�|j||�dS)Ncs&eZdZdd�Z��fdd�Z�ZS)zLTest_TestCase.test_run_call_order__error_in_test_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr8�sz^Test_TestCase.test_run_call_order__error_in_test_default_result.<locals>.Foo.defaultTestResultcst�|�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)rrrr8rr"r
)r)rrr�srrCr>rrr r?r@rD)rrr/r*)rrrAr
)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)	NcseZdZ��fdd�Z�ZS)z?Test_TestCase.test_run_call_order__failure_in_test.<locals>.Foocst�|�j�|jd�dS)Nzraised by Foo.test)rrr4)r)rrr
rr�szDTest_TestCase.test_run_call_order__failure_in_test.<locals>.Foo.test)rrrrr"r
)r)rrr�srr>rrr �
addFailurer@)rrrr/r*)rrr;rAr
)rr�$test_run_call_order__failure_in_test�sz2Test_TestCase.test_run_call_order__failure_in_testcsJG�fdd�dtj��ddddddd	d
g}g}�|�j�|j||�dS)Ncs&eZdZdd�Z��fdd�Z�ZS)zNTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr8�sz`Test_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.defaultTestResultcst�|�j�|jd�dS)Nzraised by Foo.test)rrr4)r)rrr
rr�szSTest_TestCase.test_run_call_order__failure_in_test_default_result.<locals>.Foo.test)rrrr8rr"r
)r)rrr�srrCr>rrr rHr@rD)rrr/r*)rrArr
)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)	NcseZdZ��fdd�Z�ZS)zATest_TestCase.test_run_call_order__error_in_tearDown.<locals>.Foocst�|�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
)r)rrrsrr>rrr r?r@)rrrr/r*)rrr;rAr
)rr�&test_run_call_order__error_in_tearDown
s
z4Test_TestCase.test_run_call_order__error_in_tearDowncsJG�fdd�dtj��g}�|�j�ddddddd	d
g}|j||�dS)Ncs&eZdZdd�Z��fdd�Z�ZS)zPTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.FoocSs
t|j�S)N)rr)rr
r
rr8szbTest_TestCase.test_run_call_order__error_in_tearDown_default_result.<locals>.Foo.defaultTestResultcst�|�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)rrrr8r r"r
)r)rrrsrrCr>rrr r?r@rD)rrr/r*)rrrAr
)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@seZdZdd�Zdd�ZdS)z=Test_TestCase.test_run_call_order_default_result.<locals>.FoocSst�S)N)r)rr
r
rr8-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)rrrr8rr
r
r
rr,srr)r#r$r/)rrr
r
r�"test_run_call_order_default_result*sz0Test_TestCase.test_run_call_order_default_resultcs4G�fdd�dtj���|�j|�|j||�dS)NcseZdZ��fdd�Z�ZS)z6Test_TestCase._check_call_order__subtests.<locals>.Foocs�t�|�j�xpd
D]h}|j|d��R|dkr8|jd�x8dD]0}|j|d��||dkrdtd��WdQRXq>WWdQRXqWdd	dS)Nr6r)r()�i�failure)�j�zraised by Foo.testr)r6r)r()r)r()rr�subTestr4r=)rrNrP)rrr
rr6s


$z;Test_TestCase._check_call_order__subtests.<locals>.Foo.test)rrrrr"r
)r)rrr5sr)rrr/r*)rr;r�expected_eventsr
)rr�_check_call_order__subtests4sz)Test_TestCase._check_call_order__subtestscCs8g}t|�}dddddddddddg}|j|||�dS)	Nr>rrr �addSubTestFailure�addSubTestSuccessr?r@)rrT)rrr;rAr
r
r�test_run_call_order__subtestsLs
z+Test_TestCase.test_run_call_order__subtestscCs.g}t|�}ddddddg}|j|||�dS)Nr>rrr rHr@)rrT)rrr;rAr
r
r�$test_run_call_order__subtests_legacyUs
z2Test_TestCase.test_run_call_order__subtests_legacycs4G�fdd�dtj���|�j|�|j||�dS)NcseZdZ��fdd�Z�ZS)z>Test_TestCase._check_call_order__subtests_success.<locals>.Foocs^t�|�j�xJdD]B}|j|d��,x$dD]}|j|d��WdQRXq,WWdQRXqWdS)Nr6r))rNr()rP)r6r))r)r()rrrR)rrNrP)rrr
rr`s

zCTest_TestCase._check_call_order__subtests_success.<locals>.Foo.test)rrrrr"r
)r)rrr_sr)rrr/r*)rr;rrSr
)rr�#_check_call_order__subtests_success^s	z1Test_TestCase._check_call_order__subtests_successcCs<g}t|�}ddddgddgddg}|j|||�dS)	Nr>rrr rQrV�
addSuccessr@)rrY)rrr;rAr
r
r�%test_run_call_order__subtests_successksz3Test_TestCase.test_run_call_order__subtests_successcCs.g}t|�}ddddddg}|j|||�dS)Nr>rrr rZr@)rrY)rrr;rAr
r
r�,test_run_call_order__subtests_success_legacyus
z:Test_TestCase.test_run_call_order__subtests_success_legacycsVg}t|�}d|_G�fdd�dtj��dddddd	g}�|�j|�|j||�dS)
NTcseZdZ��fdd�Z�ZS)zATest_TestCase.test_run_call_order__subtests_failfast.<locals>.Foocs`t�|�j�|jdd��|jd�WdQRX|jdd��|jd�WdQRX|jd�dS)Nr6)rNrOr))rrrRr4)r)rrr
rr�szFTest_TestCase.test_run_call_order__subtests_failfast.<locals>.Foo.test)rrrrr"r
)r)rrr�srr>rrr rUr@)r�failfastrrr/r*)rrr;rAr
)rr�&test_run_call_order__subtests_failfast}s	z4Test_TestCase.test_run_call_order__subtests_failfastcsVg�G�fdd�dtj�}tj�}d|_tj|�}|j|�dddg}|j�|�dS)Ncs0eZdZ�fdd�Z�fdd�Z�fdd�ZdS)z1Test_TestCase.test_subtests_failfast.<locals>.Fooc	s,|j���jd�WdQRX�jd�dS)N�a1�a2)rRr)r)rr
r�test_a�s
z8Test_TestCase.test_subtests_failfast.<locals>.Foo.test_acsJ|j���jd�WdQRX|j��|jd�WdQRX�jd�dS)N�b1rOZb2)rRrr4)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)rrrrarcrer
)rr
rr�srTr_r`rb)r#r$r:r]Z	makeSuiter/r*)rrr;ZsuiterAr
)rr�test_subtests_failfast�s


z$Test_TestCase.test_subtests_failfastcs:g�G�fdd�dtj�}|d�j�|j�ddg�dS)NcseZdZ�fdd�ZdS)z.Test_TestCase.test_subtests_debug.<locals>.Fooc	s,�jd�|j���jd�WdQRXdS)Nz	test casez	subtest 1)rrR)r)rr
rra�s

z5Test_TestCase.test_subtests_debug.<locals>.Foo.test_aN)rrrrar
)rr
rr�srraz	test casez	subtest 1)r#r$�debugr*)rrr
)rr�test_subtests_debug�sz!Test_TestCase.test_subtests_debugcCs(Gdd�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�srr)r#r$�assertIsr-�AssertionError)rrr
r
r�test_failureException__default�sz,Test_TestCase.test_failureException__defaultcCsXg}t|�}Gdd�dtj�}|j|d�jt�|d�j|�dddg}|j||�dS)Nc@seZdZdd�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�srrr>rHr@)rr#r$rir-r=r/r*)rrr;rrAr
r
r�2test_failureException__subclassing__explicit_raise�s
z@Test_TestCase.test_failureException__subclassing__explicit_raisecCsXg}t|�}Gdd�dtj�}|j|d�jt�|d�j|�dddg}|j||�dS)Nc@seZdZdd�ZeZdS)zMTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.FoocSs|jd�dS)Nr
)r4)rr
r
rr�szRTest_TestCase.test_failureException__subclassing__implicit_raise.<locals>.Foo.testN)rrrrr=r-r
r
r
rr�srrr>rHr@)rr#r$rir-r=r/r*)rrr;rrAr
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�sr)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
rrsz0Test_TestCase.test_tearDown.<locals>.Foo.runTestN)rrrrr
r
r
rr�sr)r#r$r )rrr
r
r�
test_tearDown�szTest_TestCase.test_tearDowncCs(Gdd�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
sr)r#r$�assertIsInstancer+�str)rrr
r
r�test_idszTest_TestCase.test_idcs\g�t���G��fdd�dtj�}|d�j�}|j|��ddddddg}|j�|�dS)	Ncs$eZdZ�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
rr8 szMTest_TestCase.test_run__uses_defaultTestResult.<locals>.Foo.defaultTestResultN)rrrrr8r
)rsrr
rrsrrrCr>rZr@rD)rr#r$r/rir*)rrr;rAr
)rsrr� test_run__uses_defaultTestResultsz.Test_TestCase.test_run__uses_defaultTestResultcCs8Gdd�dtj�}tj�}|d�j|�}|j||�dS)Nc@seZdZdd�ZdS)z9Test_TestCase.test_run__returns_given_result.<locals>.FoocSsdS)Nr
)rr
r
rr0sz>Test_TestCase.test_run__returns_given_result.<locals>.Foo.testN)rrrrr
r
r
rr/srr)r#r$r:r/ri)rrr;�retvalr
r
r�test_run__returns_given_result-sz,Test_TestCase.test_run__returns_given_resultcsDtj��tj��G��fdd�dtj�}|d���}|j|��dS)Ncs"eZdZdd�Z��fdd�ZdS)zKTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.FoocSsdS)Nr
)rr
r
rr@szPTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.testcs|j|���S)N)ri)rr;)�resultIn�	resultOutr
rr/CszOTest_TestCase.test_call__invoking_an_instance_delegates_to_run.<locals>.Foo.runN)rrrrr/r
)rwrxr
rr?srr)r#r:r$ri)rrrur
)rwrxr�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�$testShortDescriptionWithoutDocstringLsz2Test_TestCase.testShortDescriptionWithoutDocstringr)z)Docstrings are omitted with -O2 and abovecCs|j|j�d�dS)z7Tests shortDescription() for a method with a docstring.N)r*r{)rr
r
r�(testShortDescriptionWithOneLineDocstringOsz6Test_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*r{)rr
r
r�*testShortDescriptionWithMultiLineDocstringWs	z8Test_TestCase.testShortDescriptionWithMultiLineDocstringcsVGdd�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�SadSnakefsrcs t|�t|�ko�kSS)N)r9)�a�b�msg)rr
r�AllSnakesCreatedEqualjszDTest_TestCase.testAddTypeEqualityFunc.<locals>.AllSnakesCreatedEqual)N)�object�assertFalseZaddTypeEqualityFuncr*)r�s1�s2r�r
)rr�testAddTypeEqualityFuncesz%Test_TestCase.testAddTypeEqualityFunccCs,t�}|j||�|j|j|j|t��dS)N)r�rir,r-)r�thingr
r
r�testAssertIsrszTest_TestCase.testAssertIscCs,t�}|j|t��|j|j|j||�dS)N)r�ZassertIsNotr,r-)rr�r
r
r�testAssertIsNotwszTest_TestCase.testAssertIsNotcCs(g}|j|t�|j|j|j|t�dS)N)rp�listr,r-�dict)rr�r
r
r�testAssertIsInstance|sz"Test_TestCase.testAssertIsInstancecCs(g}|j|t�|j|j|j|t�dS)N)ZassertNotIsInstancer�r,r-r�)rr�r
r
r�testAssertNotIsInstance�sz%Test_TestCase.testAssertNotIsInstancecCs�dddd�}|jdd�|jdddd	g�|jd
|�|jdd�|jdddd	g�|jd
|�|j|j|jdd�|j|j|jdddd	g�|j|j|jd|�|j|j|jdd�|j|j|jdddd	g�|j|j|jd|�dS)NZbananaZgrassZfish)�monkey�cowZsealr��abcr)r6r(r��drZotter�x�Zelephantrdr�)�assertIn�assertNotInr,r-)rZanimalsr
r
r�testAssertIn�szTest_TestCase.testAssertInc5Cs�tj����tjdt�|jii�|jiddi�|jddiddi�|jddiddd��|jddd�ddd��|j|j��|jddii�WdQRX|j|j��|jddiddi�WdQRX|j|j��|jddiddi�WdQRX|j|j��|jddd�ddi�WdQRX|j|j��|jddd�ddi�WdQRXd	jd
d�td�D��}|j|j��|jd
|id
di�WdQRXWdQRXdS)N�ignorer�r6r))r�r��onerd)r�rd�css|]}t|�VqdS)N)�chr)�.0rNr
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.testAssertDictContainsSubsetcCs�fffiifggft�t�ft�t�fg}x�|D]�\}}y|j||�Wn(|jk
rp|jd||f�YnXy|j||dd�Wn(|jk
r�|jd||f�YnXy|j||d�Wq0|jk
r�|jd||f�Yq0Xq0Wfgfit�ftddg�tddg�ftdd	g�tdd
g�ftd
dg�td	dg�fg}xT|D]L\}}|j|j|j||�|j|j|j||d�|j|j|j||dd��qJWdS)NzassertEqual(%r, %r) failedr
)r�z$assertEqual(%r, %r) with msg= failedz/assertEqual(%r, %r) with third parameter failedr�r6r)�r()�set�	frozensetr*r-r4r,)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�r6r�zThese are unequal)�assertListEqual�assertTupleEqual�assertSequenceEqualr,r#r$r-�tuple�extend�assertDictEqual�update)rr�r�rdr�r
r
r�testEquality�sT








zTest_TestCase.testEqualityc.Cs�|j|jd�ddd}ddd
}djtjtj|�j�tj|�j���}tj	j
t|�df}t|�d|_y|j||�Wn.|j
k
r�}z|jd	}WYdd}~XnX|jd
�|jt|�t|��|j||�t|�d|_y|j||�Wn0|j
k
�r(}z|jd	}WYdd}~XnX|jd
�|jt|�t|��|j||�d|_y|j||�Wn0|j
k
�r�}z|jd	}WYdd}~XnX|jd
�|jt|�t|��|j||�dS)N�P�r�r�r)r��
r6rz!assertSequenceEqual did not fail.i�ii)r*�maxDiffr��difflibZndiff�pprintZpformat�
splitlinesr#�case�DIFF_OMITTED�lenr�r-�argsr4�
assertLessr��
assertGreaterr�)rZseq1Zseq2�diff�omitted�er�r
r
r�testAssertSequenceEqualMaxDiffs<


z,Test_TestCase.testAssertSequenceEqualMaxDiffcCsrd|_|jdd�}tjjtd�}|j|d|�d|_|jdd�}|j|d�d|_|jdd�}|j|d�dS)Nr6r
�bar�foobarr�)r��_truncateMessager#r�r�r�r*)r�messager�r
r
r�testTruncateMessage<sz!Test_TestCase.testTruncateMessagecCsptjd�}dd�}||_y|jiddi�Wn4|jk
r`}z|jt|�d�WYdd}~XnX|jd�dS)Nr*cSsdS)Nr
r
)r�r�r
r
r�truncateLsz<Test_TestCase.testAssertDictEqualTruncates.<locals>.truncater6rr
zassertDictEqual did not fail)r#r$r�r�r-r*rqr4)rrr�r�r
r
r�testAssertDictEqualTruncatesJs
"z*Test_TestCase.testAssertDictEqualTruncatescCsltjd�}dd�}||_y|jdd�Wn4|jk
r\}z|jt|�d�WYdd}~XnX|jd�dS)Nr*cSsdS)Nr
r
)r�r�r
r
rr�XszATest_TestCase.testAssertMultiLineEqualTruncates.<locals>.truncater
r�z!assertMultiLineEqual did not fail)r#r$r��assertMultiLineEqualr-r*rqr4)rrr�r�r
r
r�!testAssertMultiLineEqualTruncatesVs
"z/Test_TestCase.testAssertMultiLineEqualTruncatescs4�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�cst�d��S)N�_diffThreshold)�setattrr
)�
old_thresholdrr
r�<lambda>ksz=Test_TestCase.testAssertEqual_diffThreshold.<locals>.<lambda>r�r�r�r��^rQcSstd��dS)Nzthis should not be raised)�SystemError)r�r�r
r
r�explodingTruncationyszHTest_TestCase.testAssertEqual_diffThreshold.<locals>.explodingTruncationcst�d��S)Nr�)r�r
)�old_truncaterr
rr�}sz%r != %ri� r�Zxxxxxxxxxxxxxxxx�@)r*r�r��
addCleanupr,r-r�rq�	exceptionr�r�)r�s�cmr�r�r�r
)r�r�rr�testAssertEqual_diffThresholdbs*z+Test_TestCase.testAssertEqual_diffThresholdcsx�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)Nrcst�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*rqr�)rr�r�r�r�rd�pr�r
)r�rr�testAssertEqual_shorten�s.z%Test_TestCase.testAssertEqual_shortencCst�}|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)!Nr6r)r(r
r�Zbaz�2r�Tr�r1�r�rFr�y@y@r�ZaaabccdZabbbccer�r����)r(r6r�)r6r(r�)r6rr�)rr6r�)r(r6r�)r6r(r�)r6rr�)rr6r�)
r��assertCountEqualr,r-�iter�divmodr�r�r#�utilZ_count_diff_all_purposer*Z_count_diff_hashable)rr�r�ZdiffsrAr
r
r�testAssertCountEqual�sV $($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
rr6r)r(r�r�)rr6)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)r6g�������?g�?ZbugZantsbugsant)r�ZassertGreaterEqualr�ZassertLessEqualr,r-)rr
r
r�testInequality	sbzTest_TestCase.testInequalitycCsld}d}d}d|_y|j||�WnD|jk
rf}z&t|�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�r6)r�r�r-rq�splitr*)r�sample_text�revised_sample_text�sample_text_errorr��errorr
r
r�testAssertMultiLineEqualCsz&Test_TestCase.testAssertMultiLineEqualcCsfd}d}d}y|j||�WnD|jk
r`}z&t|�jdd�d}|j||�WYdd}~XnXdS)Nzladen swallows fly slowlyzunladen swallows fly quicklyzr- laden swallows fly slowly
?                    ^^^^
+ unladen swallows fly quickly
? ++                   ^^^^^
r�r6)r*r-rqr�)rr�r�r�r�r�r
r
r�testAssertEqualSingleLinebsz'Test_TestCase.testAssertEqualSingleLinecsHtjjr�fdd�}ndd�}|��*�j�j���jdd�WdQRXWdQRX|���jdd�WdQRXddg}ddg}|��*�j�j���j||�WdQRXWdQRX|��2�j�j���jt	|�t	|��WdQRXWdQRX|��.�j�j���j
|t	|��WdQRXWdQRX|��.�j�j���j
t	|�|�WdQRXWdQRX|��*�j�j���j
dd�WdQRXWdQRX|��2�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|��2�j�j���j
ddiddi�WdQRXWdQRX�j�j���j
iddi�WdQRX�j�j���j
ddii�WdQRX�j�j���jddgdddg�WdQRX|���jddgddg�WdQRX|��2�j�j���jddgddg�WdQRXWdQRX|��6�j�j���jddggddgg�WdQRXWdQRXdS)Ncs�jtd�S)Nz#Comparison between bytes and string)�assertWarnsRegex�BytesWarningr
)rr
r�
bytes_warningtsz=Test_TestCase.testEqualityBytesWarning.<locals>.bytes_warningcSstj�S)N)�
contextlib�	ExitStackr
r
r
rr�xsr��ar)�sys�flagsr�r,r-r*ZassertNotEqualr�r�r�r�r�r�r�r�)rr�r�r�r
)rr�testEqualityBytesWarningrs~  ($$ (( (z&Test_TestCase.testEqualityBytesWarningcCs<|jd�|j|j|jd�|jd�|j|j|jd�dS)NFzDjZoPloGears on Rails)rzr,r-ZassertIsNotNone)rr
r
r�testAssertIsNone�s

zTest_TestCase.testAssertIsNonecCs$|jdd�|j|j|jdd�dS)NZ
asdfabasdfzab+ZsaaasZaaaa)ZassertRegexr,r-)rr
r
r�testAssertRegex�szTest_TestCase.testAssertRegexcs�Gdd�dt���fdd�}|j�|�|jt�f|�|jttddd�|j|j��|j�dd	��WdQRX|jt��|j�d�WdQRX|j���|jt|�WdQRXdS)
Nc@seZdZdS)z=Test_TestCase.testAssertRaisesCallable.<locals>.ExceptionMockN)rrrr
r
r
r�
ExceptionMock�srcs�d��dS)Nz	We expectr
r
)rr
r�Stub�sz4Test_TestCase.testAssertRaisesCallable.<locals>.Stub�19r�)�basecSsdS)Nrr
r
r
r
rr��sz8Test_TestCase.testAssertRaisesCallable.<locals>.<lambda>)�	Exceptionr,r3�intr-�assertWarnsr�)rrr
)rr�testAssertRaisesCallable�sz&Test_TestCase.testAssertRaisesCallablecPslGdd�dt���fdd�}|j���|�WdQRX|jt�f��}|�WdQRX|j|j��|j|jjdd�|jt��tddd	�WdQRX|j|j��|j���WdQRXWdQRX|j	|jd
�� |j�d
d��WdQRXWdQRX|j
td
��6|jt�� |j�dd
��WdQRXWdQRXWdQRX|j���|jt|�WdQRXdS)Nc@seZdZdS)z<Test_TestCase.testAssertRaisesContext.<locals>.ExceptionMockN)rrrr
r
r
rr�srcs�d��dS)Nz	We expectr
r
)rr
rr�sz3Test_TestCase.testAssertRaisesContext.<locals>.Stubrz	We expectrr�)rr�)r��*)r�)
rr,r3rpr�r*r�rr-�assertRaisesRegexr�r�rj)rrr�r
)rr�testAssertRaisesContext�s,z%Test_TestCase.testAssertRaisesContextc&Cs�|jt��|j�WdQRX|jt��|jd�WdQRX|jt��|jt�WdQRX|jt��|jtdf�WdQRX|jt��|jttf�WdQRXdS)Nr6)r,�	TypeErrorr�r3)rr
r
r�testAssertRaisesNoExceptionType�sz-Test_TestCase.testAssertRaisesNoExceptionTypecCs4dd�}tj|�}|jt|�|j|tj|��dS)NcSs&yt�Wntk
r t�YnXdS)N)r3r
r
r
r�func
sz4Test_TestCase.testAssertRaisesRefcount.<locals>.func)r��getrefcountr,r3r*)rrZrefcountr
r
r�testAssertRaisesRefcount
s
z&Test_TestCase.testAssertRaisesRefcountcsfGdd�dt���fdd�}|j�tjd�|�|j�d|�|jt��|j�dd�WdQRXdS)Nc@seZdZdS)z:Test_TestCase.testAssertRaisesRegex.<locals>.ExceptionMockN)rrrr
r
r
rrsrcs�d��dS)Nz	We expectr
r
)rr
rrsz1Test_TestCase.testAssertRaisesRegex.<locals>.Stubzexpect$)rr�re�compilerr�)rrr
)rr�testAssertRaisesRegexsz#Test_TestCase.testAssertRaisesRegexc%Cs�|j|jd|jttjd�dd��|j|jd|jtddd��|j|jd��"|jtddd��WdQRXWdQRX|jtd��8|jt��"|jtdd	d
��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��expect)r�r
)r�)	rr-rrrr�r�r,rj)rr
r
r�testAssertNotRaisesRegex#s

z&Test_TestCase.testAssertNotRaisesRegexcCs*Gdd�dt�}|jt|j|dd��dS)Nc@seZdZdS)z>Test_TestCase.testAssertRaisesRegexInvalidRegex.<locals>.MyExcN)rrrr
r
r
r�MyExc8srcSsdS)NTr
r
r
r
rr�:szATest_TestCase.testAssertRaisesRegexInvalidRegex.<locals>.<lambda>)rr,r
r)rrr
r
r�!testAssertRaisesRegexInvalidRegex6sz/Test_TestCase.testAssertRaisesRegexInvalidRegexcCs*Gdd�dt�}|jt|j|dd��dS)Nc@seZdZdS)z>Test_TestCase.testAssertWarnsRegexInvalidRegex.<locals>.MyWarnN)rrrr
r
r
r�MyWarn>srcSsdS)NTr
r
r
r
rr�@sz@Test_TestCase.testAssertWarnsRegexInvalidRegex.<locals>.<lambda>)�Warningr,r
r�)rrr
r
r� testAssertWarnsRegexInvalidRegex<sz.Test_TestCase.testAssertWarnsRegexInvalidRegexcCsBdd�}|j|jd|jtd|�|j|jd|jttjd�|�dS)NcSstd��dS)NZ
Unexpected)rr
r
r
rrCsz9Test_TestCase.testAssertRaisesRegexMismatch.<locals>.Stubz*"\^Expected\$" does not match "Unexpected"z
^Expected$)rr-rrr)rrr
r
r�testAssertRaisesRegexMismatchBsz+Test_TestCase.testAssertRaisesRegexMismatchc
sjGdd�dt���fdd�}d}|j��}|�||�WdQRX|j}|j|��|j|jd|�dS)Nc@seZdZdS)z=Test_TestCase.testAssertRaisesExcValue.<locals>.ExceptionMockN)rrrr
r
r
rrRsrcs�|��dS)Nr
)r
)rr
rrUsz4Test_TestCase.testAssertRaisesExcValue.<locals>.Stubzparticular valuer)rr,r�rpr*r�)rr�vZctxr�r
)rr�testAssertRaisesExcValueQs
z&Test_TestCase.testAssertRaisesExcValuec-Cs�|jt��|j�WdQRX|jt��|jt�WdQRX|jt��|jdd�WdQRX|jt��|jtd�WdQRX|jt��|jtdfd�WdQRX|jt��|jttfd�WdQRXdS)Nr6r)r,r
rr3r�)rr
r
r�$testAssertRaisesRegexNoExceptionType`sz2Test_TestCase.testAssertRaisesRegexNoExceptionTypec-Csdd�}|jt|�|jt|�|jttf|�|jttjdtd�|j|j��|jtdd��WdQRX|jt��|jtd�WdQRXtj��6tjdt�|j|j��|jt|�WdQRXWdQRXtj��4tjdt�|jt��|jt|�WdQRXWdQRXdS)	NcSstjdt�dS)Nr
)r��warn�RuntimeWarningr
r
r
r�
_runtime_warnosz<Test_TestCase.testAssertWarnsCallable.<locals>._runtime_warnr
)�categorycSsdS)Nrr
r
r
r
rr�{sz7Test_TestCase.testAssertWarnsCallable.<locals>.<lambda>�defaultr�)	rr!r�r�r r,r-r�r�)rr"r
r
r�testAssertWarnsCallablens$
 
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
dtd�WdQRX|j|j��|jt��WdQRXWdQRX|j|jd�� |jtdd	��WdQRXWdQRX|jtd��6|jt�� |jtd
d��WdQRXWdQRXWdQRXtj��Ftjdt�|j|j��"|jt��|�WdQRXWdQRXWdQRXtj��Dtjd
t�|jt��"|jt��|�WdQRXWdQRXWdQRXdS)NcSstjdt�dS)Nr
)r�r r!r
r
r
rr"�sz;Test_TestCase.testAssertWarnsContext.<locals>._runtime_warnr6rr
ztest_case.py)r#r�)r�r
)r�r$r�)�inspect�getsourcelinesrr!r�rp�warningr*r�r��filename�linenor�r r,r-rr�rjr�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)Nr6)r,r
rr��UserWarningr)rr
r
r�testAssertWarnsNoExceptionType�sz,Test_TestCase.testAssertWarnsNoExceptionTypec6Cs&dd�}|jtd|d�|j|j��|jtddd��WdQRX|jt��|jtdd�WdQRXtj��:tjdt�|j|j��|jtd|d�WdQRXWdQRX|j|j��|jtd|d�WdQRXtj��>tjd	t�|jt|jf��|jtd|d�WdQRXWdQRXdS)
NcSstj|t�dS)N)r�r r!)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�r!r,r-rr�r�r�r�)rr"r
r
r�testAssertWarnsRegexCallable�s*

z*Test_TestCase.testAssertWarnsRegexCallablecrCsdd�}tj|�d}|jtd��}|d�WdQRX|j|jt�|j|jjdd�|jd|j	�|j|j
|d�|j|j��|jtd��WdQRXWdQRX|j
|jd��"|jtddd	��WdQRXWdQRX|jtd��8|jt��"|jtdd
d��WdQRXWdQRXWdQRXtj��Jtjdt�|j|j��&|jtd��|d�WdQRXWdQRXWdQRX|j|j��&|jtd��|d
�WdQRXWdQRXtj��Ntjdt�|jt|jf��&|jtd��|d
�WdQRXWdQRXWdQRXdS)NcSstj|t�dS)N)r�r r!)r�r
r
rr"�sz@Test_TestCase.testAssertWarnsRegexContext.<locals>._runtime_warnr6zo+r/rztest_case.pyr�)r�r
)r�r$r0r�)r&r'r�r!rpr(r*r�r�r)r*r,r-rr�rjr�r�r�)rr"r+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)Nr6r)r,r
r�r-r�r)rr
r
r�#testAssertWarnsRegexNoExceptionTypesz1Test_TestCase.testAssertWarnsRegexNoExceptionTypec
cs,t��}dVWdQRX|j|j�d�dS)Nr�)r	r*�getvalue)rZbufr
r
r�assertNoStderr(szTest_TestCase.assertNoStderrcCsf|jt|�t|��xLt||�D]>\}}|j|tj�x&|j�D]\}}|jt||�|�q@Wq WdS)N)r*r��ziprp�loggingZ	LogRecord�items�getattr)r�recordsZmatchesZrec�match�krr
r
r�assertLogRecords.s
zTest_TestCase.assertLogRecordscCsd|j��R|j��}tjd�tjd�WdQRX|j|jdg�|j|j	ddig�WdQRXdS)N�1r�z
INFO:foo:1�namer
)
r5�
assertLogs�log_foo�info�
log_foobarrgr*�outputr=r:)rr�r
r
r�testAssertLogsDefaults5s


z$Test_TestCase.testAssertLogsDefaultscCsv|j��d|j��$}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jddiddig�WdQRXdS)	Nr>r��3z
INFO:foo:1zWARNING:quux:3r?r
r)r5r@rArBrCrg�log_quuxr(r*rDr=r:)rr�r
r
r�!testAssertLogsTwoMatchingMessages>s



z/Test_TestCase.testAssertLogsTwoMatchingMessagescCsz|j��h|j|d��$}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jddidd	ig�WdQRXdS)
N)�levelr>r�rFzERROR:foo.bar:2zCRITICAL:quux:3r?zfoo.barr)r5r@rAr(rCr�rGZcriticalr*rDr=r:)rrIr�r
r
r�checkAssertLogsPerLevelIs


z%Test_TestCase.checkAssertLogsPerLevelcCs|jtj�|jd�dS)N�ERROR)rJr7rK)rr
r
r�testAssertLogsPerLevelTsz$Test_TestCase.testAssertLogsPerLevelcCs�|j���|jdd��j}|j|dd��$}tjd�tjd�tjd�WdQRX|j|j	ddg�|j
|jdd	idd
ig�WdQRX|j|j	dg�WdQRXdS)N�DEBUG)rIr>r�rFz
INFO:foo:1zDEBUG:foo.bar:2r?r
zfoo.barzWARNING:quux:3)r5r@rArBrCrgrGr(r*rDr=r:)rZloggerZouter_cmr�r
r
r�checkAssertLogsPerLoggerXs


z&Test_TestCase.checkAssertLogsPerLoggercCs|jtjd��|jd�dS)Nr
)rNr7�	getLogger)rr
r
r�testAssertLogsPerLoggerfsz%Test_TestCase.testAssertLogsPerLoggercCsD|j��2|j|j��|j��WdQRXWdQRXWdQRXdS)N)r5r,r-r@)rr
r
r�testAssertLogsFailureNoLogsjs

z)Test_TestCase.testAssertLogsFailureNoLogscCsR|j��@|j|j��(|jdd��tjd�WdQRXWdQRXWdQRXdS)NZWARNING)rIr>)r5r,r-r@rArB)rr
r
r�!testAssertLogsFailureLevelTooHighqs
z/Test_TestCase.testAssertLogsFailureLevelTooHighcCsV|jddd��>|j|j��&|jd��tjd�WdQRXWdQRXWdQRXdS)NrrK)rIr
r>)r@r,r-rGr�)rr
r
r�&testAssertLogsFailureMismatchingLoggerxsz4Test_TestCase.testAssertLogsFailureMismatchingLoggercCs�|jdf|jdf|jdf|jdf|jdf|jdf|jdf|jdf|jdf|j	df|j
tdd�ff|jdf|j
td
dd�td
ddd
�ff|jtddd�ff|jdff}x.|D]&\}}|jt��||�WdQRXq�WdS)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>Fr6r))r�r�)r�r�rdr
cSsidS)Nr
r
r
r
r
rr��sr�N)r(r�)r(r�)r(r()r(r()rTrT)rTrT)rUrV)rUrV)T)T)F)r�r�)�failIfEqualZassertNotEquals�failUnlessEqualZassertEquals�failUnlessAlmostEqualZassertAlmostEquals�failIfAlmostEqualZassertNotAlmostEquals�
failUnlessZassert_�failUnlessRaisesr
�failIfr�r�ZassertRaisesRegexp�KeyErrorZassertRegexpMatchesrr�)r�old�methr�r
r
r�testDeprecatedMethodNames�s$z'Test_TestCase.testDeprecatedMethodNamescCs\tjdd�dkrdSdddddd	d
dg}x,|D]$}|jt��t||�WdQRXq0WdS)
z9Test that the deprecated fail* methods get removed in 3.xNr)r(rXrYrZr[r\r]r^r�)r(r()r��version_infor,r.r9)rZdeprecated_namesZdeprecated_namer
r
r�_testDeprecatedFailMethods�s
z(Test_TestCase._testDeprecatedFailMethodscCs&Gdd�dtj�}|d�}t|�dS)Nc@seZdZdd�ZdS)z0Test_TestCase.testDeepcopy.<locals>.TestableTestcSsdS)Nr
)rr
r
r�testNothing�sz<Test_TestCase.testDeepcopy.<locals>.TestableTest.testNothingN)rrrrer
r
r
r�TestableTest�srfre)r#r$r)rrfrr
r
r�testDeepcopy�szTest_TestCase.testDeepcopycCsZtjd�}xJttjd�D]8}tj||d�}tj|�}|j||�|jt�t��qWdS)Nr/r6)�protocol)	r#r$r��pickleZHIGHEST_PROTOCOL�dumps�loadsr*r�)rrrhZ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�}x6||||fD]&}|jt��|d
�j�WdQRXq|WdS)NcSst�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
)rnr
r�Test1�srqcseZdZ�Z�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test2N)rrrrrpr
)rnror
r�Test2�srrcseZdZ�Z�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test3N)rrrrpr r
)rnror
r�Test3�srscseZdZ�fdd�ZdS)z2Test_TestCase.testKeyboardInterrupt.<locals>.Test4cs|j��dS)N)r�)r)rnr
rrp�szATest_TestCase.testKeyboardInterrupt.<locals>.Test4.test_somethingN)rrrrpr
)rnr
r�Test4�srtrp)N)r#r$r,rmr/)rrqrrrsrt�klassr
)rnror�testKeyboardInterrupt�s
z#Test_TestCase.testKeyboardInterruptcs�ddd��dd��G�fdd�dtj�}G��fdd�dtj�}G��fd	d
�d
tj�}G�fdd�dtj�}xJ||||fD]:}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
rro�sz5Test_TestCase.testSkippingEverywhere.<locals>.nothingcseZdZ�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test1N)rrrrpr
)rwr
rrq�srqcseZdZ�Z�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test2N)rrrrrpr
)rwror
rrr�srrcseZdZ�Z�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test3N)rrrrpr r
)rwror
rrs�srscseZdZ�fdd�ZdS)z3Test_TestCase.testSkippingEverywhere.<locals>.Test4cs|j��dS)N)r�)r)rwr
rrp�szBTest_TestCase.testSkippingEverywhere.<locals>.Test4.test_somethingN)rrrrpr
)rwr
rrt�srtrpr6)N)r#r$r:r/r*r�Zskipped�testsRun)rrqrrrsrtrur;r
)rwror�testSkippingEverywhere�s
z$Test_TestCase.testSkippingEverywherecs�ddd��dd��G�fdd�dtj�}G��fdd�dtj�}G��fd	d
�d
tj�}G�fdd�dtj�}xJ||||fD]:}tj�}|d
�j|�|jt|j�d�|j|jd�q|WdS)NcSst�dS)N)�
SystemExit)rr
r
rrn�sz,Test_TestCase.testSystemExit.<locals>._raisecSsdS)Nr
)rr
r
rro�sz-Test_TestCase.testSystemExit.<locals>.nothingcseZdZ�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test1N)rrrrpr
)rnr
rrq�srqcseZdZ�Z�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test2N)rrrrrpr
)rnror
rrrsrrcseZdZ�Z�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test3N)rrrrpr r
)rnror
rrssrscseZdZ�fdd�ZdS)z+Test_TestCase.testSystemExit.<locals>.Test4cs|j��dS)N)r�)r)rnr
rrp
sz:Test_TestCase.testSystemExit.<locals>.Test4.test_somethingN)rrrrpr
)rnr
rrt	srtrpr6)N)r#r$r:r/r*r��errorsrx)rrqrrrsrtrur;r
)rnror�testSystemExit�s
zTest_TestCase.testSystemExitc	Cs8tj�}tj|�}tj��~|j|��WdQRXdS)N)r#r$�weakref�refrZ
disable_gcr�)rr��wrr
r
r�testNoCycless


zTest_TestCase.testNoCyclescsZG�fdd�dt��G�fdd�dtj�}x*dD]"}||�}|j�|j�jd�q0WdS)	Ncs(eZdZdZ�fdd�Z�fdd�ZdS)z9Test_TestCase.test_no_exception_leak.<locals>.MyExceptionrcs�jd7_tj|�dS)Nr6)�	ninstancerr)r)r&r
rr!szBTest_TestCase.test_no_exception_leak.<locals>.MyException.__init__cs�jd8_dS)Nr6)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
rr)sz<Test_TestCase.test_no_exception_leak.<locals>.TestCase.test1cs
���dS)Nr
)r)r&r
rr,sz<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_leaks

z$Test_TestCase.test_no_exception_leakN)prrrrrZeq_pairsrZne_pairsr0r2r5r7r<rBrErFrGrIrJrKrLrMrTrWrXrYr[r\r^rfrhrkrlrmrnrorrrtrvryr|r#ZskipIfr�r��optimizer}r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rrrrrrrrrrr%r,r.r1r2r3r��contextmanagerr5r=rErHrJrLrNrPrQrRrSrbrdrgrlrvryr|rZcpython_onlyr�r�r
r
r
rr%8s�

		


	

%4($>(:L!
1!-	
r%�__main__)!r�r�r�rirr�r7r�r}r&�copyrrrr#Zunittest.test.supportrrrrrZtest.supportr	rOrArCrGr�rr$r%r�mainr
r
r
r�<module>sF