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_result.cpython-35.opt-2.pyc



���]�_�@s=ddlZddlZddlZddlmZddlZddlZGdd�de�Zdd�Z	Gdd�dej
�Zeej
j�Zx!d	d
ddfD]
Zee=q�Wdddd
d�Zeed<edefe�ZGdd�dej
�ZGdd�dej
�Zedkr9ej�dS)�N)�supportc@s#eZdZGdd�d�ZdS)�
MockTracebackc@s(eZdZdd�Zdd�ZdS)z MockTraceback.TracebackExceptioncOs|jdd�|_dS)N�capture_localsF)�getr)�self�args�kwargs�r	�0/opt/alt/python35/lib64/python3.5/test_result.py�__init__
sz)MockTraceback.TracebackException.__init__cCs#dg}|jr|jd�|S)NzA traceback�locals)r�append)r�resultr	r	r
�formats		
z'MockTraceback.TracebackException.formatN)�__name__�
__module__�__qualname__rrr	r	r	r
�TracebackExceptionsrN)rrrrr	r	r	r
rsrcCsttj_dS)N)�	traceback�unittestrr	r	r	r
�restore_tracebacksrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zejejjdkd �d!d"��Zejejjdkd �d#d$��Zejejjdkd �d%d&��Zejejjdkd �d'd(��Zd)d*�Zd+d,�Zd-d.�Zd/S)0�Test_TestResultcCs�tj�}|j|j��|jt|j�d�|jt|j�d�|j|jd�|j|j	d�|j
|j�|j
|j�dS)NrF)
r�
TestResult�
assertTrue�
wasSuccessful�assertEqual�len�errors�failures�testsRun�
shouldStopZassertIsNoneZ_stdout_bufferZ_stderr_buffer)rrr	r	r
�	test_init#szTest_TestResult.test_initcCs-tj�}|j�|j|jd�dS)NT)rr�stoprr )rrr	r	r
�	test_stop1s
zTest_TestResult.test_stopcCs�Gdd�dtj�}|d�}tj�}|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jd�|j|�dS)Nc@seZdZdd�ZdS)z+Test_TestResult.test_startTest.<locals>.FoocSsdS)Nr	)rr	r	r
�test_1<sz2Test_TestResult.test_startTest.<locals>.Foo.test_1N)rrrr$r	r	r	r
�Foo;sr%r$r�F)
r�TestCaser�	startTestrrrrrrrr �stopTest)rr%�testrr	r	r
�test_startTest:s
zTest_TestResult.test_startTestcCs%Gdd�dtj�}|d�}tj�}|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jd�|j|�|j|j��|jt|j�d�|jt|j	�d�|j|j
d�|j|jd�dS)Nc@seZdZdd�ZdS)z*Test_TestResult.test_stopTest.<locals>.FoocSsdS)Nr	)rr	r	r
r$Qsz1Test_TestResult.test_stopTest.<locals>.Foo.test_1N)rrrr$r	r	r	r
r%Psr%r$rr&F)
rr'rr(rrrrrrrr r))rr%r*rr	r	r
�
test_stopTestOs

zTest_TestResult.test_stopTestcCs$tj�}|j�|j�dS)N)rr�startTestRun�stopTestRun)rrr	r	r
�test_startTestRun_stopTestRunjs
z-Test_TestResult.test_startTestRun_stopTestRuncCs�Gdd�dtj�}|d�}tj�}|j|�|j|�|j|�|j|j��|jt	|j
�d�|jt	|j�d�|j|jd�|j|j
d�dS)Nc@seZdZdd�ZdS)z,Test_TestResult.test_addSuccess.<locals>.FoocSsdS)Nr	)rr	r	r
r$�sz3Test_TestResult.test_addSuccess.<locals>.Foo.test_1N)rrrr$r	r	r	r
r%�sr%r$rr&F)rr'rr(�
addSuccessr)rrrrrrrr )rr%r*rr	r	r
�test_addSuccess�s


zTest_TestResult.test_addSuccessc	Cs%Gdd�dtj�}|d�}y|jd�Wntj�}YnXtj�}|j|�|j||�|j|�|j	|j
��|jt|j
�d�|jt|j�d�|j|jd�|j|jd�|jd\}}|j||�|j|t�dS)Nc@seZdZdd�ZdS)z,Test_TestResult.test_addFailure.<locals>.FoocSsdS)Nr	)rr	r	r
r$�sz3Test_TestResult.test_addFailure.<locals>.Foo.test_1N)rrrr$r	r	r	r
r%�sr%r$�foorr&F)rr'�fail�sys�exc_inforr(�
addFailurer)�assertFalserrrrrrr �assertIs�assertIsInstance�str)rr%r*�exc_info_tupler�	test_case�
formatted_excr	r	r
�test_addFailure�s$

zTest_TestResult.test_addFailurec	Cs!Gdd�dtj�}|d�}y
t��Wntj�}YnXtj�}|j|�|j||�|j|�|j	|j
��|jt|j
�d�|jt|j�d�|j|jd�|j|jd�|j
d\}}|j||�|j|t�dS)Nc@seZdZdd�ZdS)z*Test_TestResult.test_addError.<locals>.FoocSsdS)Nr	)rr	r	r
r$�sz1Test_TestResult.test_addError.<locals>.Foo.test_1N)rrrr$r	r	r	r
r%�sr%r$r&rF)rr'�	TypeErrorr4r5rr(�addErrorr)r7rrrrrrr r8r9r:)rr%r*r;rr<r=r	r	r
�
test_addError�s$


zTest_TestResult.test_addErrorcCs�Gdd�dtj�}|d�}tj�}d|_ttj_|jt�|j	�|j
|�|j�|jt
|j�d�|jd\}}|jd|�dS)Nc@seZdZdd�ZdS)z1Test_TestResult.test_addError_locals.<locals>.FoocSsdddS)Nr&rr	)rr	r	r
r$�sz8Test_TestResult.test_addError_locals.<locals>.Foo.test_1N)rrrr$r	r	r	r
r%�sr%r$Tr&rzA tracebacklocals)rr'r�	tb_localsrrr�
addCleanuprr-�runr.rrr)rr%r*rr<r=r	r	r
�test_addError_locals�s	



z$Test_TestResult.test_addError_localscs%G���fdd�dtj�}d�|d��tj���j��|j�j��|jt�j�d�|jt�j	�d�|j�j
d�|j�jd��jd\}}|j|��|j
d|��j	d\}}|j|��|j
d|�dS)	Ncs(eZdZ���fdd�ZdS)z,Test_TestResult.test_addSubTest.<locals>.Foocst|jdd��[|j�yddWntk
rHtj�}YnX�j��|�|jd�WdQRXdS)Nr2r&rzsome recognizable failure)�subTest�_subtest�ZeroDivisionErrorr4r5Z
addSubTestr3)rr;)r�subtestr*r	r
r$	s	
z3Test_TestResult.test_addSubTest.<locals>.Foo.test_1N)rrrr$r	)rrIr*r	r
r%sr%r$r&FrrHzsome recognizable failure)rr'rrDr7rrrrrrr r8ZassertIn)rr%r<r=r	)rrIr*r
�test_addSubTests %
zTest_TestResult.test_addSubTestcCs:tjddd�}|j|j|�dtd�dS)NTr&z$testGetDescriptionWithoutDocstring (z.Test_TestResult))r�TextTestResultr�getDescriptionr)rrr	r	r
�"testGetDescriptionWithoutDocstring)s
z2Test_TestResult.testGetDescriptionWithoutDocstringcCs�|jdddd��>tjddd�}|j|j|j�dtd�WdQRX|jd��>tjddd�}|j|j|j�dtd	�WdQRXdS)
Nr2r&�bar�Tz+testGetSubTestDescriptionWithoutDocstring (z .Test_TestResult) (bar=2, foo=1)zsome messagez .Test_TestResult) [some message])rFrrKrrLrGr)rrr	r	r
�)testGetSubTestDescriptionWithoutDocstring0sz9Test_TestResult.testGetSubTestDescriptionWithoutDocstringcCsQ|j��>tjddd�}|j|j|j�dtd�WdQRXdS)NTr&z4testGetSubTestDescriptionWithoutDocstringAndParams (z.Test_TestResult) (<subtest>))rFrrKrrLrGr)rrr	r	r
�2testGetSubTestDescriptionWithoutDocstringAndParams>s

zBTest_TestResult.testGetSubTestDescriptionWithoutDocstringAndParamsc
Csvd}tjddd�}xTddggD]C}|j|��+|j|j|j�|t|f�WdQRXq+WdS)NzAtestGetSubTestDescriptionForFalsyValues (%s.Test_TestResult) [%s]Tr&r)rrKrFrrLrGr)rZexpectedr�argr	r	r
�'testGetSubTestDescriptionForFalsyValuesFsz7Test_TestResult.testGetSubTestDescriptionForFalsyValuescCsq|jdd��X|jdd��>tjddd�}|j|j|j�dtd�WdQRXWdQRXdS)Nr2r&rNrOTz1testGetNestedSubTestDescriptionWithoutDocstring (z .Test_TestResult) (bar=2, foo=1))rFrrKrrLrGr)rrr	r	r
�/testGetNestedSubTestDescriptionWithoutDocstringPsz?Test_TestResult.testGetNestedSubTestDescriptionWithoutDocstringrOz)Docstrings are omitted with -O2 and abovecCs:tjddd�}|j|j|�dtd�dS)NTr&z(testGetDescriptionWithOneLineDocstring (zG.Test_TestResult)
Tests getDescription() for a method with a docstring.)rrKrrLr)rrr	r	r
�&testGetDescriptionWithOneLineDocstringYsz6Test_TestResult.testGetDescriptionWithOneLineDocstringcCs]tjddd�}|jdddd��)|j|j|j�dtd�WdQRXdS)NTr&r2rNrOz/testGetSubTestDescriptionWithOneLineDocstring (zV.Test_TestResult) (bar=2, foo=1)
Tests getDescription() for a method with a docstring.)rrKrFrrLrGr)rrr	r	r
�-testGetSubTestDescriptionWithOneLineDocstringds
z=Test_TestResult.testGetSubTestDescriptionWithOneLineDocstringcCs:tjddd�}|j|j|�dtd�dS)NTr&z*testGetDescriptionWithMultiLineDocstring (zN.Test_TestResult)
Tests getDescription() for a method with a longer docstring.)rrKrrLr)rrr	r	r
�(testGetDescriptionWithMultiLineDocstringpsz8Test_TestResult.testGetDescriptionWithMultiLineDocstringcCs]tjddd�}|jdddd��)|j|j|j�dtd�WdQRXdS)NTr&r2rNrOz1testGetSubTestDescriptionWithMultiLineDocstring (z].Test_TestResult) (bar=2, foo=1)
Tests getDescription() for a method with a longer docstring.)rrKrFrrLrGr)rrr	r	r
�/testGetSubTestDescriptionWithMultiLineDocstring~s
z?Test_TestResult.testGetSubTestDescriptionWithMultiLineDocstringcCsbGdd�dt�}tj�}|j|j|��d|jjd<|j|j|��dS)Nc@s&eZdZGdd�de�ZdS)z5Test_TestResult.testStackFrameTrimming.<locals>.Framec@seZdZiZdS)z>Test_TestResult.testStackFrameTrimming.<locals>.Frame.tb_frameN)rrr�	f_globalsr	r	r	r
�tb_frame�srZN)rrr�objectrZr	r	r	r
�Frame�sr\TZ
__unittest)r[rrr7Z_is_relevant_tb_levelrZrYr)rr\rr	r	r
�testStackFrameTrimming�s
z&Test_TestResult.testStackFrameTrimmingcCs�tj�}dd�|_d|_|jdd�|j|j�tj�}dd�|_d|_|jdd�|j|j�tj�}dd�|_d|_|jd�|j|j�dS)NcWsdS)N�r	)�_r	r	r
�<lambda>�sz.Test_TestResult.testFailFast.<locals>.<lambda>TcWsdS)Nr^r	)r_r	r	r
r`�scWsdS)Nr^r	)r_r	r	r
r`�s)	rrZ_exc_info_to_string�failfastr@rr r6�addUnexpectedSuccess)rrr	r	r
�testFailFast�s			
zTest_TestResult.testFailFastcsCtjdtj�dd�}�fdd�}|j|�}dS)N�streamraTcs�j|j�dS)N)rra)r)rr	r
r*�sz5Test_TestResult.testFailFastSetByRunner.<locals>.test)r�TextTestRunner�io�StringIOrD)r�runnerr*rr	)rr
�testFailFastSetByRunner�sz'Test_TestResult.testFailFastSetByRunnerN)rrrr!r#r+r,r/r1r>rArErJrMrPrQrSrTrZskipIfr4�flags�optimizerUrVrWrXr]rcrir	r	r	r
rs4
	'0"
	


rZaddSkipZaddExpectedFailurerbrcCs:g|_g|_d|_d|_d|_d|_dS)NrF)rrrr �bufferrB)rrdZdescriptions�	verbosityr	r	r
r�s					�	OldResultc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�Test_OldTestResultc
CsPtjdtf��4t�}|j|�|jt|j�|�WdQRXdS)NzTestResult has no add.+ method,)rZcheck_warnings�RuntimeWarningrnrDrrr)rr*rrr	r	r
�assertOldResultWarning�s
	
	
z)Test_OldTestResult.assertOldResultWarningcCsWGdd�dtj�}x7dD]/\}}||�}|j|t|��q WdS)Nc@sFeZdZdd�Zejdd��Zejdd��ZdS)z2Test_OldTestResult.testOldTestResult.<locals>.TestcSs|jd�dS)NZfoobar)�skipTest)rr	r	r
�testSkip�sz;Test_OldTestResult.testOldTestResult.<locals>.Test.testSkipcSs
t�dS)N)r?)rr	r	r
�testExpectedFail�szCTest_OldTestResult.testOldTestResult.<locals>.Test.testExpectedFailcSsdS)Nr	)rr	r	r
�testUnexpectedSuccess�szHTest_OldTestResult.testOldTestResult.<locals>.Test.testUnexpectedSuccessN)rrrrsrZexpectedFailurertrur	r	r	r
�Test�srvrsTrtruF�rsT�rtT�ruF)rwrxry)rr'rq�int)rrvZ	test_nameZshould_passr*r	r	r
�testOldTestResult�s
z$Test_OldTestResult.testOldTestResultcCs3Gdd�dtj�}|j|d�d�dS)Nc@s(eZdZdd�Zdd�ZdS)z7Test_OldTestResult.testOldTestTesultSetup.<locals>.TestcSs|jd�dS)Nz	no reason)rr)rr	r	r
�setUp�sz=Test_OldTestResult.testOldTestTesultSetup.<locals>.Test.setUpcSsdS)Nr	)rr	r	r
�testFoo�sz?Test_OldTestResult.testOldTestTesultSetup.<locals>.Test.testFooN)rrrr|r}r	r	r	r
rv�srvr}r)rr'rq)rrvr	r	r
�testOldTestTesultSetup�sz)Test_OldTestResult.testOldTestTesultSetupcCsBtjd�Gdd�dtj��}|j|d�d�dS)Nz	no reasonc@seZdZdd�ZdS)z7Test_OldTestResult.testOldTestResultClass.<locals>.TestcSsdS)Nr	)rr	r	r
r}�sz?Test_OldTestResult.testOldTestResultClass.<locals>.Test.testFooN)rrrr}r	r	r	r
rv�srvr}r)r�skipr'rq)rrvr	r	r
�testOldTestResultClass�sz)Test_OldTestResult.testOldTestResultClasscCsNGdd�dtj�}tjdtdtj��}|j|d��dS)Nc@seZdZdd�ZdS)z8Test_OldTestResult.testOldResultWithRunner.<locals>.TestcSsdS)Nr	)rr	r	r
r}�sz@Test_OldTestResult.testOldResultWithRunner.<locals>.Test.testFooN)rrrr}r	r	r	r
rv�srvZresultclassrdr})rr'rernrfrgrD)rrvrhr	r	r
�testOldResultWithRunner�sz*Test_OldTestResult.testOldResultWithRunnerN)rrrrqr{r~r�r�r	r	r	r
ro�s
roc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�TestOutputBufferingcCstj|_tj|_dS)N)r4�stdout�	_real_out�stderr�	_real_err)rr	r	r
r|�szTestOutputBuffering.setUpcCs|jt_|jt_dS)N)r�r4r�r�r�)rr	r	r
�tearDown�szTestOutputBuffering.tearDowncCs�|j}|j}tj�}|j|j�|j|tj�|j|tj	�|j
|�|j|tj�|j|tj	�dS)N)r�r�rrr7rlr8r4r�r�r()r�real_out�real_errrr	r	r
�testBufferOutputOff�s		
z'TestOutputBuffering.testBufferOutputOffcCs%|j}|j}tj�}|j|j�d|_|j|tj�|j|tj	�|j
|�|j|tj�|j|tj	�|jtjt
j�|jtj	t
j�|jtjtj	�tj}tj	}t
j�|_t
j�|_td�tddtj	�|j|j�d�|j|j�d�|j|jj�d�|j|jj�d�|j|�|j|�|jtj|j�|jtj	|j�|j|jj�d�|j|jj�d�|j|j�d�|j|j�d�dS)NTr2rN�filezfoo
zbar
r^)r�r�rrr7rlr8r4r�r�r(ZassertIsNotr9rfrg�_original_stdout�_original_stderr�printr�getvaluer0r))rr�r�rZ
out_streamZ
err_streamr	r	r
�#testBufferOutputStartTestAddSuccesss>			
		


z7TestOutputBuffering.testBufferOutputStartTestAddSuccesscCs&tj�}d|_|j|�|S)NT)rrrlr()rrr	r	r
�getStartedResult>s	
z$TestOutputBuffering.getStartedResultcCs�ttj_|jt�xuddddgD]a\}}}|j�}tj}tj	}t
j�|_t
j�|_
tddtj�|r�td	dtj	�t||�}||d�|j|�t||�}|jt|�d
�|d\}	}
tjd�}d
}|r+tjd�}d||f}
|j|	|�|j|jj�|�|j|j
j�|�|j|
|
�q,WdS)Nrr@Trr6Fr2r�rNr&rz9
                Stdout:
                foo
            r^z9
                Stderr:
                bar
            zA traceback%s%s)rr@T)rr6F)rr@T)rr6F)NNN)rrrrrCrr�r4r�r�rfrgr�r�r��getattrr)rr�textwrap�dedentr8r�ZassertMultiLineEqual)rZmessage_attrZadd_attrZ
include_errorrZbuffered_outZbuffered_errZaddFunctionZresult_listr*�messageZexpectedOutMessageZexpectedErrMessageZexpectedFullMessager	r	r
�!testBufferOutputAddErrorOrFailureDs@
		

		z5TestOutputBuffering.testBufferOutputAddErrorOrFailurecCsmtj�}d|_Gdd�dtj�}tj|d�g�}||�|jt|j�d�dS)NTc@s.eZdZedd��Zdd�ZdS)z5TestOutputBuffering.testBufferSetupClass.<locals>.FoocSsdddS)Nr&rr	)�clsr	r	r
�
setUpClassxsz@TestOutputBuffering.testBufferSetupClass.<locals>.Foo.setUpClasscSsdS)Nr	)rr	r	r
�test_foo{sz>TestOutputBuffering.testBufferSetupClass.<locals>.Foo.test_fooN)rrr�classmethodr�r�r	r	r	r
r%wsr%r�r&)rrrlr'�	TestSuiterrr)rrr%�suiter	r	r
�testBufferSetupClassss	
z(TestOutputBuffering.testBufferSetupClasscCsmtj�}d|_Gdd�dtj�}tj|d�g�}||�|jt|j�d�dS)NTc@s.eZdZedd��Zdd�ZdS)z8TestOutputBuffering.testBufferTearDownClass.<locals>.FoocSsdddS)Nr&rr	)r�r	r	r
�
tearDownClass�szFTestOutputBuffering.testBufferTearDownClass.<locals>.Foo.tearDownClasscSsdS)Nr	)rr	r	r
r��szATestOutputBuffering.testBufferTearDownClass.<locals>.Foo.test_fooN)rrrr�r�r�r	r	r	r
r%�sr%r�r&)rrrlr'r�rrr)rrr%r�r	r	r
�testBufferTearDownClass�s	
z+TestOutputBuffering.testBufferTearDownClasscCs�tj�}d|_Gdd�dtj�}Gdd�dt�}d|_|tjd<|jtjj	d�tj
|d�g�}||�|jt|j
�d�dS)NTc@seZdZdd�ZdS)z6TestOutputBuffering.testBufferSetUpModule.<locals>.FoocSsdS)Nr	)rr	r	r
r��sz?TestOutputBuffering.testBufferSetUpModule.<locals>.Foo.test_fooN)rrrr�r	r	r	r
r%�sr%c@s"eZdZedd��ZdS)z9TestOutputBuffering.testBufferSetUpModule.<locals>.ModulecSsdddS)Nr&rr	r	r	r	r
�setUpModule�szETestOutputBuffering.testBufferSetUpModule.<locals>.Module.setUpModuleN)rrr�staticmethodr�r	r	r	r
�Module�sr�r�r&)rrrlr'r[rr4�modulesrC�popr�rrr)rrr%r�r�r	r	r
�testBufferSetUpModule�s		

z)TestOutputBuffering.testBufferSetUpModulecCs�tj�}d|_Gdd�dtj�}Gdd�dt�}d|_|tjd<|jtjj	d�tj
|d�g�}||�|jt|j
�d�dS)NTc@seZdZdd�ZdS)z9TestOutputBuffering.testBufferTearDownModule.<locals>.FoocSsdS)Nr	)rr	r	r
r��szBTestOutputBuffering.testBufferTearDownModule.<locals>.Foo.test_fooN)rrrr�r	r	r	r
r%�sr%c@s"eZdZedd��ZdS)z<TestOutputBuffering.testBufferTearDownModule.<locals>.ModulecSsdddS)Nr&rr	r	r	r	r
�tearDownModule�szKTestOutputBuffering.testBufferTearDownModule.<locals>.Module.tearDownModuleN)rrrr�r�r	r	r	r
r��sr�r�r&)rrrlr'r[rr4r�rCr�r�rrr)rrr%r�r�r	r	r
�testBufferTearDownModule�s		

z,TestOutputBuffering.testBufferTearDownModuleN)
rrrr|r�r�r�r�r�r�r�r�r�r	r	r	r
r��s0/r��__main__)rfr4r�r*rrrr[rrr'r�dictr�__dict__Z	classDict�mr�typernror�r�mainr	r	r	r
�<module>s(
��

4�