Your IP : 18.116.86.134
3
��JZ[2 � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddlm Z ddlm
Z
ddlmZ dd lm
Z
dd
lmZ ddlmZ ddlmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddlm!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% dd lm&Z& ddlZddlZd!d"� Zd#d$� Z'e
�r�e"j(d%�d& j)d%d'�Z*ne"d( Z*G d)d*� d*e+�Z,e%j-e �o�e$d+�e%j-ed,�e%j-e'e#� d-�G d.d/� d/e,e%j.����Z/e%j-e �o*e$d+�e%j-e'e*� d0�G d1d2� d2e,e%j.���Z0e%j-e d3�G d4d5� d5e%j.��Z1G d6d7� d7e%j.�Z2e3d8k�r�ee4� dS )9a�
Notes about unicode handling in psutil
======================================
In psutil these are the APIs returning or dealing with a string
('not tested' means they are not tested to deal with non-ASCII strings):
* Process.cmdline()
* Process.connections('unix')
* Process.cwd()
* Process.environ()
* Process.exe()
* Process.memory_maps()
* Process.name()
* Process.open_files()
* Process.username() (not tested)
* disk_io_counters() (not tested)
* disk_partitions() (not tested)
* disk_usage(str)
* net_connections('unix')
* net_if_addrs() (not tested)
* net_if_stats() (not tested)
* net_io_counters() (not tested)
* sensors_fans() (not tested)
* sensors_temperatures() (not tested)
* users() (not tested)
* WindowsService.binpath() (not tested)
* WindowsService.description() (not tested)
* WindowsService.display_name() (not tested)
* WindowsService.name() (not tested)
* WindowsService.status() (not tested)
* WindowsService.username() (not tested)
In here we create a unicode path with a funky non-ASCII name and (where
possible) make psutil return it back (e.g. on name(), exe(), open_files(),
etc.) and make sure that:
* psutil never crashes with UnicodeDecodeError
* the returned path matches
For a detailed explanation of how psutil handles unicode see:
- https://github.com/giampaolo/psutil/issues/1040
- http://psutil.readthedocs.io/#unicode
� N)�closing)�BSD)�OPENBSD)�OSX)�POSIX)�WINDOWS)�PY3)�u)�APPVEYOR)�ASCII_FS)�bind_unix_socket)�chdir)�copyload_shared_lib)�
create_exe)�get_test_subprocess)�HAS_CONNECTIONS_UNIX)�HAS_ENVIRON)�HAS_MEMORY_MAPS)�mock)�
reap_children)�run_test_module_by_name)�
safe_mkdir)�safe_rmpath)�skip_on_access_denied)�TESTFILE_PREFIX)�TESTFN)�TESTFN_UNICODE)�TRAVIS)�unittest)�unix_socket_pathc C s8 t r,yt| �S tk
r( tj� Y q4X nt| �S d S )N)r
�_safe_rmpathZWindowsError� traceback� print_exc)�path� r$ �$/usr/lib64/python3.6/test_unicode.pyr \ s r c C sT t rdS z>y t| � t| � t| gd� W n tk
r> dS X dS W dt� X dS )z`Return True if both the fs and the subprocess module can
deal with a unicode file name.
T)�cmdFN)r r r r �UnicodeEncodeErrorr )�namer$ r$ r% �subprocess_supports_unicodep s r) �utf8s f���surrogateescapeu fÀc @ s� e Zd ZdZedd� �Zedd� �Zdd� Zdd � Zd
d� Z dd
� Z
dd� Zdd� Zdd� Z
eje d�dd� �Zeje d�eje d�e� dd� ���Zdd� Zeje d�eje d�dd� ��ZdS ) �_BaseFSAPIsTestsNc C s t | j� t| j� d S )N)r �
funky_namer )�clsr$ r$ r% �
setUpClass� s
z_BaseFSAPIsTests.setUpClassc C s t � t| j� d S )N)r r r- )r. r$ r$ r% �
tearDownClass� s z_BaseFSAPIsTests.tearDownClassc C s
t � d S )N)r )�selfr$ r$ r% �tearDown� s z_BaseFSAPIsTests.tearDownc C s t d��d S )Nzmust be implemented in subclass)�NotImplementedError)r1 r$ r$ r% �expect_exact_path_match� s z(_BaseFSAPIsTests.expect_exact_path_matchc C sH t | jgd�}tj|j�}|j� }| j|t� | j� rD| j || j� d S )N)r&