Your IP : 216.73.216.85


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



���]�1�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
e
jZGdd�dej�Z
dd�Zedkr�e�dS)�N)�supportc@s�eZdZdd�Zdd�Zdd�Zejd�dd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dBdC�Z%GdDdE�dE�Z&GdFdG�dG�Z'dHdI�Z(dJdK�Z)dLS)M�TestSupportcCs*tjd�|jtjtjd�dS)N�ftplib�foo)r�
import_module�assertRaises�unittest�SkipTest)�self�r�1/opt/alt/python35/lib64/python3.5/test_support.py�test_import_modules
zTestSupport.test_import_modulecCstjd�dS)Nr)rZimport_fresh_module)r
rrr�test_import_fresh_modulesz$TestSupport.test_import_fresh_modulecCs?|jtj|d�|j�|jtjtj|d�dS)N�test_get_attributer)�assertEqualrZ
get_attributerrrr	)r
rrrrs
zTestSupport.test_get_attributezfailing buildbotscCs|jtj�tj�dS)N)rrZget_original_stdout�sys�stdout)r
rrr�test_get_original_stdoutsz$TestSupport.test_get_original_stdoutcCsCddl}|jdtj�tjd�|jdtj�dS)Nr�sched)r�assertInr�modulesrZunload�assertNotIn)r
rrrr�test_unload!s
zTestSupport.test_unloadc
CsPttd��}WdQRXtjt�|jtjjt��tjt�dS)N�w)�open�TESTFNr�unlink�assertFalse�os�path�exists)r
�frrr�test_unlink's

zTestSupport.test_unlinkcCsttjd}tjj|d�}tj|�tj|�tj|�|jtjj|��tj	tdd��tj|�WdQRXtj|�tj|�tj
|tjtj
B�tj	tdd��tj|�WdQRX|jtjj|��tj|�tj|�tj
|d�tj	tdd��tj|�WdQRX|jtjj|��dS)N�dZsubdir�verboser)rrrr�join�mkdir�rmtreerr �	swap_attr�chmod�stat�S_IRUSR�S_IXUSR)r
�dirpathZ
subdirpathrrr�test_rmtree.s(







zTestSupport.test_rmtreecCs�td}t|d��}tdd|�WdQRXtjjdtj�tj	�zCt
t�}|jttj�t
jt�|jttj�Wdtjd=t
j|�t
jd�XdS)Nz.pyrzfoo = 1�filer�__pycache__)rr�printrr�insertr�curdir�	importlib�invalidate_caches�
__import__rrrZforgetrrr')r
Zmod_filenamer!�modrrr�test_forgetFs




zTestSupport.test_forgetcCs0tj�}|jtjdf�|j�dS)Nr)�socket�bindr�HOST�close)r
�srrr�	test_HOSTWszTestSupport.test_HOSTcCs<tj�}tj�}|jtj|f�|j�dS)N)rZfind_unused_portr9r:r;r<)r
�portr=rrr�test_find_unused_port\sz!TestSupport.test_find_unused_portcCs1tj�}tj|�|j�|j�dS)N)r9rZ	bind_port�listenr<)r
r=rrr�test_bind_portbs

zTestSupport.test_bind_portcCs�tj�}tjj|�}z�tjj|d�}|jtjj|��tj	|��0}|j
||�|jtjj|��WdQRX|jtjj|��Wdtj|�XdS)NZtemp)
�tempfile�mkdtemprr�realpathr%r�isdirr�temp_dirr�
assertTruer')r
�
parent_dirr�	temp_pathrrr�
test_temp_dirjs zTestSupport.test_temp_dirc
CsLtj�� }|jtjj|��WdQRX|jtjj|��dS)N)rrGrHrrrFr)r
rJrrr�test_temp_dir__path_noneys z$TestSupport.test_temp_dir__path_nonecCs�dd�}tj�}tjj|�}zI|jtjj|��|jt||�|jtjj|��Wdt	j
|�XdS)Nc	Ss)tj|��}td��WdQRXdS)Nzshould not get here)rrG�	Exception)rrJrrr�
call_temp_dir�szMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dir)rCrDrrrErHrFr�FileExistsError�shutilr')r
rNrrrr�*test_temp_dir__existing_dir__quiet_defaultsz6TestSupport.test_temp_dir__existing_dir__quiet_defaultcCs�tj�}tjj|�}zxtj��L}tj|dd��}|j||�WdQRXdd�|j	D�}WdQRX|j
tjj|��Wdtj
|�Xd|g}|j||�dS)N�quietTcSsg|]}t|j��qSr)�str�message)�.0rrrr�
<listcomp>�s	zGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>z+tests may fail, unable to create temp dir: )rCrDrrrEr�check_warningsrGr�warningsrHrFrPr')r
r�recorderrJrX�expectedrrr�'test_temp_dir__existing_dir__quiet_true�s
z3TestSupport.test_temp_dir__existing_dir__quiet_truecCs{tj�}tj��F}tj|��-}|j||�|jtj�|�WdQRXWdQRX|jtj�|�dS)N)r�getcwdrrG�
change_cwdr)r
�original_cwdrJ�new_cwdrrr�test_change_cwd�s$zTestSupport.test_change_cwdcCsptj�}dd�}tj��/}tjj|d�}|jt||�WdQRX|jtj�|�dS)Nc	Ss)tj|��}td��WdQRXdS)Nzshould not get here)rr]rM)rr_rrr�call_change_cwd�szFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwd�does_not_exist)	rr\rrGrr%r�FileNotFoundErrorr)r
r^rarIZnon_existent_dirrrr�!test_change_cwd__non_existent_dir�sz-TestSupport.test_change_cwd__non_existent_dircCs�tj�}tj���}tjj|d�}tj��b}tj|dd��-}|j||�|jtj�|�WdQRXdd�|j	D�}WdQRXWdQRXd|g}|j||�dS)NrbrRTcSsg|]}t|j��qSr)rSrT)rUrrrrrV�s	zMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>z)tests may fail, unable to change CWD to: )
rr\rrGrr%rWr]rrX)r
r^rIZbad_dirrYr_rXrZrrr�-test_change_cwd__non_existent_dir__quiet_true�s$
z9TestSupport.test_change_cwd__non_existent_dir__quiet_truecCsqtd}tj��=}tjd|dd��WdQRXdd�|jD�}WdQRX|j|d|g�dS)NZ_does_not_existrrRTcSsg|]}t|j��qSr)rSrT)rUrrrrrV�s	z>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>z)tests may fail, unable to change CWD to: )rrrWr]rXr)r
rrY�messagesrrr�test_change_cwd__chdir_warning�s
z*TestSupport.test_change_cwd__chdir_warningc
Cs�tj�}tjdt��'|jtjjtj��t�WdQRX|jtjj	t��|j
tjjtj��|�dS)N�name)rr\r�temp_cwdrrr�basenamerr rH)r
�hererrr�
test_temp_cwd�s
)zTestSupport.test_temp_cwdc
Cs�tj�}tjdd��F}|j||�|jtjj|��|jtj�|�WdQRX|jtj�|�dS)Nrh)	rr\rriZassertNotEqualrHrrFr)r
r^r_rrr�test_temp_cwd__name_none�sz$TestSupport.test_temp_cwd__name_nonecCs/|jtjddddddi�d�dS)N���z{1: 1, 2: 2, 3: 3})rrZsortdict)r
rrr�
test_sortdict�szTestSupport.test_sortdictc
CsRtj�}|jt��}tj|d�WdQRX|j|jjtj	�dS)Nsfoo)
rZmake_bad_fdr�OSErrorr�writer�	exception�errno�EBADF)r
�fd�cmrrr�test_make_bad_fd�szTestSupport.test_make_bad_fdcCs9tj|ddddd�|jttj|d�dS)Nz	def class�linenorp�offset�	�1)rZcheck_syntax_errorr�AssertionError)r
rrr�test_check_syntax_error�sz#TestSupport.test_check_syntax_errorc	Cs4ddl}tjd��|jd�WdQRXdS)NrZasyncore)r4rZCleanImportr)r
r4rrr�test_CleanImport�szTestSupport.test_CleanImportc
Csjtjdd��+|jdtj�|jdtj�WdQRX|jdtj�|jdtj�dS)NrZbar)rZ
DirsOnSysPathrrrr)r
rrr�test_DirsOnSysPath�s
zTestSupport.test_DirsOnSysPathc
Cs:tj��}td�WdQRX|j|j�d�dS)N�hellozhello
)rZcaptured_stdoutr1r�getvalue)r
rrrr�test_captured_stdoutsz TestSupport.test_captured_stdoutcCsCtj��}tddtj�WdQRX|j|j�d�dS)Nr�r/zhello
)rZcaptured_stderrr1r�stderrrr�)r
r�rrr�test_captured_stderr	sz TestSupport.test_captured_stderrc
CsMtj��*}|jd�|jd�t�}WdQRX|j|d�dS)Nzhello
rr�)rZcaptured_stdinrs�seek�inputr)r
�stdinZcapturedrrr�test_captured_stdins


zTestSupport.test_captured_stdincCstj�dS)N)rZ
gc_collect)r
rrr�test_gc_collectszTestSupport.test_gc_collectcCs|jtj�t�dS)N)ZassertIsInstancerZpython_is_optimized�bool)r
rrr�test_python_is_optimizedsz$TestSupport.test_python_is_optimizedcCsGdd�d�}|�}d|_tj|dd��*}|j|jd�|j|d�WdQRX|j|jd�tj|dd��'}|j|jd�|j|�WdQRX|jt|d��tj|dd��|`WdQRX|jt|d��dS)Nc@seZdZdS)z'TestSupport.test_swap_attr.<locals>.ObjN)�__name__�
__module__�__qualname__rrrr�Objsr�rp�x��y)r�rr(rr��assertIsNoner�hasattr)r
r��objr�r�rrr�test_swap_attrs		
zTestSupport.test_swap_attrcCs�ddi}tj|dd��+}|j|dd�|j|d�WdQRX|j|dd�tj|dd��(}|j|dd�|j|�WdQRX|jd|�tj|dd��|d=WdQRX|jd|�dS)Nr�rpr�r�)rZ	swap_itemrr�r)r
�Dr�r�rrr�test_swap_item-szTestSupport.test_swap_itemc@s(eZdZdZdZdZdZdS)zTestSupport.RefClassN)r�r�r��
attribute1�
attribute2Z_hidden_attribute1�__magic_1__rrrr�RefClass;sr�c@s(eZdZdZdZdZdZdS)zTestSupport.OtherClassN)r�r�r�r��
attribute3r��__magic_2__rrrr�
OtherClassAsr�cCs]tj|j|j�}|jdh|�tj|j|j�}|jddh|�dS)Nr�r�r�)r�detect_api_mismatchr�r�r)r
�
missing_itemsrrr�test_detect_api_mismatchGsz$TestSupport.test_detect_api_mismatchcCsxddddg}tj|j|jd|�}|jt�|�tj|j|jd|�}|jt�|�dS)Nr�r�r�Z
not_in_either�ignore)rr�r�r�r�set)r
r�r�rrr� test_detect_api_mismatch__ignorePsz,TestSupport.test_detect_api_mismatch__ignoreN)*r�r�r�r
rrr�skiprrr"r.r8r>r@rBrKrLrQr[r`rdrergrlrmrqryrr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrsJ
		rcCstg}tj|�dS)N)rrZrun_unittest)Ztestsrrr�	test_mainws	r��__main__)r4rPr*rrrr9rCruZtestrrZTestCaserr�r�rrrr�<module>s	�i