관리-도구
편집 파일: test_misc.cpython-37.pyc
B �=�_�o � @ s d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl mZ ddl mZ ddl m Z ddlmZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddlm&Z& ddl Z ddlZ e j'dd� dkZ(G dd� de �Z)e�*d d!�Z+G d"d#� d#e �Z,e&�-ej.�/e$� d$�G d%d&� d&e ��Z0e1d'k�r dd(l2m3Z3 e3e4� dS ))z Miscellaneous tests. � N)�LINUX)�POSIX)�WINDOWS)�memoize)�memoize_when_activated)� supports_ipv6)�wrap_numbers)�PY3)�APPVEYOR)� CI_TESTING)�HAS_BATTERY)�HAS_MEMORY_MAPS)�HAS_NET_IO_COUNTERS)�HAS_SENSORS_BATTERY)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�import_module_by_path)�mock)�PsutilTestCase)� PYTHON_EXE)� reload_module)�ROOT_DIR)�SCRIPTS_DIR)�sh)�unittest� )� � c @ s� e Zd Zefdd�Zdd� Zefdd�Zefdd�Zefd d �Zefdd�Z d d� Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)S )*�TestMiscc C s� t �| �� j�}||�}| �d|� | �d|j |� | �dt|�� � |�dd�� | �d|� | �d|� |� � |� � ||�}| �d|� | �d|� tjj t jd t �t�� �d ��@ t �� }||�}| �d|j |� | �d|� | �d|� W d Q R X tjj t jd t �t�� �d ��@ t �� }||�}| �d|j |� | �d |� | �d|� W d Q R X tjj t jd t �t�� �d ��4 t �� }||�}| �d|j |� | �d|� W d Q R X d S )Nzpsutil.Processzpid=%sz name='%s'zname=u'zname='zstatus=z exitcode=zstatus='terminated'�name)�side_effectzstatus='zombie'zname=Z terminated)�psutil�ProcessZspawn_testproc�pid�assertIn�strr �replace�assertNotIn� terminate�waitr �patch�object� ZombieProcess�os�getpid� NoSuchProcess�AccessDenied)�self�func�p�r� r5 �I/opt/alt/python37/lib64/python3.7/site-packages/psutil/tests/test_misc.py�test_process__repr__= sB zTestMisc.test_process__repr__c C s | j td� d S )N)r2 )r7 r% )r1 r5 r5 r6 �test_process__str__a s zTestMisc.test_process__str__c C sN | � tt�d��d� | � ttjddd��d� | � ttjddd��d� d S )NiA z7psutil.NoSuchProcess process no longer exists (pid=321)�foo)r zCpsutil.NoSuchProcess process no longer exists (pid=321, name='foo'))�msgzpsutil.NoSuchProcess foo)�assertEqual�reprr! r/ )r1 r2 r5 r5 r6 �test_no_such_process__repr__d s z%TestMisc.test_no_such_process__repr__c C sj | � tt�d��d� | � ttjddd��d� | � ttjdddd��d� | � ttjddd ��d � d S )NiA zEpsutil.ZombieProcess process still exists but it's a zombie (pid=321)r9 )r zQpsutil.ZombieProcess process still exists but it's a zombie (pid=321, name='foo')� )r �ppidzYpsutil.ZombieProcess process still exists but it's a zombie (pid=321, name='foo', ppid=1))r: zpsutil.ZombieProcess foo)r; r<