Your IP : 18.117.184.125


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

3

��JZK�@s`dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlm
Z
ddlmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZej��Zejd�y$ddlZddlZddlZddlZWn$e k
�rDej!dk�r@�YnXWdQRXej"j#Z#e	j$d$kZ%dd�Z&ej'e
d�Gdd�dej(��Z)ej'e
d�Gdd�dej(��Z*ej'e
d�Gdd�dej(��Z+ej'e
d�Gdd�dej(��Z,ej'e
d�Gdd�dej(��Z-ej'e
d�Gdd �d ej(��Z.ej'e
d�Gd!d"�d"ej(��Z/e0d#k�r\ee1�dS)%zWindows specific tests.�N)�WINDOWS)�callable)�APPVEYOR)�get_test_subprocess)�HAS_BATTERY)�mock)�
reap_children)�retry_before_failing)�run_test_module_by_name)�sh)�unittest�ignore�nt�� cs�fdd�}|S)Ncsty�|f|�|�Stk
rn}zBddlm}|j|krDtjdd��|jtjkr\tjdd���WYdd}~XnXdS)Nr)�ACCESS_DENIED_SET)�OSErrorZpsutil._pswindowsr�errno�psutil�AccessDeniedZESRCH�
NoSuchProcess)�self�args�kwargs�errr)�fun��$/usr/lib64/python3.6/test_windows.py�wrapper5s
z wrap_exceptions.<locals>.wrapperr)rrr)rr�wrap_exceptions4s
rzWINDOWS onlyc@s�eZdZdd�Zejdejkd�dd��Zdd�Z	d	d
�Z
dd�Zejed
�e
�dd���Ze
�dd��Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TestSystemAPIscCsVtd�}tjdd�j�}x8|D]0}d|jdd�j�kr8q||kr|jd|�qWdS)Nz
ipconfig /allT)Zperniczpseudo-interface� �-z-%r nic wasn't found in 'ipconfig /all' output)rrZnet_io_counters�keys�replace�lower�fail)r�outZnicsZnicrrr�test_nic_namesJs
zTestSystemAPIs.test_nic_names�NUMBER_OF_PROCESSORSz-NUMBER_OF_PROCESSORS env var is not availablecCs"ttjd�}|j|tj��dS)Nr))�int�os�environ�assertEqualr�	cpu_count)rZnum_cpusrrr�test_cpu_countTszTestSystemAPIs.test_cpu_countcCs$tj�d}tj�}|j||�dS)N�)�win32apiZ
GetSystemInforr.r-)r�	sys_value�psutil_valuerrr�test_cpu_count_2ZszTestSystemAPIs.test_cpu_count_2cCs@tj�}|j�d}|j|jtj�j�|j|jtj�j	�dS)Nr)
�wmi�WMIZWin32_Processorr-ZCurrentClockSpeedrZcpu_freqZcurrentZ
MaxClockSpeed�max)r�w�procrrr�
test_cpu_freq_szTestSystemAPIs.test_cpu_freqcCs,tj�j�d}|jt|j�tj�j�dS)Nr)	r5r6ZWin32_ComputerSystemr-r*ZTotalPhysicalMemoryrZvirtual_memory�total)rr8rrr�test_total_phymemesz TestSystemAPIs.test_total_phymemztest not relieable on appveyorcCs:tj�j�}tdd�|D��}ttj��}|j||�dS)NcSsg|]
}|j�qSr)�	ProcessId)�.0�xrrr�
<listcomp>|sz,TestSystemAPIs.test_pids.<locals>.<listcomp>)r5r6�
Win32_Process�setrZpidsr-)rr8Zwmi_pidsZpsutil_pidsrrr�	test_pidsvszTestSystemAPIs.test_pidscCstjdd�}tj�j�}x�|D]�}x�|D]�}|jjdd�|jkr(|jsHPytj	|j�}Wn4t
k
r�}z|jtjkrzPn�WYdd}~XnX|j
|jt|j��t|j�}|j
|j|�t|j|�d
kr�|jd|j|f�Pq(W|jdt|��qWdS)NT)�all�\��
izpsutil=%s, wmi=%szcan't find partition %si(i�)r�disk_partitionsr5r6ZWin32_LogicalDiskZdevicer$ZDeviceID�
mountpoint�
disk_usagerr�ENOENTr-r;r*ZSizeZ	FreeSpace�free�absr&�repr)rZps_partsZ	wmi_partsZps_partZwmi_partZusagerZwmi_freerrr�
test_disks�s*


zTestSystemAPIs.test_diskscCspxjtj�D]^}tj|j�}tj|j�}|j|d|jdd�|j|d|jdd�|j	|j
|j|j�q
WdS)Nri)�delta�ii)rrHr1ZGetDiskFreeSpaceExrIrJ�assertAlmostEqualrLr;r-Zused)rZdiskr2r3rrr�test_disk_usage�szTestSystemAPIs.test_disk_usagecCs>dd�tj�jd�D�}dd�tjdd�D�}|j||�dS)NcSs$g|]}|r|jd�r|d�qS)zA:rE)�
startswith)r>r?rrrr@�sz7TestSystemAPIs.test_disk_partitions.<locals>.<listcomp>z\cSsg|]
}|j�qSr)rI)r>r?rrrr@�sT)rD)r1ZGetLogicalDriveStrings�splitrrHr-)rr2r3rrr�test_disk_partitions�sz#TestSystemAPIs.test_disk_partitionscCs`ttj��}tj�j�}t�}x$|D]}|j|j�|j|j�q$W|j	||@d||f�dS)Nzno common entries in %s, %s)
rB�cextZnet_if_statsr5r6ZWin32_NetworkAdapter�add�NameZNetConnectionID�
assertTrue)rZps_namesZwmi_adaptersZ	wmi_namesZwmi_adapterrrr�test_net_if_stats�s

z TestSystemAPIs.test_net_if_statscCs^tj�j�}|djjd�d}tjj|d�}tjjtj	��}t
||j��}|j|d�dS)Nr�.z%Y%m%d%H%M%S�)
r5r6ZWin32_OperatingSystemZLastBootUpTimerU�datetimeZstrptimeZ
fromtimestampr�	boot_timerMZ
total_secondsZassertLessEqual)rZwmi_osZ
wmi_btime_strZwmi_btime_dtZ	psutil_dtZdiffrrr�test_boot_time�szTestSystemAPIs.test_boot_timecCs�tjddd��|jtj�d�WdQRXtjddd��|jtj�d�WdQRXtjddd��|jtj�d�WdQRXtjddd��|jtj�d�WdQRXdS)Nz psutil._pswindows.cext.boot_timer0)�return_value��iM)r�patchr-rr_)rrrr�test_boot_time_fluctuation�sz)TestSystemAPIs.test_boot_time_fluctuationN)�__name__�
__module__�__qualname__r(r�skipIfr+r,r/r4r:r<rr	rCrOrSrVr[r`rerrrrr Gs

	

r c@s`eZdZdd�Zejed�dd��Zejed�dd��Zdd	�Z	d
d�Z
dd
�Zdd�ZdS)�TestSensorsBatterycCs.tj�dr|jtj��n|jtj��dS)NZSystemBatteriesPresent)r1ZGetPwrCapabilitiesZassertIsNotNoner�sensors_battery�assertIsNone)rrrr�test_has_battery�sz#TestSensorsBattery.test_has_batteryz
no batterycCs6tj�}|jd�d}tj�}|j|j|jdd�dS)Nzselect * from Win32_BatteryrrQ)rP)r5r6�queryrrkrRZpercentZEstimatedChargeRemaining)rr8�battery_wmi�battery_psutilrrr�test_percent�szTestSensorsBattery.test_percentcCs6tj�}|jd�d}tj�}|j|j|jdk�dS)Nzselect * from Win32_Batteryrr)r5r6rnrrkr-Z
power_pluggedZ
BatteryStatus)rr8rorprrr�test_power_plugged�s
z%TestSensorsBattery.test_power_pluggedc	Cs6tjddd��}|jtj��|js(t�WdQRXdS)Nz&psutil._pswindows.cext.sensors_batteryr�)ra)rrsrr)rrdrlrrk�called�AssertionError)r�mrrr�test_emulate_no_battery�s
z*TestSensorsBattery.test_emulate_no_batteryc
Cs<tjddd��$}|jtj�jtj�|js.t�WdQRXdS)Nz&psutil._pswindows.cext.sensors_batteryrQr)ra)rQrrr)	rrdr-rrk�secsleft�POWER_TIME_UNLIMITEDrtru)rrvrrr�test_emulate_power_connected�s

z/TestSensorsBattery.test_emulate_power_connectedc
Cs<tjddd��$}|jtj�jtj�|js.t�WdQRXdS)Nz&psutil._pswindows.cext.sensors_batteryr�)ra)rr{rr)	rrdr-rrkrxryrtru)rrvrrr�test_emulate_power_charging�s

z.TestSensorsBattery.test_emulate_power_chargingc
Cs<tjddd��$}|jtj�jtj�|js.t�WdQRXdS)Nz&psutil._pswindows.cext.sensors_batteryrrQ)ra���)rrrr})	rrdr-rrkrxZPOWER_TIME_UNKNOWNrtru)rrvrrr�test_emulate_secs_left_unknowns

z1TestSensorsBattery.test_emulate_secs_left_unknownN)
rfrgrhrmrrirrqrrrwrzr|r~rrrrrj�s	
rjc@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Ze
jejd+kd�dd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*S),�TestProcesscCst�j|_dS)N)r�pid)�clsrrr�
setUpClassszTestProcess.setUpClasscCs
t�dS)N)r)r�rrr�
tearDownClassszTestProcess.tearDownClasscCstjd�}|jtj|j�dS)Nr)r�Process�assertRaisesr�kill)r�prrr�
test_issue_24s
zTestProcess.test_issue_24cCs�tjd�}|j|j�d�t|�|j�|j|j�dk�y|j�dd�\}}Wn(tj	k
r|t
j�dd
krx�YnX|j|d	k�dS)NrbZSystemgrrQ�vista�win-7�win7r)r�r�r�)rr�r-�name�str�usernamerZ�create_time�memory_infor�platform�uname)rr��rss�vmsrrr�test_special_pid s
zTestProcess.test_special_pidcCs"tj|j�}|jt|jtj�dS)N)rr�r�r��
ValueError�send_signal�signal�SIGINT)rr�rrr�test_send_signal1szTestProcess.test_send_signalcCsNxHtj�D]<}y |jtjj|j��|j��Wq
tjk
rDYq
Xq
WdS)N)	r�process_iterr-r+�path�basename�exer��Error)rr�rrr�test_exe5s
 zTestProcess.test_execCsbtjtj��}|j�}tjtjtj	tj��}|j�}|j
||d�tj|�|j
|j�|�dS)NrQ)rr�r+�getpid�num_handlesr1�OpenProcess�win32con�PROCESS_QUERY_INFORMATION�FALSEr-�CloseHandle)rr�Zbefore�handle�afterrrr�test_num_handles_increment<s
z&TestProcess.test_num_handles_incrementc
s��fdd�}tj|j�}g}x�ttj�D]���jd�s(�dkrBq(q(y(||��|j�}||��|j�}Wntjtjfk
r�Yq(X||kr(d�||f}|j|�q(W|r�|j	ddj
|��dS)Ncs,t|�d�}|dk	r$t|�r$|�n|dS)N)�getattrr)r��attr)r�rr�callJsz+TestProcess.test_handles_leak.<locals>.call�_�	terminater��suspend�resume�nicer��wait�children�as_dict�memory_info_exz@failure while processing Process.%s method (before=%s, after=%s)�
)
r�r�r�r�r�r�r�r�r�r�)rr�r��dirrTr�rr�appendr&�join)rr�r�ZfailuresZnum1Znum2r&r)r�r�test_handles_leakFs,


zTestProcess.test_handles_leakcCs:x4tj�D](}y|j�Wq
tjk
r0Yq
Xq
WdS)N)rr�r�r)rr�rrr�test_name_always_availablejs
z&TestProcess.test_name_always_availabler�zCTRL_* signals not supportedcCsbtjt�j�}|jtj�|jtj�|j�|j	�|j
tj|jtj�|j
tj|jtj�dS)N)rr�rr�r�r�ZCTRL_C_EVENTZCTRL_BREAK_EVENTr�r�r�r)rr�rrr�test_ctrl_signalssszTestProcess.test_ctrl_signalsc
Cs\xVtj�D]J}ytjj|j��}|j�}Wntjtjfk
rFYq
X|j	||�q
WdS)N)
rr�r+r�r�r�r�rrr-)rr��a�brrr�test_compare_name_exe�sz!TestProcess.test_compare_name_execCs |jtj�j�tjtj��dS)N)r-rr�r�r1Z
GetUserNameExr�ZNameSamCompatible)rrrr�
test_username�szTestProcess.test_usernamecCs8tjddtj��j�}djtj�j��}|j	||�dS)Nz +r!)
�re�subr1ZGetCommandLine�stripr�rr��cmdliner-)rr2r3rrr�test_cmdline�szTestProcess.test_cmdlinecCsJtjtjtjtj��}|jtj|�t	j
|�}tj�j
�}|j||�dS)N)r1r�r�r�r�r+r��
addCleanupr��win32processZGetPriorityClassrr�r�r-)rr�r2r3rrr�	test_nice�s
zTestProcess.test_nicecCs�tjtjtj|j�}|jtj|�tj	|�}t
j|j�j�}|j
|d|j�|j
|d|j�|j
|d|j�|j
|d|j�|j
|d|j�|j
|d|j�|j
|d|j�|j
|d|j�|j
|j|j�|j
|j|j�dS)	NZPeakWorkingSetSize�WorkingSetSizeZQuotaPeakPagedPoolUsageZQuotaPagedPoolUsageZQuotaPeakNonPagedPoolUsageZQuotaNonPagedPoolUsageZ
PagefileUsageZPeakPagefileUsage)r1r�r�r�r�r�r�r�r�ZGetProcessMemoryInforr�r�r-Z	peak_wsetZwsetZpeak_paged_poolZ
paged_poolZpeak_nonpaged_poolZ
nonpaged_poolZpagefileZ
peak_pagefiler�r�)rr�r2r3rrr�test_memory_info�s0
zTestProcess.test_memory_infocCsXtjtjtj|j�}|jtj|�tj	|j�}|j
�|j�}tj
|�}|j||�dS)N)r1r�r�r�r�r�r�r�rr�r�r�r�ZGetExitCodeProcessr-)rr�r�r3r2rrr�	test_wait�s
zTestProcess.test_waitcCs\dd�}tjtjtj|j�}|jtj|�|tj	|�d�}t
j|j�j�}|j
||�dS)Ncs�fdd�td�D�S)Ncsg|]}d|>�@r|�qS)rQr)r>�i)r?rrr@�szGTestProcess.test_cpu_affinity.<locals>.from_bitmask.<locals>.<listcomp>�@)�range)r?r)r?r�from_bitmask�sz3TestProcess.test_cpu_affinity.<locals>.from_bitmaskr)r1r�r�r�r�r�r�r�r�ZGetProcessAffinityMaskrr�Zcpu_affinityr-)rr�r�r2r3rrr�test_cpu_affinity�szTestProcess.test_cpu_affinitycCs�tjtjtjtj��}|jtj|�t	j
|�}tj�j
�}|j|j|d�|j|j|d�|j|j|d�|j|j|d�|j|j|d�|j|j|d�dS)NZReadOperationCountZWriteOperationCountZReadTransferCountZWriteTransferCountZOtherOperationCountZOtherTransferCount)r1r�r�r�r�r+r�r�r�r�ZGetProcessIoCountersrr��io_countersr-Z
read_countZwrite_countZ
read_bytesZwrite_bytes�other_countZother_bytes)rr�r2r3rrr�test_io_counters�s"
zTestProcess.test_io_counterscCs�ddl}ddl}d}|jjj|dtj��}|j|jjj|�|j	j
�}|jjj||j|��|j
}tj�j�}|jjj|�|j||d�dS)NrirQ)�ctypesZctypes.wintypesZwindllZkernel32r�r+r�r�r�ZwintypesZDWORDZGetProcessHandleCountZbyref�valuerr�r�r-)rr�r�r�Zhndcntr2r3rrr�test_num_handles�s
zTestProcess.test_num_handlesN)rr�)rfrgrh�classmethodr�r�r�r�r�r�r�r�r�rri�sys�version_infor�r�r�r�r�r�r�r�r�r�rrrrrs(
$	

rc@s`eZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)�TestProcessWMIz%Compare Process API results with WMI.cCst�j|_dS)N)rr�)r�rrrr�szTestProcessWMI.setUpClasscCs
t�dS)N)r)r�rrrr�szTestProcessWMI.tearDownClasscCs8tj�j|jd�d}tj|j�}|j|j�|j�dS)N)r=r)	r5r6rAr�rr�r-r�ZCaption)rr8r�rrr�	test_name
szTestProcessWMI.test_namecCs@tj�j|jd�d}tj|j�}|j|j�j�|j	j��dS)N)r=r)
r5r6rAr�rr�r-r�r%ZExecutablePath)rr8r�rrrr�szTestProcessWMI.test_execCsFtj�j|jd�d}tj|j�}|jdj|j��|j	j
dd��dS)N)r=rr!�"rF)r5r6rAr�rr�r-r�r�ZCommandLiner$)rr8r�rrrr�szTestProcessWMI.test_cmdlinecCsPtj�j|jd�d}tj|j�}|j�\}}}d||f}|j|j�|�dS)N)r=rz%s\%s)	r5r6rAr�rr�ZGetOwnerr-r�)rr8r�Zdomainr�r�rrrr�s
zTestProcessWMI.test_usernamecCsLtjd�tj�j|jd�d}tj|j�}|j�j	}|j
|t|j��dS)Ng�������?)r=r)
�time�sleepr5r6rAr�rr�r�r�r-r*r�)rr8r�r�rrr�test_memory_rss#s


zTestProcessWMI.test_memory_rsscCsjtjd�tj�j|jd�d}tj|j�}|j�j	}t
|j�}||krf||dkrf|jd||f�dS)Ng�������?)r=rizwmi=%s, psutil=%s)
r�r�r5r6rAr�rr�r�r�r*Z
PageFileUsager&)rr8r�r�Z	wmi_usagerrr�test_memory_vms*s


zTestProcessWMI.test_memory_vmscCs\tj�j|jd�d}tj|j�}t|jjd�d�}t	j
dt	j|j���}|j
||�dS)N)r=rr\z%Y%m%d%H%M%S)r5r6rAr�rr�r�ZCreationDaterUr�ZstrftimeZ	localtimer�r-)rr8r�Zwmic_createZ
psutil_createrrr�test_create_time7szTestProcessWMI.test_create_timeN)rfrgrh�__doc__r�r�r�r�r�r�r�r�r�r�rrrrr��s
r�c@sXeZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�TestDualProcessImplementationa{
    Certain APIs on Windows have 2 internal implementations, one
    based on documented Windows APIs, another one based
    NtQuerySystemInformation() which gets called as fallback in
    case the first fails because of limited permission error.
    Here we test that the two methods return the exact same value,
    see:
    https://github.com/giampaolo/psutil/issues/304
    cCst�j|_dS)N)rr�)r�rrrr�Lsz(TestDualProcessImplementation.setUpClasscCs
t�dS)N)r)r�rrrr�Psz+TestDualProcessImplementation.tearDownClassc
CsZtj|j�j�}tjdtjtj��d��(}|j	tj|j�j�|�|j
sLt�WdQRXdS)Nz psutil._psplatform.cext.proc_exe)�side_effect)rr�r�r�rrdrr+r�r-rtru)rr�rrrrr�Ws
z'TestDualProcessImplementation.test_namec
Cs�tj|j�j�}tjdttjd�d���}tj|j�j�}|j	t
|�t
|��xLtt
|��D]<}|j||d�|j||d�|j
||||dd�qZW|js�t�WdQRXdS)Nz(psutil._psplatform.cext.proc_memory_info�msg)r�ri)rP)rr�r�r�rrdrr�EPERMr-�lenr�ZassertGreaterEqualrRrtru)rZmem_1rZmem_2r�rrrr�^sz.TestDualProcessImplementation.test_memory_infoc
CsXtj|j�j�}tjdttjd�d��(}|j	tj|j�j�|�|j
sJt�WdQRXdS)Nz(psutil._psplatform.cext.proc_create_timer�)r�)rr�r�r�rrdrrr�r-rtru)rZctimerrrrr�js
z.TestDualProcessImplementation.test_create_timecCsxtj|j�j�}tjdttjd�d��H}tj|j�j�}|j	sBt
�|j|j|jdd�|j|j
|j
dd�WdQRXdS)Nz&psutil._psplatform.cext.proc_cpu_timesr�)r�g{�G�z�?)rP)rr�r�Z	cpu_timesrrdrrr�rtrurR�user�system)rZcpu_times_1rZcpu_times_2rrr�test_cpu_timesqs
z,TestDualProcessImplementation.test_cpu_timesc
Cs~tj|j�j�}tjdttjd�d��N}tj|j�j�}x,t	t
|��D]}|j||||dd�qFW|jspt
�WdQRXdS)Nz(psutil._psplatform.cext.proc_io_countersr�)r�r0)rP)rr�r�r�rrdrrr�r�r�rRrtru)rZ
io_counters_1rZ
io_counters_2r�rrrr�|sz.TestDualProcessImplementation.test_io_countersc
CsXtj|j�j�}tjdttjd�d��(}|j	tj|j�j�|�|j
sJt�WdQRXdS)Nz(psutil._psplatform.cext.proc_num_handlesr�)r�)rr�r�r�rrdrrr�r-rtru)rr�rrrrr��sz.TestDualProcessImplementation.test_num_handlesN)
rfrgrhr�r�r�r�r�r�r�r�r�r�rrrrr�@s

r�c@s|eZdZdZedd��Zedd��ZddgZdd	�Z	d
d�Z
edd
��Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�RemoteProcessTestCasez�Certain functions require calling ReadProcessMemory.
    This trivially works when called on the current process.
    Check that this works on other processes, especially when they
    have a different bitness.
    cCsTd}xJtjd�D]<}tj|d|gtjtjd�}|j�\}}|tt�kr|SqWdS)Nz6import sys; sys.stdout.write(str(sys.maxsize > 2**32))zC:\Python*\python.exez-c)r�stdout�stderr)�glob�
subprocess�Popen�PIPEZSTDOUT�communicater��	IS_64_BIT)�code�filenamer9�outputr�rrr�find_other_interpreter�s
z,RemoteProcessTestCase.find_other_interpretercCs@|j�}|dkrtjd��tr.tj|_||_n||_tj|_dS)Nz0could not find interpreter with opposite bitness)r�rZSkipTestr�r��
executable�python64�python32)r�Zother_pythonrrrr��sz RemoteProcessTestCase.setUpClassz-czimport sys; sys.stdin.read()cCsVtjj�}ttj��|d<t|jg|j|tj	d�|_
t|jg|j|tj	d�|_dS)N�THINK_OF_A_NUMBER)�env�stdin)
r+r,�copyr�r�rr��	test_argsr�r��proc32r��proc64)rr�rrr�setUp�s
zRemoteProcessTestCase.setUpcCs|jj�|jj�t�dS)N)rr�rr)rrrr�tearDown�s

zRemoteProcessTestCase.tearDowncCs
t�dS)N)r)r�rrrr��sz#RemoteProcessTestCase.tearDownClasscCs@tj|jj�}|jt|j��d�|j|j�dd�|j�dS)Nr]rQ)rr�rr�r-r�r�r)rr�rrr�test_cmdline_32�sz%RemoteProcessTestCase.test_cmdline_32cCs@tj|jj�}|jt|j��d�|j|j�dd�|j�dS)Nr]rQ)rr�rr�r-r�r�r)rr�rrr�test_cmdline_64�sz%RemoteProcessTestCase.test_cmdline_64cCs&tj|jj�}|j|j�tj��dS)N)rr�rr�r-�cwdr+�getcwd)rr�rrr�test_cwd_32�sz!RemoteProcessTestCase.test_cwd_32cCs&tj|jj�}|j|j�tj��dS)N)rr�rr�r-rr+r	)rr�rrr�test_cwd_64�sz!RemoteProcessTestCase.test_cwd_64cCs>tj|jj�}|j�}|jd|�|j|dttj	���dS)Nr�)
rr�rr�r,�assertIn�assertEqualsr�r+r�)rr��errr�test_environ_32�sz%RemoteProcessTestCase.test_environ_32cCs>tj|jj�}|j�}|jd|�|j|dttj	���dS)Nr�)
rr�rr�r,rr
r�r+r�)rr�rrrr�test_environ_64�sz%RemoteProcessTestCase.test_environ_64N)rfrgrhr��staticmethodr�r�r�rrrr�rrr
rrrrrrrr��s
r�c@seZdZdd�Zdd�ZdS)�TestServicescCsntdddddddg�}tdd	d
g�}tddddd
ddg�}�x,tj�D�]}|j�}|j|dt�|j|dj�d�|j|dt�|j|dt�|j|d|�|ddk	r�tj	|d�|j|dt�|j|dt�|j|dt�|j|d|�|j|d|�|j|dt�|j
�}|dk	�rLtj	|�}|j|j��tj
|j��}|j||�qFWdS)NZrunningZpaused�start�pause�continue�stopZstoppedZ	automaticZmanualZdisabledZ
start_pendingZ
pause_pendingZcontinue_pendingZstop_pendingr�rF�display_namer��statusr�ZbinpathZ
start_type�description)rBr�win_service_iterr�ZassertIsInstancer�ZassertNotEqualr�rr�r�rZZ
is_running�win_service_getr�r-)rZvalid_statusesZvalid_start_typesZserv�datar�r��srrr�test_win_service_iter�sR

z"TestServices.test_win_service_iterc'Cspttj��j�}|jtj��}tj|d�WdQRX|j|jj|d�tj|�}t	tj
jjd�}t
jd|d��|jtj|j�WdQRXt
jd|d��|jtj|j�WdQRXt	tj
jjd�}t
jd|d��|jtj|j�WdQRXt
jd|d��|jtj|j�WdQRX|j|j�t|��|j|j�t|��|j|j�t|��|j|j�t|��dS)Nz???rFz/psutil._psplatform.cext.winservice_query_status)r�z/psutil._psplatform.cext.winservice_query_config)�nextrrr�r�rrr-Z	exceptionZWindowsError�_psplatformrWZERROR_SERVICE_DOES_NOT_EXISTrrdrr�ZERROR_ACCESS_DENIEDrrr�rrN)rr��cmZservice�excrrr�test_win_service_get!s2




z!TestServices.test_win_service_getN)rfrgrhrr#rrrrr�s0r�__main__l)2r�r^rr�r+r�r�r�r�r�r��warningsrrZpsutil._compatrZpsutil.testsrrrrrr	r
rr�catch_warnings�simplefilterr1r�r�r5�ImportErrorr�r rW�maxsizer�rriZTestCaser rjrr�r�r�rrf�__file__rrrr�<module>sl





<
m
A
N
^
U


?>