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_runner.cpython-35.pyc



��Yf�.�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
Gdd�dej�ZGdd�dej�Z
edkr�ej�dS)	�N)�_Outcome)�
LoggingResult�#ResultWithNoStartTestRunStopTestRunc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestCleanUpc
sGdd�dtj�}|d�}|j|jg�g��fdd�}�fdd�}|j|dd	d
ddd
d�|j|�|j|j|dtddd
d�f|fifg�|j|j��|j�d	fifddtddd
d�fg�dS)Nc@seZdZdd�ZdS)z-TestCleanUp.testCleanUp.<locals>.TestableTestcSsdS)N�)�selfrr�>/opt/alt/python35/lib64/python3.5/unittest/test/test_runner.py�testNothingsz9TestCleanUp.testCleanUp.<locals>.TestableTest.testNothingN)�__name__�
__module__�__qualname__r	rrrr�TestableTestsr
r	cs�jd||f�dS)N�)�append)�args�kwargs)�cleanupsrr�cleanup1sz)TestCleanUp.testCleanUp.<locals>.cleanup1cs�jd||f�dS)N�)r)rr)rrr�cleanup2sz)TestCleanUp.testCleanUp.<locals>.cleanup2rr�ZfourZhelloZfiveZgoodbye)rrr)rrr)�unittest�TestCase�assertEqualZ	_cleanups�
addCleanup�dict�
assertTrue�
doCleanups)rr
�testrrr)rr�testCleanUps"
zTestCleanUp.testCleanUpcsGdd�dtj�}|d�}t�}|_td��td���fdd�}�fdd	�}|j|�|j|�|j|j��|j|j�t	|j
�\\}\}}}\}\}	}
}|j||ft�f�|j|	|
ft�f�dS)
Nc@seZdZdd�ZdS)z7TestCleanUp.testCleanUpWithErrors.<locals>.TestableTestcSsdS)Nr)rrrrr	,szCTestCleanUp.testCleanUpWithErrors.<locals>.TestableTest.testNothingN)r
rrr	rrrrr
+sr
r	�fooZbarcs
��dS)Nrr)�exc1rrr4sz3TestCleanUp.testCleanUpWithErrors.<locals>.cleanup1cs
��dS)Nrr)�exc2rrr7sz3TestCleanUp.testCleanUpWithErrors.<locals>.cleanup2)rrrZ_outcome�	Exceptionr�assertFalser�success�reversed�errorsr)rr
rZoutcomerr�_ZType1Z	instance1ZType2Z	instance2r)r!r"r�testCleanUpWithErrors*s

3z!TestCleanUp.testCleanUpWithErrorscs d�g�G��fdd�dtj�}|d���fdd�}�fdd�}�j|��j|����fd	d
�}tj�}||_�j|��j�ddd
dddg�d�g�|d���j|��j|��j�ddg�dS)NFcsIeZdZ��fdd�Z�fdd�Z�fdd�ZdS)z2TestCleanUp.testCleanupInRun.<locals>.TestableTestcs#�jd��rtd��dS)N�setUpr )rr#)r)�blowUp�orderingrrr*Js
z8TestCleanUp.testCleanupInRun.<locals>.TestableTest.setUpcs�jd�dS)Nr)r)r)r,rrr	Osz>TestCleanUp.testCleanupInRun.<locals>.TestableTest.testNothingcs�jd�dS)N�tearDown)r)r)r,rrr-Rsz;TestCleanUp.testCleanupInRun.<locals>.TestableTest.tearDownN)r
rrr*r	r-r)r+r,rrr
Isr
r	cs�jd�dS)Nr)rr)r,rrrWsz.TestCleanUp.testCleanupInRun.<locals>.cleanup1cs�jd�dS)Nr)rr)r,rrrYsz.TestCleanUp.testCleanupInRun.<locals>.cleanup2cs!�j|���jd�dS)Nr%)rr)Z	some_test)r,rrrrr%^sz-TestCleanUp.testCleanupInRun.<locals>.successr*rr-rrr%T)rrr�
TestResultZ
addSuccess�runr)rr
rrr%�resultr)r+r,rrr�testCleanupInRunEs("

	


zTestCleanUp.testCleanupInRuncs�g�G��fdd�dtj�}|d�����fdd���fdd���j�|j�dd	d
ddg�dS)
NcsIeZdZ��fdd�Z�fdd�Z�fdd�ZdS)zCTestCleanUp.testTestCaseDebugExecutesCleanups.<locals>.TestableTestcs�jd�|j��dS)Nr*)rr)r)rr,rrr*ts
zITestCleanUp.testTestCaseDebugExecutesCleanups.<locals>.TestableTest.setUpcs�jd�dS)Nr)r)r)r,rrr	xszOTestCleanUp.testTestCaseDebugExecutesCleanups.<locals>.TestableTest.testNothingcs�jd�dS)Nr-)r)r)r,rrr-{szLTestCleanUp.testTestCaseDebugExecutesCleanups.<locals>.TestableTest.tearDownN)r
rrr*r	r-r)rr,rrr
ssr
r	cs�jd��j��dS)Nr)rrr)rr,rrrr�s
z?TestCleanUp.testTestCaseDebugExecutesCleanups.<locals>.cleanup1cs�jd�dS)Nr)rr)r,rrr�sz?TestCleanUp.testTestCaseDebugExecutesCleanups.<locals>.cleanup2r*rr-rr)rr�debugr)rr
r)rrr,rr�!testTestCaseDebugExecutesCleanupsps"
z-TestCleanUp.testTestCaseDebugExecutesCleanupsN)r
rrrr)r1r3rrrrrs+rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�Test_TextTestRunnerzTests for TextTestRunner.cCs,tjjd�|_|jr(tjd=dS)N�PYTHONWARNINGS)�os�environ�get�pythonwarnings)rrrrr*�s	zTest_TextTestRunner.setUpcCs|jr|jtjd<dS)Nr5)r9r6r7)rrrrr-�s	zTest_TextTestRunner.tearDowncCs�tj�}|j|j�|j|j�|j|jd�|j|jd�|j|j	�|j|j
tj�|j|j�dS)Nr)
r�TextTestRunnerr$�failfast�bufferr�	verbosity�warningsr�descriptions�resultclass�TextTestResult�	tb_locals)r�runnerrrr�	test_init�szTest_TextTestRunner.test_initcsOG�fdd�dtj��Gdd�dtj��}|ddd�dS)Ncs%eZdZ��fdd�Z�S)z>Test_TextTestRunner.test_multiple_inheritance.<locals>.AResultcs t�|�j|||�dS)N)�super�__init__)r�streamr?r=)�AResult�	__class__rrrF�szGTest_TextTestRunner.test_multiple_inheritance.<locals>.AResult.__init__)r
rrrFr)rH)rIrrH�srHc@seZdZdS)zBTest_TextTestRunner.test_multiple_inheritance.<locals>.ATextResultN)r
rrrrrr�ATextResult�srJr)rr.rA)rrJr)rHr�test_multiple_inheritance�sz-Test_TextTestRunner.test_multiple_inheritancecs�Gdd�dtj�}tj��tjdtj�dddd�}�fdd�|_|j|d	��|j�j	�|j�j
�dS)
Nc@seZdZdd�ZdS)z7Test_TextTestRunner.testBufferAndFailfast.<locals>.TestcSsdS)Nr)rrrr�testFoo�sz?Test_TextTestRunner.testBufferAndFailfast.<locals>.Test.testFooN)r
rrrLrrrr�Test�srMrGr;Tr<cs�S)Nrr)r0rr�<lambda>�sz;Test_TextTestRunner.testBufferAndFailfast.<locals>.<lambda>rL)rrr.r:�io�StringIO�_makeResultr/rr;r<)rrMrCr)r0r�testBufferAndFailfast�s	z)Test_TextTestRunner.testBufferAndFailfastcCsJtjdtj�dd�}|jtj��}|jd|j�dS)NrGrBT)rr:rOrPr/�	TestSuiterrB)rrCr0rrr�test_locals�szTest_TextTestRunner.test_localscs�Gdd�dtj�}tjj��fdd�}�j|�tj��tjdtj��}�fdd�|_	d�_
��fd	d
�}|tj_|jtj���j
�j
d�dS)Nc@seZdZdd�ZdS)z;Test_TextTestRunner.testRunnerRegistersResult.<locals>.TestcSsdS)Nr)rrrrrL�szCTest_TextTestRunner.testRunnerRegistersResult.<locals>.Test.testFooN)r
rrrLrrrrrM�srMcs�tj_dS)N)rrC�registerResultr)�originalRegisterResultrr�cleanup�sz>Test_TextTestRunner.testRunnerRegistersResult.<locals>.cleanuprGcs�S)Nrr)r0rrrN�sz?Test_TextTestRunner.testRunnerRegistersResult.<locals>.<lambda>rcs#�jd7_�j|��dS)Nr)�
wasRegisteredr)Z
thisResult)r0rrr�fakeRegisterResult�szITest_TextTestRunner.testRunnerRegistersResult.<locals>.fakeRegisterResultr)rrrCrUrr.r:rOrPrQrXr/rSr)rrMrWrCrYr)rVr0rr�testRunnerRegistersResult�s
	z-Test_TextTestRunner.testRunnerRegistersResultcsXGdd�dt��G��fdd�dtj����}|jtj��dS)Nc@s"eZdZdZdd�ZdS)zbTest_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRun.<locals>.OldTextResult�cSsdS)Nr)rrrr�printErrors�sznTest_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRun.<locals>.OldTextResult.printErrorsN)r
rr�
separator2r\rrrr�
OldTextResult�sr^cs7eZdZ��fdd�Z�fdd�Z�S)z[Test_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRun.<locals>.Runnercs t�|�jtj��dS)N)rErFrOrP)r)�RunnerrIrrrF�szdTest_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRun.<locals>.Runner.__init__cs��S)Nr)r)r^rrrQ�szgTest_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRun.<locals>.Runner._makeResult)r
rrrFrQr)r^r_)rIrr_�sr_)rrr:r/rS)rrCr)r^r_r�7test_works_with_result_without_startTestRun_stopTestRun�s"	zKTest_TextTestRunner.test_works_with_result_without_startTestRun_stopTestRuncs}Gdd�dt��G��fdd�dtj��g}�|�}|jtj��ddg}|j||�dS)Nc@s"eZdZdZdd�ZdS)zSTest_TextTestRunner.test_startTestRun_stopTestRun_called.<locals>.LoggingTextResultr[cSsdS)Nr)rrrrr\�sz_Test_TextTestRunner.test_startTestRun_stopTestRun_called.<locals>.LoggingTextResult.printErrorsN)r
rrr]r\rrrr�LoggingTextResult�sracs7eZdZ��fdd�Z�fdd�Z�S)zOTest_TextTestRunner.test_startTestRun_stopTestRun_called.<locals>.LoggingRunnercs)t�|�jtj��||_dS)N)rErFrOrP�_events)r�events)�
LoggingRunnerrIrrrF�szXTest_TextTestRunner.test_startTestRun_stopTestRun_called.<locals>.LoggingRunner.__init__cs
�|j�S)N)rb)r)rarrrQ�sz[Test_TextTestRunner.test_startTestRun_stopTestRun_called.<locals>.LoggingRunner._makeResult)r
rrrFrQr)rdra)rIrrd�srdZstartTestRunZstopTestRun)rrr:r/rSr)rrcrCZexpectedr)rdrar�$test_startTestRun_stopTestRun_called�s"z8Test_TextTestRunner.test_startTestRun_stopTestRun_calledcCs�tjd�}tj|�}x^tdtjd�D]F}tj||�}tj|�}|j	|j
j�|j��q5WdS)Nr rr)rOrPrr:�range�pickleZHIGHEST_PROTOCOL�dumps�loadsrrG�getvalue)rrGrCZprotocol�s�objrrr�test_pickle_unpickle�sz(Test_TextTestRunner.test_pickle_unpicklecCs�dd�}t�}t�}t�}tj|||d|�}|j|j|�|j||f}|j|j�|�dS)NcWs|S)Nr)rrrr�MockResultClass	sz=Test_TextTestRunner.test_resultclass.<locals>.MockResultClassr@)�objectrr:rr@rGrQ)rrnZSTREAMZDESCRIPTIONSZ	VERBOSITYrCZexpectedresultrrr�test_resultclasss				z$Test_TextTestRunner.test_resultclasscCsydd�}tdtjdtjdtjjt��}d}d}tjtj	dg|�}|�||�\}}Wd	QRX|j
d
|�|jt|�d�x0dd
dgD]}|j|j
|�d�q�Wx0||dgD]}|j|j
|�d�q�Wtj	ddgtj	dddgtj	ddgf}	xf|	D]^}
tj|
|�}|�||�\}}Wd	QRX|j
d
|�|jt|�d�qIWtjtj	ddg|�}|�||�\}}Wd	QRX|j
d
|�|jt|�d�x3dd
ddgD]}|j|j
|�d�q"Wx-||gD]}|j|j
|�d�qRWd	S)zx
        Check that warnings argument of TextTestRunner correctly affects the
        behavior of the warnings.
        cSsdd�|j�D�S)NcSsg|]}|j��qSr)�
splitlines)�.0�brrr�
<listcomp>s	zPTest_TextTestRunner.test_warnings.<locals>.get_parse_out_err.<locals>.<listcomp>)Zcommunicate)�prrr�get_parse_out_errsz<Test_TextTestRunner.test_warnings.<locals>.get_parse_out_err�stdout�stderr�cwdsPlease use assertEqual instead.sPlease use assertTrue instead.z_test_warnings.pyNsOK�sdwsiwsuwrsrwr�ignorez-Waz-Wir�always�)r�
subprocess�PIPEr6�path�dirname�__file__�Popen�sys�
executableZassertInr�len�count)rrvZoptsZae_msgZat_msgru�out�err�msgZ	args_listrrrr�
test_warningssB
	z!Test_TextTestRunner.test_warningscCsXtj}tj�}|t_z)tj�}|j|jj|k�Wd|t_XdS)N)r�rxrOrPrr:rrG)rZ
old_stderr�frCrrr�%testStdErrLookedUpAtInstantiationTimeNs		z9Test_TextTestRunner.testStdErrLookedUpAtInstantiationTimecCs8tj�}tj|�}|j|jj|k�dS)N)rOrPrr:rrG)rr�rCrrr�testSpecifiedStreamUsedYsz+Test_TextTestRunner.testSpecifiedStreamUsedN)r
rr�__doc__r*r-rDrKrRrTrZr`rermrpr�r�r�rrrrr4�s

9r4�__main__)rOr6r�rgr~rZ
unittest.caserZunittest.test.supportrrrrr4r
�mainrrrr�<module>s|�