a
    kxÛg_  ã                   @   s¾   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlmZ d dlmZ d dlmZ ejZG dd„ dejƒZdd„ Zed	krºeƒ  dS )
é    N)Úsupport)Úscript_helper)Úsocket_helperc                   @   sÌ  e Zd Zdd„ Zdd„ Zdd„ Ze d¡dd	„ ƒZd
d„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Ze eed ƒd!¡d"d#„ ƒZd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Z d6d7„ Z!d8d9„ Z"d:d;„ Z#d<d=„ Z$d>d?„ Z%d@dA„ Z&dBdC„ Z'dDdE„ Z(dFdG„ Z)G dHdI„ dIƒZ*G dJdK„ dKƒZ+dLdM„ Z,dNdO„ Z-dPdQ„ Z.e eedRƒo€eedSƒdT¡dUdV„ ƒZ/dfdXdY„Z0dZd[„ Z1d\d]„ Z2d^d_„ Z3d`da„ Z4dbdc„ Z5ddde„ Z6dWS )gÚTestSupportc                 C   s    t  d¡ |  tjt jd¡ d S )NÚftplibÚfoo)r   Úimport_moduleÚassertRaisesÚunittestÚSkipTest©Úself© r   ú'/usr/lib/python3.9/test/test_support.pyÚtest_import_module   s    
zTestSupport.test_import_modulec                 C   s   t  d¡ d S )Nr   )r   Zimport_fresh_moduler   r   r   r   Útest_import_fresh_module   s    z$TestSupport.test_import_fresh_modulec                 C   s.   |   t | d¡| j¡ |  tjtj| d¡ d S )NÚtest_get_attributer   )ÚassertEqualr   Zget_attributer   r	   r
   r   r   r   r   r   r      s    ÿzTestSupport.test_get_attributezfailing buildbotsc                 C   s   |   t ¡ tj¡ d S ©N)r   r   Zget_original_stdoutÚsysÚstdoutr   r   r   r   Útest_get_original_stdout#   s    z$TestSupport.test_get_original_stdoutc                 C   s2   dd l }|  dtj¡ t d¡ |  dtj¡ d S )Nr   Úsched)r   ÚassertInr   Úmodulesr   ZunloadÚassertNotIn)r   r   r   r   r   Útest_unload'   s    
zTestSupport.test_unloadc                 C   sT   t tdƒ}W d   ƒ n1 s 0    Y  t t¡ |  tj t¡¡ t t¡ d S )NÚw)ÚopenÚTESTFNr   ÚunlinkÚassertFalseÚosÚpathÚexists)r   Úfr   r   r   Útest_unlink-   s
    
zTestSupport.test_unlinkc                 C   sb  t jd }tj |d¡}t |¡ t |¡ t  |¡ |  tj |¡¡ t  	t dd¡ t  |¡ W d   ƒ n1 sv0    Y  t |¡ t |¡ t 
|tjtjB ¡ t  	t dd¡ t  |¡ W d   ƒ n1 sÖ0    Y  |  tj |¡¡ t |¡ t |¡ t 
|d¡ t  	t dd¡ t  |¡ W d   ƒ n1 sB0    Y  |  tj |¡¡ d S )NÚdZsubdirÚverboser   )r   r   r"   r#   ÚjoinÚmkdirÚrmtreer!   r$   Ú	swap_attrÚchmodÚstatÚS_IRUSRÚS_IXUSR)r   ÚdirpathZ
subdirpathr   r   r   Útest_rmtree4   s(    



(

(

*zTestSupport.test_rmtreec              	   C   sÈ   t d }t|dƒ}td|d W d   ƒ n1 s40    Y  tj dtj¡ t 	¡  zNt
t ƒ}|  t tj¡ t t ¡ |  t tj¡ W tjd= t |¡ t d¡ ntjd= t |¡ t d¡ 0 d S )Nz.pyr   zfoo = 1©Úfiler   Ú__pycache__)r   r   Úprintr   r#   Úinsertr"   ÚcurdirÚ	importlibÚinvalidate_cachesÚ
__import__r   r   r   Zforgetr   r    r+   )r   Zmod_filenamer%   Úmodr   r   r   Útest_forgetL   s     *

þ
zTestSupport.test_forgetc                 C   s   t  tjdf¡}| ¡  d S )Nr   )ÚsocketÚcreate_serverr   ÚHOSTÚclose©r   Úsr   r   r   Ú	test_HOST]   s    zTestSupport.test_HOSTc                 C   s$   t  ¡ }t t j|f¡}| ¡  d S r   )r   Zfind_unused_portr>   r?   r@   rA   )r   ZportrC   r   r   r   Útest_find_unused_porta   s    z!TestSupport.test_find_unused_portc                 C   s&   t   ¡ }t |¡ | ¡  | ¡  d S r   )r>   r   Z	bind_portZlistenrA   rB   r   r   r   Útest_bind_portf   s    
zTestSupport.test_bind_portc              	   C   s®   t  ¡ }tj |¡}zˆtj |d¡}|  tj |¡¡ t 	|¡.}|  
||¡ |  tj |¡¡ W d  ƒ n1 st0    Y  |  tj |¡¡ W t |¡ nt |¡ 0 dS )z8Test that temp_dir() creates and destroys its directory.ZtempN)ÚtempfileÚmkdtempr"   r#   Úrealpathr)   r!   Úisdirr   Útemp_dirr   Ú
assertTruer+   )r   Ú
parent_dirr#   Ú	temp_pathr   r   r   Útest_temp_dirn   s    0zTestSupport.test_temp_dirc                 C   sP   t  ¡ "}|  tj |¡¡ W d  ƒ n1 s00    Y  |  tj |¡¡ dS )zTest passing no path.N)r   rK   rL   r"   r#   rJ   r!   )r   rN   r   r   r   Útest_temp_dir__path_none}   s    
0z$TestSupport.test_temp_dir__path_nonec              	   C   sn   dd„ }t  ¡ }tj |¡}z@|  tj |¡¡ |  t||¡ |  tj |¡¡ W t	 
|¡ nt	 
|¡ 0 dS )z-Test passing a directory that already exists.c                 S   s6   t  | ¡}tdƒ‚W d   ƒ n1 s(0    Y  d S ©Nzshould not get here)r   rK   Ú	Exception)r#   rN   r   r   r   Úcall_temp_dir…   s    zMTestSupport.test_temp_dir__existing_dir__quiet_default.<locals>.call_temp_dirN)rG   rH   r"   r#   rI   rL   rJ   r	   ÚFileExistsErrorÚshutilr+   )r   rS   r#   r   r   r   Ú*test_temp_dir__existing_dir__quiet_defaultƒ   s    z6TestSupport.test_temp_dir__existing_dir__quiet_defaultc              	   C   sì   t  ¡ }tj |¡}z’t ¡ Z}tj|dd}|  ||¡ W d  ƒ n1 sP0    Y  dd„ |j	D ƒ}W d  ƒ n1 s~0    Y  |  
tj |¡¡ W t |¡ nt |¡ 0 |  t|ƒd|¡ |d }|  
| d|›d	¡|¡ dS )
z=Test passing a directory that already exists with quiet=True.T©ÚquietNc                 S   s   g | ]}t |jƒ‘qS r   ©ÚstrÚmessage©Ú.0r   r   r   r   Ú
<listcomp>œ   ó    zGTestSupport.test_temp_dir__existing_dir__quiet_true.<locals>.<listcomp>é   r   z5tests may fail, unable to create temporary directory ú: )rG   rH   r"   r#   rI   r   Úcheck_warningsrK   r   ÚwarningsrL   rJ   rU   r+   ÚlenÚ
startswith)r   r#   ÚrecorderrN   rc   Úwarnr   r   r   Ú'test_temp_dir__existing_dir__quiet_true“   s     
*.
ÿþz3TestSupport.test_temp_dir__existing_dir__quiet_trueÚforkztest requires os.forkc                 C   s   t  dt d¡¡ dS )z?Test that a forked child process does not remove the directory.ú-caÐ  
            import os
            from test import support
            with support.temp_cwd() as temp_path:
                pid = os.fork()
                if pid != 0:
                    # parent process

                    # wait for the child to terminate
                    support.wait_process(pid, exitcode=0)

                    # Make sure that temp_path is still present. When the child
                    # process leaves the 'temp_cwd'-context, the __exit__()-
                    # method of the context must not remove the temporary
                    # directory.
                    if not os.path.isdir(temp_path):
                        raise AssertionError("Child removed temp_path.")
        N)r   Zassert_python_okÚtextwrapZdedentr   r   r   r   Útest_temp_dir__forked_child¨   s    z'TestSupport.test_temp_dir__forked_childc              	   C   sŠ   t  ¡ }t ¡ V}t |¡,}|  ||¡ |  t  ¡ |¡ W d   ƒ n1 sN0    Y  W d   ƒ n1 sl0    Y  |  t  ¡ |¡ d S r   )r"   Úgetcwdr   rK   Ú
change_cwdr   )r   Úoriginal_cwdrN   Únew_cwdr   r   r   Útest_change_cwdÂ   s    
LzTestSupport.test_change_cwdc                 C   sh   t  ¡ }dd„ }t ¡ ,}t j |d¡}|  t||¡ W d  ƒ n1 sJ0    Y  |  t  ¡ |¡ dS )z&Test passing a non-existent directory.c                 S   s6   t  | ¡}tdƒ‚W d   ƒ n1 s(0    Y  d S rQ   )r   rn   rR   )r#   rp   r   r   r   Úcall_change_cwdÐ   s    zFTestSupport.test_change_cwd__non_existent_dir.<locals>.call_change_cwdÚdoes_not_existN)	r"   rm   r   rK   r#   r)   r	   ÚFileNotFoundErrorr   )r   ro   rr   rM   Znon_existent_dirr   r   r   Ú!test_change_cwd__non_existent_dirÌ   s    
ÿ"z-TestSupport.test_change_cwd__non_existent_dirc              
   C   sø   t  ¡ }t ¡  }t j |d¡}t ¡ j}tj|dd,}|  ||¡ |  t  ¡ |¡ W d  ƒ n1 sj0    Y  dd„ |j	D ƒ}W d  ƒ n1 s˜0    Y  W d  ƒ n1 s¶0    Y  |  t
|ƒd|¡ |d }|  | d	|›d
¡|¡ dS )z6Test passing a non-existent directory with quiet=True.rs   TrW   Nc                 S   s   g | ]}t |jƒ‘qS r   rY   r\   r   r   r   r^   å   r_   zMTestSupport.test_change_cwd__non_existent_dir__quiet_true.<locals>.<listcomp>r`   r   úBtests may fail, unable to change the current working directory to ra   )r"   rm   r   rK   r#   r)   rb   rn   r   rc   rd   rL   re   )r   ro   rM   Zbad_dirrf   rp   rc   rg   r   r   r   Ú-test_change_cwd__non_existent_dir__quiet_trueÛ   s    

.L
þýz9TestSupport.test_change_cwd__non_existent_dir__quiet_truec              	   C   s¦   t d }t ¡ N}tj|dd W d  ƒ n1 s60    Y  dd„ |jD ƒ}W d  ƒ n1 sd0    Y  |  t|ƒd|¡ |d }|  | d	|›d
¡|¡ dS )z0Check the warning message when os.chdir() fails.Z_does_not_existT)r#   rX   Nc                 S   s   g | ]}t |jƒ‘qS r   rY   r\   r   r   r   r^   ö   r_   z>TestSupport.test_change_cwd__chdir_warning.<locals>.<listcomp>r`   r   rv   ra   )	r   r   rb   rn   rc   r   rd   rL   re   )r   r#   rf   ZmessagesÚmsgr   r   r   Útest_change_cwd__chdir_warningð   s    
.
þýz*TestSupport.test_change_cwd__chdir_warningc                 C   sr   t  ¡ }tjtd( |  t j t  ¡ ¡t¡ W d   ƒ n1 sB0    Y  |  t j 	t¡¡ |  t  ¡ |¡ d S )N©Úname)
r"   rm   r   Útemp_cwdr   r   r#   Úbasenamer!   r$   )r   Úherer   r   r   Útest_temp_cwd  s
    6zTestSupport.test_temp_cwdc                 C   sv   t  ¡ }tjdd>}|  ||¡ |  t j |¡¡ |  t  ¡ |¡ W d  ƒ n1 sX0    Y  |  t  ¡ |¡ dS )z Test passing None to temp_cwd().Nrz   )	r"   rm   r   r|   ZassertNotEqualrL   r#   rJ   r   )r   ro   rp   r   r   r   Útest_temp_cwd__name_none	  s    .z$TestSupport.test_temp_cwd__name_nonec                 C   s   |   t ddddœ¡d¡ d S )Né   é   r`   )r   r‚   r`   z{1: 1, 2: 2, 3: 3})r   r   Zsortdictr   r   r   r   Útest_sortdict  s    zTestSupport.test_sortdictc                 C   sT   t  ¡ }|  t¡}t |d¡ W d   ƒ n1 s40    Y  |  |jjtj	¡ d S )Ns   foo)
r   Zmake_bad_fdr	   ÚOSErrorr"   Úwriter   Z	exceptionÚerrnoZEBADF)r   ÚfdÚcmr   r   r   Útest_make_bad_fd  s    *zTestSupport.test_make_bad_fdc                 C   sL   t j| dddd |  t¡ t  | d¡ W d   ƒ n1 s>0    Y  d S )Nz	def classr`   é   )ÚlinenoÚoffsetzx=1)r   Zcheck_syntax_errorr	   ÚAssertionErrorr   r   r   r   Útest_check_syntax_error  s    z#TestSupport.test_check_syntax_errorc                 C   s@   dd l }t d¡ | d¡ W d   ƒ n1 s20    Y  d S )Nr   Zasyncore)r9   r   ZCleanImportr   )r   r9   r   r   r   Útest_CleanImport   s    zTestSupport.test_CleanImportc                 C   sh   t  dd¡, |  dtj¡ |  dtj¡ W d   ƒ n1 s>0    Y  |  dtj¡ |  dtj¡ d S )Nr   Zbar)r   ZDirsOnSysPathr   r   r#   r   r   r   r   r   Útest_DirsOnSysPath%  s
    ,zTestSupport.test_DirsOnSysPathc                 C   sD   t  ¡ }tdƒ W d   ƒ n1 s&0    Y  |  | ¡ d¡ d S )NÚhelloúhello
)r   Zcaptured_stdoutr6   r   Úgetvalue)r   r   r   r   r   Útest_captured_stdout,  s    
&z TestSupport.test_captured_stdoutc                 C   sJ   t  ¡ }tdtjd W d   ƒ n1 s,0    Y  |  | ¡ d¡ d S )Nr‘   r3   r’   )r   Zcaptured_stderrr6   r   Ústderrr   r“   )r   r•   r   r   r   Útest_captured_stderr1  s    
,z TestSupport.test_captured_stderrc                 C   sR   t  ¡ *}| d¡ | d¡ tƒ }W d   ƒ n1 s80    Y  |  |d¡ d S )Nr’   r   r‘   )r   Zcaptured_stdinr…   ÚseekÚinputr   )r   ÚstdinZcapturedr   r   r   Útest_captured_stdin6  s
    


$zTestSupport.test_captured_stdinc                 C   s   t  ¡  d S r   )r   Z
gc_collectr   r   r   r   Útest_gc_collect>  s    zTestSupport.test_gc_collectc                 C   s   |   t ¡ t¡ d S r   )ZassertIsInstancer   Zpython_is_optimizedÚboolr   r   r   r   Útest_python_is_optimizedA  s    z$TestSupport.test_python_is_optimizedc                 C   s  G dd„ dƒ}|ƒ }d|_ t |dd¡*}|  |j d¡ |  |d¡ W d   ƒ n1 sX0    Y  |  |j d¡ t |dd¡(}|  |jd¡ |  |¡ W d   ƒ n1 s¬0    Y  |  t|dƒ¡ t |dd¡ |`W d   ƒ n1 sî0    Y  |  t|dƒ¡ d S )Nc                   @   s   e Zd ZdS )z'TestSupport.test_swap_attr.<locals>.ObjN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   ÚObjE  s   r¡   r`   ÚxrŠ   Úy)r¢   r   r,   r   r£   ÚassertIsNoner!   Úhasattr)r   r¡   Úobjr¢   r£   r   r   r   Útest_swap_attrD  s    *("zTestSupport.test_swap_attrc                 C   sú   ddi}t  |dd¡,}|  |d d¡ |  |d¡ W d   ƒ n1 sH0    Y  |  |d d¡ t  |dd¡*}|  |d d¡ |  |¡ W d   ƒ n1 s 0    Y  |  d|¡ t  |dd¡ |d= W d   ƒ n1 sà0    Y  |  d|¡ d S )Nr¢   r`   rŠ   r£   )r   Z	swap_itemr   r¤   r   )r   ÚDr¢   r£   r   r   r   Útest_swap_itemU  s    *($zTestSupport.test_swap_itemc                   @   s   e Zd ZdZdZdZdZdS )zTestSupport.RefClassN)rž   rŸ   r    Ú
attribute1Ú
attribute2Z_hidden_attribute1Ú__magic_1__r   r   r   r   ÚRefClassc  s   r­   c                   @   s   e Zd ZdZdZdZdZdS )zTestSupport.OtherClassN)rž   rŸ   r    r«   Ú
attribute3r¬   Ú__magic_2__r   r   r   r   Ú
OtherClassi  s   r°   c                 C   sB   t  | j| j¡}|  dh|¡ t  | j| j¡}|  ddh|¡ d S )Nrª   r®   r¯   )r   Údetect_api_mismatchr­   r°   r   )r   Úmissing_itemsr   r   r   Útest_detect_api_mismatcho  s    ÿÿz$TestSupport.test_detect_api_mismatchc                 C   sP   g d¢}t j| j| j|d}|  tƒ |¡ t j| j| j|d}|  tƒ |¡ d S )N)rª   r®   r¯   Znot_in_either)Úignore)r   r±   r­   r°   r   Úset)r   r´   r²   r   r   r   Ú test_detect_api_mismatch__ignorex  s    
ÿ
ÿz,TestSupport.test_detect_api_mismatch__ignorec                 C   sX   dh}dh}t j| t||d ddh}h d£}t j| td||d |  tt j| t¡ d S )NZtempdirÚtemplate)ÚextraÚ	blacklistZTextTestResultZinstallHandler>   ZTestProgramZ
load_testsZBaseTestSuite)zunittest.resultzunittest.casezunittest.suitezunittest.loaderzunittest.mainzunittest.runnerzunittest.signalszunittest.async_case)r   Zcheck__all__rG   r
   r	   r   )r   r¸   r¹   r   r   r   Útest_check__all__ƒ  s     ýù	zTestSupport.test_check__all__ÚwaitpidÚWNOHANGz need os.waitpid() and os.WNOHANGc                 C   sâ   t  ¡  t ¡ }|dkr"t d¡ t ¡ }t ¡ t j }t j}zŽdt _t	 
¡ }t ¡ |krd|  d¡ tj}z|t_t  ¡  W |t_n|t_0 t jr”q t d¡ qNd| }|  || ¡ ¡ |  t j¡ W |t _n|t _0 t  ¡  d S )Nr   FZtimeoutgš™™™™™¹?z2Warning -- reap_children() reaped child process %s)r   Zreap_childrenr"   ri   Ú_exitÚtimeÚ	monotonicZSHORT_TIMEOUTZenvironment_alteredÚioÚStringIOZfailr   Ú
__stderr__Úsleepr   r“   rL   )r   ÚpidZt0ZdeadlineZwas_alteredr•   Ú
old_stderrrx   r   r   r   Útest_reap_children™  s2    


zTestSupport.test_reap_childrenNc                 C   s†   d|› d|› d}t jg|¢d‘|‘}dd„ tj ¡ D ƒ}tj|tjtjd|d}|d u r^|}|  	|j
 ¡ t|ƒ¡ |  	|jd	¡ d S )
Nzfrom test.support import z; print(repr(z()))rj   c                 S   s    i | ]\}}|  d ¡s||“qS )ZPYTHON)re   )r]   ÚkeyÚvaluer   r   r   Ú
<dictcomp>Í  s   
ÿz-TestSupport.check_options.<locals>.<dictcomp>T)r   r•   Zuniversal_newlinesÚenvr   )r   Ú
executabler"   ÚenvironÚitemsÚ
subprocessÚrunÚPIPEZDEVNULLr   r   ÚrstripÚreprÚ
returncode)r   ÚargsÚfuncÚexpectedÚcodeÚcmdrÊ   Úprocr   r   r   Úcheck_optionsÊ  s    üzTestSupport.check_optionsc                 C   s²   g dgdgdgdgdgdgdgdgd	gd
gdgddgg d¢ddgddgddgddgddgfD ]<}| j |d |  |d¡ W d   ƒ q\1 sŽ0    Y  q\|  g d¢ddg¡ d S )Nz-Bú-sz-Sú-Ez-vz-bz-qú-Iz-bbz-vvvú-Wignoreú-XÚdev)rÞ   rß   rà   ZfaulthandlerZ
importtimeZshowrefcountÚtracemallocztracemalloc=3©ÚoptsZargs_from_interpreter_flags)rÝ   rÜ   rÛ   ©ZsubTestrÚ   ©r   rã   r   r   r   Ú test_args_from_interpreter_flagsÙ  s2    è,ÿz,TestSupport.test_args_from_interpreter_flagsc              	   C   sT   g dgdgdgfD ]<}| j |d |  |d¡ W d   ƒ q1 sD0    Y  qd S )Nz-Oz-OOz-OOOOrâ   Z!optim_args_from_interpreter_flagsrä   rå   r   r   r   Ú&test_optim_args_from_interpreter_flagsû  s    ûz2TestSupport.test_optim_args_from_interpreter_flagsc                 C   sô  G dd„ dƒ}|dƒ}|dƒ}t  t dd ¡Æ t  g ¡ |  t  |¡¡ |  t  |¡¡ t  d d ¡ |  t  |¡¡ |  t  |¡¡ t  | ¡ gd ¡ |  t  |¡¡ |  t  |¡¡ t  dgd ¡ |  t  |¡¡ |  t  |¡¡ t  dgd ¡ |  t  |¡¡ |  t  |¡¡ t  dgd ¡ |  t  |¡¡ t  d	gd ¡ |  t  |¡¡ t  d
gd ¡ |  t  |¡¡ |  t  |¡¡ t  | ¡ | ¡ gd ¡ |  t  |¡¡ |  t  |¡¡ t  ddgd ¡ |  t  |¡¡ |  t  |¡¡ W d   ƒ n1 sü0    Y  t  t dd ¡È t jg d |  t  |¡¡ |  t  |¡¡ t  d d ¡ |  t  |¡¡ |  t  |¡¡ t  d | ¡ g¡ |  t  |¡¡ |  t  |¡¡ t  d dg¡ |  t  |¡¡ |  t  |¡¡ t  d dg¡ |  t  |¡¡ |  t  |¡¡ t  d dg¡ |  t  |¡¡ t  d d	g¡ |  t  |¡¡ t  d d
g¡ |  t  |¡¡ |  t  |¡¡ t  d | ¡ | ¡ g¡ |  t  |¡¡ |  t  |¡¡ t  d ddg¡ |  t  |¡¡ |  t  |¡¡ W d   ƒ n1 sæ0    Y  d S )Nc                   @   s   e Zd Zdd„ Zdd„ ZdS )z)TestSupport.test_match_test.<locals>.Testc                 S   s
   || _ d S r   ©Útest_id)r   ré   r   r   r   Ú__init__	  s    z2TestSupport.test_match_test.<locals>.Test.__init__c                 S   s   | j S r   rè   r   r   r   r   Úid  s    z,TestSupport.test_match_test.<locals>.Test.idN)rž   rŸ   r    rê   rë   r   r   r   r   ÚTest  s   rì   z"test.test_os.FileTests.test_accessz'test.test_os.Win32ErrorTests.test_chdirZ_match_test_funcZtest_osztest_*Z	filetestsZ	FileTestsz*test_os.*.test_*Útest_accessZ	DONTMATCH)Zignore_patterns)r   r,   Zset_match_testsrL   Z
match_testrë   r!   )r   rì   rí   Z
test_chdirr   r   r   Útest_match_test  sz    
0zTestSupport.test_match_testc              	   C   sN   t  ¡ }t ttj¡}zt  ¡ }W t |¡ nt |¡ 0 |  || d¡ d S )Nr`   )r   Zfd_countr"   r   Ú__file__ÚO_RDONLYrA   r   )r   Ústartr‡   Zmorer   r   r   Útest_fd_countp  s    
zTestSupport.test_fd_countc                 C   sF   t  ¡ }tj}z|t_t |¡ W |t_n|t_0 |  | ¡ |¡ d S r   )rÀ   rÁ   r   rÂ   r   Zprint_warningr   r“   )r   rx   rÖ   r•   rÅ   r   r   r   Úcheck_print_warning|  s    zTestSupport.check_print_warningc                 C   s   |   dd¡ |   dd¡ d S )Nrx   zWarning -- msg
za
bzWarning -- a
Warning -- b
)ró   r   r   r   r   Útest_print_warningˆ  s    ÿÿzTestSupport.test_print_warning)N)7rž   rŸ   r    r   r   r   r
   Úskipr   r   r&   r2   r=   rD   rE   rF   rO   rP   rV   rh   Z
skipUnlessr¥   r"   rl   rq   ru   rw   ry   r   r€   rƒ   r‰   rŽ   r   r   r”   r–   rš   r›   r   r§   r©   r­   r°   r³   r¶   rº   rÆ   rÚ   ræ   rç   rî   rò   ró   rô   r   r   r   r   r      sh   


		ÿ
/
"ir   c                  C   s   t g} tj| Ž  d S r   )r   r   Zrun_unittest)Ztestsr   r   r   Ú	test_main§  s    rö   Ú__main__)r†   r9   rÀ   r"   rU   r>   r.   rÎ   r   rG   rk   r¾   r
   Útestr   Ztest.supportr   r   r   ZTestCaser   rö   rž   r   r   r   r   Ú<module>   s2        