a
    õ£Be³:  ã                   @   s  d Z ddlm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 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ej'j(Z(e )¡ Z*d Z+d!d"„ Z,G d#d$„ d$eƒZ-G d%d&„ d&e-ƒZ.e /e d'¡G d(d)„ d)eƒƒZ0G d*d+„ d+eƒZ1e2d,k�rdd-l3m4Z4 e4e5ƒ dS ).a©  Tests for detecting function memory leaks (typically the ones
implemented in C). It does so by calling a function many times and
checking whether process memory usage keeps increasing between
calls or over time.
Note that this may produce false positives (especially on Windows
for some reason).
PyPy appears to be completely unstable for this framework, probably
because of how its JIT handles memory, so tests are skipped.
é    )Úprint_functionN)ÚLINUX)ÚMACOS)ÚOPENBSD)ÚPOSIX)ÚSUNOS)ÚWINDOWS)ÚProcessLookupError)Úsuper)ÚHAS_CPU_AFFINITY)ÚHAS_CPU_FREQ)ÚHAS_ENVIRON)Ú
HAS_IONICE)ÚHAS_MEMORY_MAPS)ÚHAS_NET_IO_COUNTERS)ÚHAS_PROC_CPU_NUM)ÚHAS_PROC_IO_COUNTERS)Ú
HAS_RLIMIT)ÚHAS_SENSORS_BATTERY)ÚHAS_SENSORS_FANS)ÚHAS_SENSORS_TEMPERATURES)ÚTestMemoryLeak)Úcreate_sockets)Ú
get_testfn)Úprocess_namespace)Úskip_on_access_denied)Úspawn_testproc)Úsystem_namespace)Ú	terminateé   c                  C   s   dd„ } | S )zsDecorator for those Linux functions which are implemented in pure
    Python, and which we want to run faster.
    c                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc                    s\   t rB| jj}z(t| j_ˆ | g|¢R i |¤ŽW || j_S || j_0 nˆ | g|¢R i |¤ŽS d S ©N)r   Ú	__class__ÚtimesÚ	FEW_TIMES)ÚselfÚargsÚkwargsÚbefore©Úfun© ú]/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/psutil/tests/test_memleaks.pyÚwrapperB   s    þz5fewtimes_if_linux.<locals>.decorator.<locals>.wrapper)Ú	functoolsÚwraps)r)   r,   r*   r(   r+   Ú	decoratorA   s    
z$fewtimes_if_linux.<locals>.decoratorr*   )r/   r*   r*   r+   Úfewtimes_if_linux=   s    r0   c                   @   sà  e Zd ZdZeZdd„ Zeƒ dd„ ƒZeƒ dd„ ƒZ	eƒ dd	„ ƒZ
eƒ d
d„ ƒZe e d¡eƒ dd„ ƒƒZe e d¡eƒ dd„ ƒƒZeƒ dd„ ƒZdd„ Zdd„ Ze e d¡dd„ ƒZe e d¡dd„ ƒZe e d¡eƒ dd„ ƒƒZe ed¡dd „ ƒZeƒ d!d"„ ƒZeƒ eed#�d$d%„ ƒƒZe e d&¡d'd(„ ƒZe e d¡eƒ d)d*„ ƒƒZ eƒ d+d,„ ƒZ!eƒ eed#�d-d.„ ƒƒZ"eƒ d/d0„ ƒZ#eƒ e e$ d¡d1d2„ ƒƒZ%eƒ d3d4„ ƒZ&eƒ d5d6„ ƒZ'e e d¡eƒ d7d8„ ƒƒZ(d9d:„ Z)eƒ d;d<„ ƒZ*e e+ d¡d=d>„ ƒZ,e e+ d¡d?d@„ ƒZ-eƒ dAdB„ ƒZ.e e/ d¡eƒ dCdD„ ƒƒZ0e e1 dE¡e e2 d¡dFdG„ ƒƒZ3e e1 dE¡e e2 d¡dHdI„ ƒƒZ4eƒ e edJ¡dKdL„ ƒƒZ5e e6 d¡dMdN„ ƒZ7e e d&¡dOdP„ ƒZ8dQS )RÚTestProcessObjectLeaksz$Test leaks of Process class methods.c                 C   s    t d ƒ}| | |j|j ¡ d S r    )r   Útest_class_coverageZgettersÚsetters©r$   Únsr*   r*   r+   Útest_coverage[   s    z$TestProcessObjectLeaks.test_coveragec                 C   s   |   | jj¡ d S r    )ÚexecuteÚprocÚname©r$   r*   r*   r+   Ú	test_name_   s    z TestProcessObjectLeaks.test_namec                 C   s   |   | jj¡ d S r    )r7   r8   Zcmdliner:   r*   r*   r+   Útest_cmdlinec   s    z#TestProcessObjectLeaks.test_cmdlinec                 C   s   |   | jj¡ d S r    )r7   r8   Úexer:   r*   r*   r+   Útest_exeg   s    zTestProcessObjectLeaks.test_exec                 C   s   |   | jj¡ d S r    )r7   r8   Zppidr:   r*   r*   r+   Ú	test_ppidk   s    z TestProcessObjectLeaks.test_ppidz
POSIX onlyc                 C   s   |   | jj¡ d S r    )r7   r8   Zuidsr:   r*   r*   r+   Ú	test_uidso   s    z TestProcessObjectLeaks.test_uidsc                 C   s   |   | jj¡ d S r    )r7   r8   Úgidsr:   r*   r*   r+   Ú	test_gidst   s    z TestProcessObjectLeaks.test_gidsc                 C   s   |   | jj¡ d S r    )r7   r8   Ústatusr:   r*   r*   r+   Útest_statusy   s    z"TestProcessObjectLeaks.test_statusc                 C   s   |   | jj¡ d S r    )r7   r8   Únicer:   r*   r*   r+   Ú	test_nice}   s    z TestProcessObjectLeaks.test_nicec                    s    t  ¡ ‰ ˆ ‡ ‡fdd„¡ d S )Nc                      s   ˆj  ˆ ¡S r    )r8   rE   r*   ©Znicenessr$   r*   r+   Ú<lambda>‚   ó    z6TestProcessObjectLeaks.test_nice_set.<locals>.<lambda>)ÚthisprocrE   r7   r:   r*   rG   r+   Útest_nice_set€   s    z$TestProcessObjectLeaks.test_nice_setúnot supportedc                 C   s   |   | jj¡ d S r    )r7   r8   Úionicer:   r*   r*   r+   Útest_ionice„   s    z"TestProcessObjectLeaks.test_ionicec                    sZ   t r"t ¡ ‰ˆ  ‡ ‡fdd„¡ n4ˆ  ‡ fdd„¡ t tjt 	¡ dd¡}ˆ  
t|¡ d S )Nc                      s   ˆ j  ˆ¡S r    )r8   rM   r*   ©r$   Úvaluer*   r+   rH   Œ   rI   z8TestProcessObjectLeaks.test_ionice_set.<locals>.<lambda>c                      s   ˆ j  tj¡S r    )r8   rM   ÚpsutilZIOPRIO_CLASS_NONEr*   r:   r*   r+   rH   Ž   rI   éÿÿÿÿr   )r   rJ   rM   r7   r-   ÚpartialÚcextZproc_ioprio_setÚosÚgetpidÚexecute_w_excÚOSError©r$   r)   r*   rO   r+   Útest_ionice_setˆ   s    z&TestProcessObjectLeaks.test_ionice_setc                 C   s   |   | jj¡ d S r    )r7   r8   Zio_countersr:   r*   r*   r+   Útest_io_counters’   s    z'TestProcessObjectLeaks.test_io_counterszworthless on POSIXc                 C   s   t  ¡  ¡  |  | jj¡ d S r    )rQ   ÚProcessÚusernamer7   r8   r:   r*   r*   r+   Útest_username—   s    z$TestProcessObjectLeaks.test_usernamec                 C   s   |   | jj¡ d S r    )r7   r8   Zcreate_timer:   r*   r*   r+   Útest_create_time�   s    z'TestProcessObjectLeaks.test_create_time)Zonly_ifc                 C   s   |   | jj¡ d S r    )r7   r8   Znum_threadsr:   r*   r*   r+   Útest_num_threads¡   s    z'TestProcessObjectLeaks.test_num_threadsúWINDOWS onlyc                 C   s   |   | jj¡ d S r    )r7   r8   Znum_handlesr:   r*   r*   r+   Útest_num_handles¦   s    z'TestProcessObjectLeaks.test_num_handlesc                 C   s   |   | jj¡ d S r    )r7   r8   Znum_fdsr:   r*   r*   r+   Útest_num_fdsª   s    z#TestProcessObjectLeaks.test_num_fdsc                 C   s   |   | jj¡ d S r    )r7   r8   Znum_ctx_switchesr:   r*   r*   r+   Útest_num_ctx_switches¯   s    z,TestProcessObjectLeaks.test_num_ctx_switchesc                 C   s   |   | jj¡ d S r    )r7   r8   Úthreadsr:   r*   r*   r+   Útest_threads³   s    z#TestProcessObjectLeaks.test_threadsc                 C   s   |   | jj¡ d S r    )r7   r8   Ú	cpu_timesr:   r*   r*   r+   Útest_cpu_times¸   s    z%TestProcessObjectLeaks.test_cpu_timesc                 C   s   |   | jj¡ d S r    )r7   r8   Zcpu_numr:   r*   r*   r+   Útest_cpu_num¼   s    z#TestProcessObjectLeaks.test_cpu_numc                 C   s   |   | jj¡ d S r    )r7   r8   Zmemory_infor:   r*   r*   r+   Útest_memory_infoÁ   s    z'TestProcessObjectLeaks.test_memory_infoc                 C   s   |   | jj¡ d S r    )r7   r8   Zmemory_full_infor:   r*   r*   r+   Útest_memory_full_infoÅ   s    z,TestProcessObjectLeaks.test_memory_full_infoc                 C   s   |   | jj¡ d S r    )r7   r8   Zterminalr:   r*   r*   r+   Útest_terminalÉ   s    z$TestProcessObjectLeaks.test_terminalc                 C   s$   t rtn| j}| j| jj|d� d S )N©r"   )r   r#   r"   r7   r8   Úresume©r$   r"   r*   r*   r+   Útest_resumeÎ   s    z"TestProcessObjectLeaks.test_resumec                 C   s   |   | jj¡ d S r    )r7   r8   Úcwdr:   r*   r*   r+   Útest_cwdÒ   s    zTestProcessObjectLeaks.test_cwdc                 C   s   |   | jj¡ d S r    )r7   r8   Úcpu_affinityr:   r*   r*   r+   Útest_cpu_affinityÖ   s    z(TestProcessObjectLeaks.test_cpu_affinityc                    s4   t  ¡ ‰ ˆ ‡ ‡fdd„¡ ˆ t‡fdd„¡ d S )Nc                      s   ˆj  ˆ ¡S r    ©r8   rs   r*   ©Zaffinityr$   r*   r+   rH   Ý   rI   z>TestProcessObjectLeaks.test_cpu_affinity_set.<locals>.<lambda>c                      s   ˆ j  dg¡S ©NrR   ru   r*   r:   r*   r+   rH   ß   rI   )rJ   rs   r7   rW   Ú
ValueErrorr:   r*   rv   r+   Útest_cpu_affinity_setÚ   s
    ÿz,TestProcessObjectLeaks.test_cpu_affinity_setc                 C   s>   t tƒ dƒ� |  | jj¡ W d   ƒ n1 s00    Y  d S )NÚw)Úopenr   r7   r8   Z
open_filesr:   r*   r*   r+   Útest_open_filesá   s    z&TestProcessObjectLeaks.test_open_filesc                 C   s   |   | jj¡ d S r    )r7   r8   Zmemory_mapsr:   r*   r*   r+   Útest_memory_mapsæ   s    z'TestProcessObjectLeaks.test_memory_mapsz
LINUX onlyc                    s   ˆ   ‡ fdd„¡ d S )Nc                      s   ˆ j  tj¡S r    ©r8   ÚrlimitrQ   ÚRLIMIT_NOFILEr*   r:   r*   r+   rH   î   rI   z4TestProcessObjectLeaks.test_rlimit.<locals>.<lambda>©r7   r:   r*   r:   r+   Útest_rlimitë   s    z"TestProcessObjectLeaks.test_rlimitc                    s<   t  tj¡‰ ˆ ‡ ‡fdd„¡ ˆ ttf‡fdd„¡ d S )Nc                      s   ˆj  tjˆ ¡S r    r~   r*   ©Úlimitr$   r*   r+   rH   ô   rI   z8TestProcessObjectLeaks.test_rlimit_set.<locals>.<lambda>c                      s   ˆ j  d¡S rw   )r8   r   r*   r:   r*   r+   rH   õ   rI   )rJ   r   rQ   r€   r7   rW   rX   rx   r:   r*   rƒ   r+   Útest_rlimit_setð   s    z&TestProcessObjectLeaks.test_rlimit_setzworthless on WINDOWSc                    sJ   t ƒ �0 trdnd‰ ˆ ‡ ‡fdd„¡ W d   ƒ n1 s<0    Y  d S )NZinetÚallc                      s   ˆj  ˆ ¡S r    )r8   Úconnectionsr*   ©Úkindr$   r*   r+   rH     rI   z9TestProcessObjectLeaks.test_connections.<locals>.<lambda>)r   r   r7   r:   r*   rˆ   r+   Útest_connections÷   s    z'TestProcessObjectLeaks.test_connectionsc                 C   s   |   | jj¡ d S r    )r7   r8   Úenvironr:   r*   r*   r+   Útest_environ  s    z#TestProcessObjectLeaks.test_environc                 C   s   |   dd„ ¡ d S )Nc                   S   s   t  t ¡ ¡S r    )rT   Ú	proc_inforU   rV   r*   r*   r*   r+   rH   	  rI   z7TestProcessObjectLeaks.test_proc_info.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_proc_info  s    z%TestProcessObjectLeaks.test_proc_infoN)9Ú__name__Ú
__module__Ú__qualname__Ú__doc__rJ   r8   r6   r0   r;   r<   r>   r?   ÚunittestÚskipIfr   r@   rB   rD   rF   rK   r   rN   rZ   r   r[   r^   r_   r   r   r`   r   rb   rc   rd   rf   rh   r   ri   rj   rk   rl   rp   rr   r   rt   ry   r|   r   r}   r   r   r‚   r…   rŠ   r   rŒ   rŽ   r*   r*   r*   r+   r1   V   s¤   






	













r1   c                       sp   e Zd ZdZe‡ fdd„ƒZe‡ fdd„ƒZdd„ Zerhdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚTestTerminatedProcessLeakszñRepeat the tests above looking for leaks occurring when dealing
    with terminated processes raising NoSuchProcess exception.
    The C functions are still invoked but will follow different code
    paths. We'll check those code paths.
    c                    s:   t ƒ  ¡  tƒ | _t | jj¡| _| j ¡  | j 	¡  d S r    )
r
   Ú
setUpClassr   ÚsubprQ   r\   Úpidr8   ÚkillÚwait©Úcls©r!   r*   r+   r–     s
    

z%TestTerminatedProcessLeaks.setUpClassc                    s   t ƒ  ¡  t| jƒ d S r    )r
   ÚtearDownClassr   r—   r›   r�   r*   r+   rž     s    
z(TestTerminatedProcessLeaks.tearDownClassc                 C   s$   z
|ƒ  W n t jy   Y n0 d S r    )rQ   ZNoSuchProcessrY   r*   r*   r+   Úcall   s    
zTestTerminatedProcessLeaks.callc                 C   s   |   | jj¡ d S r    )r7   r8   r™   r:   r*   r*   r+   Ú	test_kill(  s    z$TestTerminatedProcessLeaks.test_killc                 C   s   |   | jj¡ d S r    )r7   r8   r   r:   r*   r*   r+   Útest_terminate+  s    z)TestTerminatedProcessLeaks.test_terminatec                 C   s   |   | jj¡ d S r    )r7   r8   Zsuspendr:   r*   r*   r+   Útest_suspend.  s    z'TestTerminatedProcessLeaks.test_suspendc                 C   s   |   | jj¡ d S r    )r7   r8   rn   r:   r*   r*   r+   rp   1  s    z&TestTerminatedProcessLeaks.test_resumec                 C   s   |   | jj¡ d S r    )r7   r8   rš   r:   r*   r*   r+   Ú	test_wait4  s    z$TestTerminatedProcessLeaks.test_waitc                    s   ‡ fdd„}ˆ   |¡ d S )Nc                      s(   zt  ˆ jj¡W S  ty"   Y n0 d S r    )rT   r�   r8   r˜   r	   r*   r:   r*   r+   rŸ   9  s    z7TestTerminatedProcessLeaks.test_proc_info.<locals>.callr�   )r$   rŸ   r*   r:   r+   rŽ   7  s    z)TestTerminatedProcessLeaks.test_proc_info)r�   r�   r‘   r’   Úclassmethodr–   rž   rŸ   r   r    r¡   r¢   rp   r£   rŽ   Ú__classcell__r*   r*   r�   r+   r•     s   r•   ra   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestProcessDualImplementationc                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jt ¡ dd�S )NT©Zuse_peb©rT   Zproc_cmdlinerU   rV   r*   r*   r*   r+   rH   F  rI   zETestProcessDualImplementation.test_cmdline_peb_true.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_cmdline_peb_trueE  s    z3TestProcessDualImplementation.test_cmdline_peb_truec                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jt ¡ dd�S )NFr§   r¨   r*   r*   r*   r+   rH   I  rI   zFTestProcessDualImplementation.test_cmdline_peb_false.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_cmdline_peb_falseH  s    z4TestProcessDualImplementation.test_cmdline_peb_falseN)r�   r�   r‘   r©   rª   r*   r*   r*   r+   r¦   B  s   r¦   c                   @   s  e Zd ZdZdd„ Zeƒ dd„ ƒZeƒ dd„ ƒZeƒ dd	„ ƒZeƒ d
d„ ƒZ	eƒ dd„ ƒZ
eƒ e eope ¡ dkd¡e e d¡dd„ ƒƒƒZe e d¡dd„ ƒZdd„ Ze ed¡dd„ ƒZdd„ Zdd„ Zdd „ Ze eoìej d!¡ d"¡eƒ d#d$„ ƒƒZeƒ d%d&„ ƒZeƒ e e  d¡d'd(„ ƒƒZ!eƒ e e�oBe "¡ d)kd*¡d+d,„ ƒƒZ#d-d.„ Z$d/d0„ Z%eƒ e e& d¡d1d2„ ƒƒZ'eƒ e e( d¡d3d4„ ƒƒZ)eƒ e e* d¡d5d6„ ƒƒZ+eƒ d7d8„ ƒZ,d9d:„ Z-d;d<„ Z.e�rd=d>„ Z/d?d@„ Z0dAdB„ Z1dCdD„ Z2dEdF„ Z3dGS )HÚTestModuleFunctionsLeaksz&Test leaks of psutil module functions.c                 C   s   t ƒ }| | |j¡ d S r    )r   r2   r†   r4   r*   r*   r+   r6   T  s    z&TestModuleFunctionsLeaks.test_coveragec                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jdd�S )NT©Zlogical©rQ   Ú	cpu_countr*   r*   r*   r+   rH   \  rI   z9TestModuleFunctionsLeaks.test_cpu_count.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_cpu_countZ  s    z'TestModuleFunctionsLeaks.test_cpu_countc                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jdd�S )NFr¬   r­   r*   r*   r*   r+   rH   `  rI   z?TestModuleFunctionsLeaks.test_cpu_count_cores.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_cpu_count_cores^  s    z-TestModuleFunctionsLeaks.test_cpu_count_coresc                 C   s   |   tj¡ d S r    )r7   rQ   rg   r:   r*   r*   r+   rh   b  s    z'TestModuleFunctionsLeaks.test_cpu_timesc                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jdd�S )NT)Zpercpu)rQ   rg   r*   r*   r*   r+   rH   h  rI   z=TestModuleFunctionsLeaks.test_per_cpu_times.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_per_cpu_timesf  s    z+TestModuleFunctionsLeaks.test_per_cpu_timesc                 C   s   |   tj¡ d S r    )r7   rQ   Z	cpu_statsr:   r*   r*   r+   Útest_cpu_statsj  s    z'TestModuleFunctionsLeaks.test_cpu_statsÚarm64zskipped due to #1892rL   c                 C   s   |   tj¡ d S r    )r7   rQ   Zcpu_freqr:   r*   r*   r+   Útest_cpu_freqn  s    z&TestModuleFunctionsLeaks.test_cpu_freqra   c                 C   s   t  ¡  |  t j¡ d S r    )rQ   Ú
getloadavgr7   r:   r*   r*   r+   Útest_getloadavgv  s    z(TestModuleFunctionsLeaks.test_getloadavgc                 C   s   |   tj¡ d S r    )r7   rQ   Zvirtual_memoryr:   r*   r*   r+   Útest_virtual_memory}  s    z,TestModuleFunctionsLeaks.test_virtual_memoryz&worthless on SUNOS (uses a subprocess)c                 C   s   |   tj¡ d S r    )r7   rQ   Zswap_memoryr:   r*   r*   r+   Útest_swap_memory�  s    z)TestModuleFunctionsLeaks.test_swap_memoryc                 C   s$   t rtn| j}| jdd„ |d� d S )Nc                   S   s   t  t ¡ ¡S r    )rQ   Z
pid_existsrU   rV   r*   r*   r*   r+   rH   ‡  rI   z:TestModuleFunctionsLeaks.test_pid_exists.<locals>.<lambda>rm   ©r   r#   r"   r7   ro   r*   r*   r+   Útest_pid_exists…  s    z(TestModuleFunctionsLeaks.test_pid_existsc                 C   s$   t rtn| j}| jdd„ |d� d S )Nc                   S   s
   t  d¡S )NÚ.)rQ   Ú
disk_usager*   r*   r*   r+   rH   �  rI   z:TestModuleFunctionsLeaks.test_disk_usage.<locals>.<lambda>rm   r¹   ro   r*   r*   r+   Útest_disk_usage‹  s    z(TestModuleFunctionsLeaks.test_disk_usagec                 C   s   |   tj¡ d S r    )r7   rQ   Zdisk_partitionsr:   r*   r*   r+   Útest_disk_partitions�  s    z-TestModuleFunctionsLeaks.test_disk_partitionsz/proc/diskstatsz3/proc/diskstats not available on this Linux versionc                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jdd�S ©NF)Znowrap)rQ   Zdisk_io_countersr*   r*   r*   r+   rH   –  rI   z@TestModuleFunctionsLeaks.test_disk_io_counters.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_disk_io_counters’  s    z.TestModuleFunctionsLeaks.test_disk_io_countersc                 C   s   |   tj¡ d S r    )r7   rQ   Zpidsr:   r*   r*   r+   Ú	test_pidsš  s    z"TestModuleFunctionsLeaks.test_pidsc                 C   s   |   dd„ ¡ d S )Nc                   S   s   t jdd�S r¿   )rQ   Znet_io_countersr*   r*   r*   r+   rH   £  rI   z?TestModuleFunctionsLeaks.test_net_io_counters.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_net_io_counters   s    z-TestModuleFunctionsLeaks.test_net_io_countersr   zneed root accessc                 C   sD   t jdd� tƒ � |  dd„ ¡ W d   ƒ n1 s60    Y  d S )Nr†   ©r‰   c                   S   s   t jdd�S )Nr†   rÃ   )rQ   Únet_connectionsr*   r*   r*   r+   rH   «  rI   z?TestModuleFunctionsLeaks.test_net_connections.<locals>.<lambda>)rQ   rÄ   r   r7   r:   r*   r*   r+   Útest_net_connections¥  s    z-TestModuleFunctionsLeaks.test_net_connectionsc                 C   s"   t rdn| j}| jtj|d� d S )Ni @ )Ú	tolerance)r   rÆ   r7   rQ   Znet_if_addrs)r$   rÆ   r*   r*   r+   Útest_net_if_addrs­  s    z*TestModuleFunctionsLeaks.test_net_if_addrsc                 C   s   |   tj¡ d S r    )r7   rQ   Znet_if_statsr:   r*   r*   r+   Útest_net_if_stats²  s    z*TestModuleFunctionsLeaks.test_net_if_statsc                 C   s   |   tj¡ d S r    )r7   rQ   Zsensors_batteryr:   r*   r*   r+   Útest_sensors_battery·  s    z-TestModuleFunctionsLeaks.test_sensors_batteryc                 C   s   |   tj¡ d S r    )r7   rQ   Zsensors_temperaturesr:   r*   r*   r+   Útest_sensors_temperatures¼  s    z2TestModuleFunctionsLeaks.test_sensors_temperaturesc                 C   s   |   tj¡ d S r    )r7   rQ   Zsensors_fansr:   r*   r*   r+   Útest_sensors_fansÁ  s    z*TestModuleFunctionsLeaks.test_sensors_fansc                 C   s   |   tj¡ d S r    )r7   rQ   Z	boot_timer:   r*   r*   r+   Útest_boot_timeÈ  s    z'TestModuleFunctionsLeaks.test_boot_timec                 C   s   |   tj¡ d S r    )r7   rQ   Zusersr:   r*   r*   r+   Ú
test_usersÌ  s    z#TestModuleFunctionsLeaks.test_usersc                 C   s   |   dd„ ¡ d S )Nc                   S   s
   t  d¡S )NF)rQ   Z
_set_debugr*   r*   r*   r+   rH   Ð  rI   z9TestModuleFunctionsLeaks.test_set_debug.<locals>.<lambda>r�   r:   r*   r*   r+   Útest_set_debugÏ  s    z'TestModuleFunctionsLeaks.test_set_debugc                 C   s   |   tj¡ d S r    )r7   rT   Zwinservice_enumerater:   r*   r*   r+   Útest_win_service_iterÖ  s    z.TestModuleFunctionsLeaks.test_win_service_iterc                 C   s   d S r    r*   r:   r*   r*   r+   Útest_win_service_getÙ  s    z-TestModuleFunctionsLeaks.test_win_service_getc                    s&   t t ¡ ƒ ¡ ‰ |  ‡ fdd„¡ d S )Nc                      s
   t  ˆ ¡S r    )rT   Zwinservice_query_configr*   ©r9   r*   r+   rH   Þ  rI   zFTestModuleFunctionsLeaks.test_win_service_get_config.<locals>.<lambda>©ÚnextrQ   Zwin_service_iterr9   r7   r:   r*   rÑ   r+   Útest_win_service_get_configÜ  s    z4TestModuleFunctionsLeaks.test_win_service_get_configc                    s&   t t ¡ ƒ ¡ ‰ |  ‡ fdd„¡ d S )Nc                      s
   t  ˆ ¡S r    )rT   Zwinservice_query_statusr*   rÑ   r*   r+   rH   â  rI   zFTestModuleFunctionsLeaks.test_win_service_get_status.<locals>.<lambda>rÒ   r:   r*   rÑ   r+   Útest_win_service_get_statusà  s    z4TestModuleFunctionsLeaks.test_win_service_get_statusc                    s&   t t ¡ ƒ ¡ ‰ |  ‡ fdd„¡ d S )Nc                      s
   t  ˆ ¡S r    )rT   Zwinservice_query_descrr*   rÑ   r*   r+   rH   æ  rI   zKTestModuleFunctionsLeaks.test_win_service_get_description.<locals>.<lambda>rÒ   r:   r*   rÑ   r+   Ú test_win_service_get_descriptionä  s    z9TestModuleFunctionsLeaks.test_win_service_get_descriptionN)4r�   r�   r‘   r’   r6   r0   r¯   r°   rh   r±   r²   r“   r”   r   ÚplatformÚmachiner   r´   r   r¶   r·   r   r¸   rº   r½   r¾   r   rU   ÚpathÚexistsrÀ   rÁ   r   rÂ   ÚgetuidrÅ   rÇ   rÈ   r   rÉ   r   rÊ   r   rË   rÌ   rÍ   rÎ   rÏ   rÐ   rÔ   rÕ   rÖ   r*   r*   r*   r+   r«   Q  sx   




ÿ


ÿ

r«   Ú__main__)Úrun_from_name)6r’   Ú
__future__r   r-   rU   r×   r“   rQ   Zpsutil._commonr   r   r   r   r   r   Zpsutil._compatr	   r
   Zpsutil.testsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z_psplatformrT   r\   rJ   r#   r0   r1   r•   r”   r¦   r«   r�   Zpsutil.tests.runnerrÝ   Ú__file__r*   r*   r*   r+   Ú<module>   sb   
 76 
