U �=�_�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 5 Q R X tjj t jd t �t�� �d ��@ t �� }||�}| �d|j |� | �d |� | �d|� W 5 Q R X tjj t jd t �t�� �d ��4 t �� }||�}| �d|j |� | �d|� W 5 Q R X d S )Nzpsutil.Processzpid=%sz name='%s'zname=u'zname='zstatus=z exitcode=zstatus='terminated'�name�Zside_effectzstatus='zombie'zname=Z terminated)�psutil�ProcessZspawn_testproc�pid�assertIn�strr �replace�assertNotInZ terminate�waitr �patch�object� ZombieProcess�os�getpid� NoSuchProcess�AccessDenied)�self�func�p�r� r4 �I/opt/alt/python38/lib64/python3.8/site-packages/psutil/tests/test_misc.py�test_process__repr__= sJ ����zTestMisc.test_process__repr__c C s | j td� d S )N)r1 )r6 r% �r0 r4 r4 r5 �test_process__str__a s zTestMisc.test_process__str__c C sN | � tt�d��d� | � ttjddd��d� | � ttjddd��d� d S )N�A 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. �r0 r1 r4 r4 r5 �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 )Nr9 zEpsutil.ZombieProcess process still exists but it's a zombie (pid=321)r: r; zQpsutil.ZombieProcess process still exists but it's a zombie (pid=321, name='foo')� )r ZppidzYpsutil.ZombieProcess process still exists but it's a zombie (pid=321, name='foo', ppid=1)r<