Your IP : 3.147.67.237


Current Path : /lib64/python3.6/site-packages/psutil/tests/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/psutil/tests/__pycache__/test_system.cpython-36.pyc

3

��JZ/��@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'ddlm(Z(ddlm)Z)ddlm*Z*ddlm+Z+dd lm,Z,dd!lm-Z-Gd"d#�d#e-j.�Z/e0d$k�r�e(e1�dS)%zTests for system APIS.�N)�AIX)�BSD)�FREEBSD)�LINUX)�NETBSD)�OPENBSD)�OSX)�POSIX)�SUNOS)�WINDOWS)�long)�APPVEYOR)�ASCII_FS)�check_net_address)�DEVNULL)�enum)�get_test_subprocess)�HAS_BATTERY)�HAS_CPU_FREQ)�HAS_SENSORS_BATTERY)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�mock)�
reap_children)�retry_before_failing)�run_test_module_by_name)�safe_rmpath)�TESTFN)�TESTFN_UNICODE)�TRAVIS)�unittestc@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
eje
d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z d7d8�Z!d9d:�Z"d;d<�Z#d=d>�Z$d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)eje*dI�dJdK��Z+eje,�o\e-j.j/dL�dM�eje0�ote1j2�dNkdO�dPdQ���Z3dRdS�Z4eje0�p�e*�o�e1j5�dT�dUdV��Z6dWdX�Z7eje8dY�dZd[��Z9d\d]�Z:eje;d^�d_d`��Z<eje;d^�dadb��Z=eje>d^�eje?dc�ddde���Z@ejeAd^�dfdg��ZBdNS)h�TestSystemAPIszTests for system-related APIs.cCstt�dS)N)rr)�self�r#�#/usr/lib64/python3.6/test_system.py�setUp>szTestSystemAPIs.setUpcCs
t�dS)N)r)r"r#r#r$�tearDownAszTestSystemAPIs.tearDowncCs�|jtj�dd�tj�D��t�}|j|jdd�tj�D��tj|j�}|j�|j	�|j
|jdd�tj�D��tjdtj
tj��d��|jttj��g�WdQRXtjdtjtj��d��*|jtj��ttj��WdQRXWdQRXdS)NcSsg|]
}|j�qSr#)�pid)�.0�xr#r#r$�
<listcomp>Esz4TestSystemAPIs.test_process_iter.<locals>.<listcomp>cSsg|]
}|j�qSr#)r')r(r)r#r#r$r*GscSsg|]
}|j�qSr#)r')r(r)r#r#r$r*Kszpsutil.Process)�side_effect)�assertIn�os�getpid�psutil�process_iterrr'�Process�kill�wait�assertNotInr�patchZ
NoSuchProcess�assertEqual�list�AccessDenied�assertRaises)r"�sproc�pr#r#r$�test_process_iterDsz TestSystemAPIs.test_process_itercCs8x.tjdgd�D]}|jt|jj��dg�qW|jt��ttjdgd��WdQRXtj	dtj
dd�d��L}x:tjddgd�D]&}|j|jd�|j|jdd�q�W|j
s�t�WdQRXtj	dtj
dd�d��X}t�}x>tjddg|d	�D](}|j|jd|�|j|jdd�q�W|j
�s*t�WdQRXdS)
Nr')�attrsZfooz$psutil._psplatform.Process.cpu_timesr�)r+�	cpu_times)r=Zad_value)r/r0r6r7�info�keysr9�
ValueErrorrr5r8�assertIsNone�assertGreaterEqual�called�AssertionError�object�assertIs)r"r;�m�flagr#r#r$�test_prcess_iter_w_paramsUs$z(TestSystemAPIs.test_prcess_iter_w_paramscs��fdd�}g�t�}t�}t�}dd�|||fD�}�jttj|dd��jttj|dd�tj�}tj|d|d	�\}}�jtj�|d
��j|g��jt	|�d��j�g�x|D]}	�j
t|	d��q�Wtd
��fdd��}
|j
�|
||�\}}�j|jdd�|D��t�r4�j|j�jtj�n�j|j�jd��j�|jg�x|D]}	�j
t|	d���q\Wtd
��fdd��}
|j
�|j
�|
||�\}}�jt��t|j|j|jg��x|D]}	�jt|	d���q�WdS)Ncs�j|j�dS)N)�appendr')r;)�pidsr#r$�callbackjsz0TestSystemAPIs.test_wait_procs.<locals>.callbackcSsg|]}tj|j��qSr#)r/r1r')r(r)r#r#r$r*qsz2TestSystemAPIs.test_wait_procs.<locals>.<listcomp>�)�timeout)rNg{�G�z�?)rPrNg�?��
returncode�cs<tj|d|d�\}}�jt|�d��jt|�d�||fS)Ng���Q��?)rPrNrO�)r/�
wait_procsr6�len)�procsrN�gone�alive)r"r#r$�test~s
z,TestSystemAPIs.test_wait_procs.<locals>.testcSsg|]
}|j�qSr#)r')r(r)r#r#r$r*�scs<tj|d|d�\}}�jt|�d��jt|�d�||fS)Ng���Q��?)rPrNrQr)r/rUr6rV)rWrNrXrY)r"r#r$rZ�s
���)rr9rBr/rU�	TypeError�time�
assertLessr6rV�assertFalse�hasattrr�	terminater,r'r	�poprR�signal�SIGTERM�set�
assertTrue)r"rN�sproc1�sproc2�sproc3rW�trXrYr;rZr#)rMr"r$�test_wait_procsisB

 
zTestSystemAPIs.test_wait_procscCsNt�}t�}t�}dd�|||fD�}x|D]}|j�q,Wtj|�\}}dS)NcSsg|]}tj|j��qSr#)r/r1r')r(r)r#r#r$r*�sz=TestSystemAPIs.test_wait_procs_no_timeout.<locals>.<listcomp>)rrar/rU)r"rgrhrirWr;rXrYr#r#r$�test_wait_procs_no_timeout�s
z)TestSystemAPIs.test_wait_procs_no_timeoutcCs4tj�}|j|t�|j|d�|j|tj��dS)Nr)r/Z	boot_time�assertIsInstance�float�
assertGreaterr^r])r"Zbtr#r#r$�test_boot_time�szTestSystemAPIs.test_boot_timez
POSIX onlycCs"ddl}|jtjd�|j��dS)Nr�SC_PAGE_SIZE)�resourcer6r-�sysconfZgetpagesize)r"rrr#r#r$�
test_PAGESIZE�szTestSystemAPIs.test_PAGESIZEcCs�tj�}|jdkst|��|jdks,t|��d|jko@dknsNt|��|jdks`t|��|jdksrt|��xt|jD]j}t	||�}|dkr�|j
|ttf�|dkrz|dks�|j
d||f�||jkrz|j
d||j||f�qzWdS)Nr�d�percent�totalz%r < 0 (%s)z%r > total (total=%s, %s=%s))r/Zvirtual_memoryrwrFZ	availablerv�used�free�_fields�getattrrm�intr�fail)r"�mem�name�valuer#r#r$�test_virtual_memory�s "

z"TestSystemAPIs.test_virtual_memorycCs�tj�}|j|jd	�|jdks(t|��|jdks:t|��|jdkrX|jdksjt|��n|jdksjt|��d|jko~dkns�t|��|j	dks�t|��|j
dks�t|��dS)
Nrwrxryrv�sin�soutrru)rwrxryrvr�r�)r/Zswap_memoryr6rzrwrFrxryrvr�r�)r"r~r#r#r$�test_swap_memory�s

"zTestSystemAPIs.test_swap_memorycCstt�}|jtj|j��tj|j�}|j�|j�|jtj|j��|jtjd��|j	tjd�dtj
�k�dS)NrOrr[)rrfr/�
pid_existsr'r1r2r3r_r6rM)r"r:r;r#r#r$�test_pid_exists�szTestSystemAPIs.test_pid_existscCs�t�tj�}xT|D]L}ytj|�s(t�Wqtk
r^tjd�|tj�krZ|j|�YqXqWtt	|�dt	|�d�}x |D]}|j
tj|�|d�q�WdS)Ng�������?i�ip)�msg)rr/rMr�rFr]�sleepr}�range�maxr_)r"rMr'r#r#r$�test_pid_exists_2�s


z TestSystemAPIs.test_pid_exists_2cCsJdd�tj�D�}tj�}|j|j�|j��|jt|�tt|���dS)NcSsg|]
}|j�qSr#)r')r(r)r#r#r$r*�sz,TestSystemAPIs.test_pids.<locals>.<listcomp>)r/r0rMr6�sortrVre)r"ZplistZpidlistr#r#r$�	test_pids�szTestSystemAPIs.test_pidscCs&tj}tt_ztj�Wd|t_XdS)N)�sys�stdoutrr/rZ)r"r�r#r#r$�	test_test�s
zTestSystemAPIs.test_testc
Cs�tj�}|j|ttjdd���|j|d�tjjd�rft	d��}|j
�}WdQRXd|krftjd��tjdd�}|j|d�|j||�dS)	NT)�percpurOz
/proc/cpuinfozphysical idz#cpuinfo doesn't include physical idF)�logical)
r/�	cpu_countr6rVr?rDr-�path�exists�open�readr ZSkipTest)r"r��fdZcpuinfo_dataZphysicalr#r#r$�test_cpu_counts

zTestSystemAPIs.test_cpu_countcCszxtd	D]l}tjd|d��}|jtj��|js2t�WdQRXtjd|d��"}|jtjdd��|jsht�WdQRXqWdS)
NrOrz$psutil._psplatform.cpu_count_logical)�return_valuez%psutil._psplatform.cpu_count_physicalF)r�r[)r[rN)rr5rCr/r�rErF)r"�valrIr#r#r$�test_cpu_count_nones


z"TestSystemAPIs.test_cpu_count_nonecCs^d}tj�}t|�x,|D]$}|j|t�|j|d�||7}qW|j|t|��t|�dS)Nrg)r/r?�sumrmrnrDr6�str)r"rw�times�cp_timer#r#r$�test_cpu_timess
zTestSystemAPIs.test_cpu_timescCsDttj��}tjd�ttj��}||}|dks@|jd|�dS)Ng�������?g�������?z
difference %s)r�r/r?r]r�r})r"�t1�t2�
differencer#r#r$�test_cpu_times_time_increases:s
z,TestSystemAPIs.test_cpu_times_time_increasescCs�xftjdd�D]V}d}t|�x,|D]$}|j|t�|j|d�||7}q$W|j|t|��t|�qW|jttjdd�d�ttjdd���dS)NT)r�rgF)	r/r?r�rmrnrDr6r�rV)r"r�rwr�r#r#r$�test_per_cpu_timesCs
z!TestSystemAPIs.test_per_cpu_timescCs�tjdd�}tj�d}xtj�|krPqWtjdd�}x<t||�D].\}}t|�t|�}}||}|dkrDdSqDW|j�dS)NT)r�g�������?g�������?)r/r?r]�zipr�r})r"Ztot1Zstop_atZtot2r�r�r�r#r#r$�test_per_cpu_times_2dsz#TestSystemAPIs.test_per_cpu_times_2cCs\tj�}tjdd�}|jdd�t|�D��}x*|jD] }|jt||�t||�dd�q4WdS)NT)r�cSsg|]}t|��qSr#)r�)r(Znumr#r#r$r*ysz<TestSystemAPIs.test_cpu_times_comparison.<locals>.<listcomp>rO)�delta)r/r?�_maker�rz�assertAlmostEqualr{)r"�baseZper_cpuZ
summed_valuesZfieldr#r#r$�test_cpu_times_comparisontsz(TestSystemAPIs.test_cpu_times_comparisoncCs�y<|j|t�|j|d�|j|d�|j|dtj��Wn@tk
r|}z$td|tj	|�tj	|�f��WYdd}~XnXdS)NggY@z
%s
last=%s
new=%sg�)
rmrnrDZassertIsNot�assertLessEqualr/r�rF�pprintZpformat)r"rvZlast_retZnew_ret�errr#r#r$�_test_cpu_percent~sz TestSystemAPIs._test_cpu_percentc
Csbtjdd�}x.td�D]"}tjdd�}|j|||�|}qW|jt��tjdd�WdQRXdS)Ng����MbP?)�intervalrurOr[)r/�cpu_percentr�r�r9rB)r"�lastr)�newr#r#r$�test_cpu_percent�szTestSystemAPIs.test_cpu_percentcCs�tjddd�}|jt|�tj��x>td�D]2}tjddd�}x|D]}|j|||�qDW|}q,W|jt��tjddd�WdQRXdS)Ng����MbP?T)r�r�rurOr[)	r/r�r6rVr�r�r�r9rB)r"r�r)r�rvr#r#r$�test_per_cpu_percent�s
z#TestSystemAPIs.test_per_cpu_percentcCs`tjdd�}xNtd�D]B}tjdd�}x|D]}|j|||�q,W|jt|�||�|}qWdS)Ng����MbP?)r�ru)r/�cpu_times_percentr�r�r�)r"r�r)r�rvr#r#r$�test_cpu_times_percent�s
z%TestSystemAPIs.test_cpu_times_percentcCs�tjddd�}|jt|�tj��x^td�D]R}tjddd�}x:|D]2}x|D]}|j|||�qNW|jt|�||�qDW|}q,WdS)Ng����MbP?T)r�r�ru)r/r�r6rVr�r�r�r�)r"r�r)r��cpurvr#r#r$�test_per_cpu_times_percent�s

z)TestSystemAPIs.test_per_cpu_times_percentc
Csrtjdd�dd�tjdd�D�}tjd|d��8x0tjdd�D] }x|D]}|j|dd�qJWq@WWdQRXdS)NT)r�cSs*g|]"}|jdd�tt|j��D���qS)cSsg|]}d�qS)rr#)r(r)r#r#r$r*�szQTestSystemAPIs.test_per_cpu_times_percent_negative.<locals>.<listcomp>.<listcomp>)r�r�rVrz)r(r)r#r#r$r*�szFTestSystemAPIs.test_per_cpu_times_percent_negative.<locals>.<listcomp>zpsutil.cpu_times)r�)r/r�r?rr5r�)r"Z
zero_timesr�rvr#r#r$�#test_per_cpu_times_percent_negative�s
z2TestSystemAPIs.test_per_cpu_times_percent_negativec
Cs2tjtj��}|j|jd�|jdks.t|��|jdks@t|��|j	dksRt|��|j|jksft|��|j|j	kszt|��d|j
ko�dkns�t|j
��ttd��r�tjtj��}d
}|j|j|j�|j
|j	|j	|d
�|j
|j|j|d
�tj�}|jt��}tj|�WdQRX|j|jjtj�dS)Nrwrxryrvrru�
disk_usage�i)r�)rwrxryrviiP)r/r�r-�getcwdr6rzrwrFrxryrvr`�shutilr��tempfileZmktempr9�OSErrorZ	exception�errno�ENOENT)r"ZusageZshutil_usageZ	toleranceZfname�excr#r#r$�test_disk_usage�s($zTestSystemAPIs.test_disk_usagec	Cs(tr$|jt��tjt�WdQRXdS)N)rr9�UnicodeEncodeErrorr/r�r)r"r#r#r$�test_disk_usage_unicode�sz&TestSystemAPIs.test_disk_usage_unicodecCstjd�dS)N�.)r/r�)r"r#r#r$�test_disk_usage_bytes�sz$TestSystemAPIs.test_disk_usage_bytescCstjdd�}|j||d�x�|D]�}|j|jt�|j|jt�|j|jt�|j|jt�t	rld|jkrlq t
s�tjj
|j�s�t|��n|jts�tr�tjj
|j�s�t|��ntjj|j�s�t|��|js t|��q Wtjdd�}|j||d�x�tjdd�D]�}t	�s�ytj|j�WnXtk
�rp}z:t�rJt�rJ|jtjk�rJ�w�|jtjtjfk�r`�WYdd}~Xn@Xt�s~t�r�tjj
|j��s�t|��ntjj|j��s�t|��|j|jt�|j|jt��q�Wdd�}|t�}dd	�tjdd�D�}|j||�tj|�dS)
NF)�all)r�ZcdromTcSs2tjj|�}xtjj|�s(tjj|�}qW|j�S)N)r-r��abspath�ismount�dirname�lower)r�r#r#r$�find_mount_pointsz=TestSystemAPIs.test_disk_partitions.<locals>.find_mount_pointcSsg|]}|jj��qSr#)�
mountpointr�)r(r)r#r#r$r*sz7TestSystemAPIs.test_disk_partitions.<locals>.<listcomp>)r/Zdisk_partitionsrfrmZdevicer�r�ZfstypeZoptsrr	r-r�r�rFr
r�isdir�statr�rr�ZEIOZEPERMZEACCES�__file__r,r�)r"�lsZdiskr�r�ZmountZmountsr#r#r$�test_disk_partitions�sL
z#TestSystemAPIs.test_disk_partitionscsl�fdd�}tjdd�}||�tjdd�}�j|g�x.|D]&}�j|��j|t�|||�q>WdS)Ncs(�j|d|j��j|d|j��j|d|j��j|d|j��j|d|j��j|d|j��j|d|j��j|d|j�|jdks�t	|��|jdks�t	|��|jdks�t	|��|jdks�t	|��|jdks�t	|��|jdks�t	|��|jdk�st	|��|jdk�s$t	|��dS)	NrrOrTrQ�r���)
r6Z
bytes_sentZ
bytes_recvZpackets_sentZpackets_recvZerrinZerroutZdropinZdropoutrF)�nt)r"r#r$�check_ntuples z9TestSystemAPIs.test_net_io_counters.<locals>.check_ntupleF)�pernicT)r/�net_io_counters�assertNotEqualrfrmr�)r"r��ret�keyr#)r"r$�test_net_io_counterss

z#TestSystemAPIs.test_net_io_counterscCsNtjdid��6}|jtjdd��|jtjdd�i�|js@t�WdQRXdS)Nz"psutil._psplatform.net_io_counters)r�F)r�T)rr5rCr/r�r6rErF)r"rIr#r#r$�test_net_io_counters_no_nics8s

z+TestSystemAPIs.test_net_io_counters_no_nicsc
Csttj�}|st|��tj�}ttjtjtjg�}�x�|j	�D�]�\}}|j
|t�|jt
t|��t
|���x�|D�]�}|j
|jt�|j
|jt�|j
|jttd�f�|j
|jttd�f�|j|j|�tjdkr�|j
|jtj�||j�r�|jtjk�r6tj|j�}tj|��|j|jdf�WdQRXnj|jtjk�r�tj|jdtjtjdtj�d}|\}	}
}}}
tj|	|
|�}tj|��|j|
�WdQRXxB|j|j|j|j fD]*}|dk	�r�|jtjk�r�t!||j��q�W|j�r�|j"|j �qr|j rr|j"|j�qrWq<Wt#�s&t$�s&t%�rDt&td��rp|jtjtj�n,t'�r\|jtjtj(�nt)�rp|jtjd�dS)NrQr�r�AF_LINKrO)rQr�r[)*r/�net_if_addrsrF�net_if_statsre�socketZAF_INETZAF_INET6r��itemsrmr�r6rVZfamilyr|�addressZnetmask�typeZ	broadcastr,r��version_infor�IntEnum�isup�
contextlib�closingZbindZgetaddrinfoZSOCK_STREAMZ
AI_PASSIVEZptprrCrrr
r`rZ	AF_PACKETr)r"�nicsZ	nic_statsZfamiliesZnicZaddrs�addr�sr@ZafZsocktype�protoZ	canonnameZsaZipr#r#r$�test_net_if_addrsAsX


z TestSystemAPIs.test_net_if_addrsc
Csztrdtjddddfg}ndg}tjd|d��B}tj�dd}|jsJt�tr^|j|j	d�n|j|j	d	�WdQRXdS)N�em1z06:3d:29rO�06-3d-29zpsutil._psplatform.net_if_addrs)r�rz06:3d:29:00:00:00z06-3d-29-00-00-00r[)r�r[r�NNN)
r	r/r�rr5r�rErFr6r�)r"r�rIr�r#r#r$� test_net_if_addrs_mac_null_bytes}s

z/TestSystemAPIs.test_net_if_addrs_mac_null_byteszunreliable on TRAVISc	Cs�tj�}|st|��tjtjtjf}xh|j�D]\\}}|j|t�|\}}}}|j|t	�|j
||�|j
||�|j|d�|j|d�q.WdS)Nr)r/r�rFZNIC_DUPLEX_FULLZNIC_DUPLEX_HALFZNIC_DUPLEX_UNKNOWNr�rmr��boolr,rD)	r"r�Zall_duplexesrZstatsr�ZduplexZspeedZmtur#r#r$�test_net_if_stats�sz TestSystemAPIs.test_net_if_statsz/proc/diskstatsz3/proc/diskstats not available on this linux versionNzunreliable on APPVEYORcs��fdd�}tjdd�}|dk	s(td��||�tjdd�}�jt|�tt|���xb|D]Z}|sjt|��|||�trZ|dj�rZx|d	j�r�|dd
�}q�W�j||j	��qZWdS)Ncs��j|d|j��j|d|j��j|d|j��j|d|j�tpNtsƈj|d|j��j|d|j�t	r��j|d|j
��j|d|j��j|d	|j�nt
rƈj|d|j�x$|jD]}t||�dks�t|��q�WdS)
NrrOrTrQr�r�r�r��)r6Z
read_countZwrite_countZ
read_bytesZwrite_bytesrrZ	read_timeZ
write_timerZread_merged_countZwrite_merged_countZ	busy_timerrzr{rF)r�r)r"r#r$r��sz:TestSystemAPIs.test_disk_io_counters.<locals>.check_ntupleF)�perdiskzno disks on this system?TrOr[r[r[)
r/�disk_io_countersrFr6rVrer�isdigitr4rA)r"r�r�r�r#)r"r$�test_disk_io_counters�s
z$TestSystemAPIs.test_disk_io_counterscCsNtjdid��6}|jtjdd��|jtjdd�i�|js@t�WdQRXdS)Nz#psutil._psplatform.disk_io_counters)r�F)r�T)rr5rCr/r�r6rErF)r"rIr#r#r$�test_disk_io_counters_no_disks�s

z-TestSystemAPIs.test_disk_io_counters_no_disksz unreliable on APPVEYOR or TRAVIScCs�tj�}|j|g�x�|D]�}|js,t|��|j|jt�|j|jttd�f�|j	dk	rp|j|j	ttd�f�|j|j	|j
dks�t|��tjj|j
�t
s�tr�|j|j�qtj|j�qWdS)Ng)r/�usersr�rrFrmr�Zterminalr��hostZstarted�datetimeZ
fromtimestamprrrCr'r1)r"r��userr#r#r$�
test_users�s

zTestSystemAPIs.test_userscCsZtj�}|j|jd�x>|jD]4}t||�}|j|d�tr|dkr|j|d�qWdS)N�ctx_switches�
interrupts�soft_interrupts�syscallsr)rrrr)rr)r/Z	cpu_statsr6rzr{rDrro)r"Zinfosrr�r#r#r$�test_cpu_stats�s
zTestSystemAPIs.test_cpu_statsznot suportedcs`�fdd�}tjdd�}tr&|r&dS|s2t|��|tjdd�g�tr\�jt|�tj��dS)Ncshxb|D]Z}�j|jd��j|j|j�x6|jD],}t||�}�j|ttt	f��j
|d�q0WqWdS)N�current�minr�r)r	r
r�)r6rzr�r	r�r{rmr|rrnrD)r�r�rr�)r"r#r$�check_ls�s

z.TestSystemAPIs.test_cpu_freq.<locals>.check_lsT)r�F)r/Zcpu_freqrrFrr6rVr�)r"rr�r#)r"r$�
test_cpu_freq�s	
zTestSystemAPIs.test_cpu_freqc	Cs�ddddddddd	g	}x"|D]}|jtt|�t|d
�qWtjdk�rJtjsPt�tjs\t�|j	d�dt
jj�kr�tj
s~t�|j	d�n�d
t
jj�kr�tjs�t�|jtjtjtjgjd�d�|j	d�|j	d�|j	d�|j	d�n^dt
jj�k�s
dt
jj�k�r"tj�st�|j	d	�n&dt
jj�k�rntj�s>t�|j	d�n$tj�sVt�tj�sdt�|j	d�x$|D]}|jtt|�d|d
��qtWdS)Nr	rrrrrrrr
)r��posix�linuxZbsdTrO�sunos�solaris�darwinF)rmr{r/r�r-rr	rFr�remover��platformr�rrr6rrr�countr
rrH)r"�namesrr#r#r$�test_os_constantss>










z TestSystemAPIs.test_os_constantsz
not supportedcCs�tj�}x�|j�D]x\}}|j|t�xb|D]Z}|j|jt�|jdk	rV|j|jd�|jdk	rn|j|jd�|j	dk	r,|j|j	d�q,WqWdS)Nr)
r/�sensors_temperaturesr�rmr��labelr	rD�high�critical)r"�tempsr�entries�entryr#r#r$�test_sensors_temperatures)s



z(TestSystemAPIs.test_sensors_temperaturesc
Cspddgi}tjd|d��N}tjdd	�dd
}|js8t�|j|jd�|j|jd�|j|j	d
�WdQRXdS)NZcoretempr�I@�N@��Q@z'psutil._psplatform.sensors_temperatures)r�T)Z
fahrenheitrg�^@g�a@g�c@)rrr r!)
rr5r/rrErFr6r	rr)r"�drIrr#r#r$�#test_sensors_temperatures_fahreneit7s


z2TestSystemAPIs.test_sensors_temperatures_fahreneitz
no batterycCsptj�}|j|jd�|j|jd�|jtjtjfkrF|j|jd�n|jtjkr^|j|j	�|j
|j	t�dS)Nrru)r/Zsensors_batteryrDrvr�ZsecsleftZPOWER_TIME_UNKNOWNZPOWER_TIME_UNLIMITEDrfZ
power_pluggedrmr�)r"r�r#r#r$�test_sensors_batteryCs
z#TestSystemAPIs.test_sensors_batterycCsjtj�}x\|j�D]P\}}|j|t�x:|D]2}|j|jt�|j|jttf�|j	|jd�q,WqWdS)Nr)
r/Zsensors_fansr�rmr�rr	r|rrD)r"Zfansrrrr#r#r$�test_sensors_fansQs
z TestSystemAPIs.test_sensors_fans)C�__name__�
__module__�__qualname__�__doc__r%r&r<rKrkrlrpr ZskipIfr	rtr�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�rr�rr-r�r�r
r/r�r�r�r�rrrrrrrr#rrr$rr%r#r#r#r$r!;sh7	
		!

		
>	<#

%
r!�__main__)2r)r�rr�r-r�r�rcr�r�r�r]r/rrrrrrrr	r
rZpsutil._compatrZpsutil.testsr
rrrrrrrrrrrrrrrrrrr ZTestCaser!r&r�r#r#r#r$�<module>sh'


?>