403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.109
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_pathlib.cpython-36.pyc
3

�w2_Ya�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl	m
Z
ddlmZddl
mZmZyddlZddlZWnek
r�dZZYnXGdd�de�ZGdd�dee	j�ZGd	d
�d
ee	j�ZGdd�de�ZGd
d�dee	j�ZGdd�dee	j�ZGdd�dee	j�Zejje�Zdd�Zdd�Z dd�Z!e!�Z!e	j"ej#dkd�Z$e	j"ej#dkd�Z%e	j"e!e!�Z&e%Gdd�de��Z'e$Gdd�de��Z(Gdd �d e�Z)Gd!d"�d"e)e	j�Z*e%Gd#d$�d$e)e	j��Z+e$Gd%d&�d&e)e	j��Z,e-d'k�re	j.�dS)(�N)�mock)�support)�TESTFN�FakePathc@seZdZdd�Zdd�ZdS)�_BaseFlavourTestcsd|jj}|jj�|jj�|�fdd�|D��}|j||��r`|�fdd�|D��}|j||�dS)Ncsg|]}|jd���qS)�/)�replace)�.0�x)�sep��6/opt/alt/python36/lib64/python3.6/test/test_pathlib.py�
<listcomp>sz7_BaseFlavourTest._check_parse_parts.<locals>.<listcomp>csg|]}|jd���qS)r)r)r	r
)�altseprr
rs)�flavourZparse_partsrr�assertEqual)�self�arg�expected�fZactualr)rrr
�_check_parse_partssz#_BaseFlavourTest._check_parse_partscCs�|j}|jj}|gddgf�|dgdddgf�|dgdddgf�|ddgddddgf�|dgddddgf�|dgddddgf�|dddgddddd	dgf�|dd
dgddddd	dgf�|dddgddddd	dgf�|dgddgf�|dddgdddgf�|dddgddddgf�|dddgdddgf�|d
gd||ddgf�|ddgd||ddgf�|ddgd||ddgf�|ddd	gd||dd	gf�|dddgd||d	gf�dS)N��aza/�bza/bza/b/zb/c�d�czb//czb/c/�.z/a/bz/az/a/z/bz/c)rrr)r�checkrrrr
�test_parse_parts_common"s(z(_BaseFlavourTest.test_parse_parts_commonN)�__name__�
__module__�__qualname__rrrrrr
rs
rc@s"eZdZejZdd�Zdd�ZdS)�PosixFlavourTestcCs�|j}|ddgdddddgf�|ddgdddddgf�|ddgdddddgf�|d	gddd	gf�|d
gddd
gf�|dgdddgf�dS)Nz//arrz//rz///arz////azc:azc:\az\a)r)rrrrr
�test_parse_partsBsz!PosixFlavourTest.test_parse_partscCs�|jj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d	�d�|j|d�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d�dS)Nrr�a/b�a/b/z/arz/a/bz/a/b/z//a�//z///az///a/b�c:/a/b�\/a/b�\a\b)rrr)rrr)rrr$)rrr%)rrr)rrr$)rrr%)rr&r)rrr)rrr$)rrr')rrr()rrr))r�	splitrootr)rrrrr
�test_splitrootNszPosixFlavourTest.test_splitrootN)rr r!�pathlibZ_posix_flavourrr#r+rrrr
r"?sr"c@s"eZdZejZdd�Zdd�ZdS)�
NTFlavourTestcCs|j}|dgdddgf�|dgdddgf�|dgdddgf�|dgddddgf�|d	gddddgf�|d
gddddgf�|dgddd
gf�|dgddd
gf�|dgddd
dgf�|dddgdddddgf�|dddgdddddgf�|dddgddddgf�|dddgddddddgf�|dddgddddgf�|dgdddgf�|d gddddgf�|d d!gddddgf�|d"gd#dd$gf�|d%gd#dd$dgf�|dd!dgdddddgf�|d&d!dgdddddgf�|d'd!dgd(dd)ddgf�dS)*Nzc:rzc:/�\zc:\rzc:arzc:/az/az//a/bz\\a\bz\\a\b\z//a/b/z//a/b/crzZ:bzZ:rzZ:/bzZ:\z//b/crz\\b\cz\\b\c\z	Z://b//c/zd/z//b/c//z//?/c:/z\\?\c:z\\?\c:\z//?/c:/az/bz//?/UNC/b/cz\\?\UNC\b\cz\\?\UNC\b\c\z
//?/UNC/b/c/dzZ:/az//?/Z:/az\\?\Z:z\\?\Z:\)r)rrrrr
r#fs.zNTFlavourTest.test_parse_partscCs|jj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d	�d�|j|d
�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d�|j|d�d �|j|d�d!�|j|d�d"�|j|d
�d#�dS)$Nrr�a\bz\ar.z\a\bzc:a\b�c:zc:\a\bz\\az\\\a/b�a/bzc:\\azc:\\\a/b�\\a\bz\\a\b\z	\\a\b\c\d�c\dz\\\a\b)rrr)rrr)rrr/)rr.r)rr.r/)r0rr/)r0r.r/)rr.r)rr.r1)r0r.r)r0r.r1)r2r.r)r2r.r)r2r.r3)rr.r/)rr.r)rr*r)rrrrr
r+�s"zNTFlavourTest.test_splitrootN)rr r!r,Z_windows_flavourrr#r+rrrr
r-cs"r-c@s.eZdZdRdSdTdUdVdWdXdYdZd[g
d\d]d^d_d`dagd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd �Z
d!d"�Zd#d$�Zd%d&�Z
d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�ZdAdB�ZdCdD�ZdEdF�ZdGdH�ZdIdJ�ZdKdL�Z dMdN�Z!dOdP�Z"dQS)b�_BasePurePathTestrr�a/�b/�a/b/�a//b�a//b//r�/b/cr�///b//c�d/�/ar�c/d�b/c/d�/b/c/d)za/bz/b/c/dcCs*|jd�}|j|_|jj|_|jj|_dS)Nr)�clsZ_flavourrrr)r�prrr
�setUp�s

z_BasePurePathTest.setUpcCs�|j}|d�}|j||�|ddd�|ddd�|d�|d�|td��|j||d��|d��|j||d�d�|d��|j||d�|d��|d��|j||d�|d�|d��|td���dS)Nrrrz/aza/b/cz/a/b/cza/b)rA�assertIsInstancerr)r�PrBrrr
�test_constructor_common�sz)_BasePurePathTest.test_constructor_commoncs`Gdd�dt��|j}|�fdd�|D��}|j|||��x|jD]}|jt|�t�qDWdS)Nc@seZdZdS)z:_BasePurePathTest._check_str_subclass.<locals>.StrSubclassN)rr r!rrrr
�StrSubclass�srGc3s|]}�|�VqdS)Nr)r	r
)rGrr
�	<genexpr>�sz8_BasePurePathTest._check_str_subclass.<locals>.<genexpr>)�strrAr�parts�assertIs�type)r�argsrErB�partr)rGr
�_check_str_subclass�sz%_BasePurePathTest._check_str_subclasscCs6|jd�|jd�|jd�|jd�|jd�dS)Nrrrza/b.txtz/a/b.txt)rO)rrrr
�test_str_subclass_common�s




z*_BasePurePathTest.test_str_subclass_commoncCs�|j}|d�}|jd�}|j||d��|jt|�t|��|jdd�}|j||d��|j|d��}|j||d��|jd�}|j||d��dS)Nza/brza/b/crza/b/c/dz/c)rA�joinpathrrKrL)rrErB�pprrr
�test_join_common�s

z"_BasePurePathTest.test_join_commoncCs�|j}|d�}|d}|j||d��|jt|�t|��|d}|j||d��|dd}|j||d��d|d}|j||d��||d�}|j||d��|d}|j||d��dS)	Nza/brza/b/czc/dza/b/c/drzc/a/b/dz/c)rArrKrL)rrErBrRrrr
�test_div_common�sz!_BasePurePathTest.test_div_commoncCs(|j|�}|jt|�|jd|j��dS)Nr)rArrIrr)rrrMrBrrr
�
_check_str�s
z_BasePurePathTest._check_strcCs,xd	D]}|j||f�qW|jdd
�dS)Nr�a/b�a/b/cr�/a/b�/a/b/crr)rrVrWrrXrY)r)rU)r�pathstrrrr
�test_str_commons
z!_BasePurePathTest.test_str_commoncCs,|j}x dD]}|j||�j�|�qWdS)Nr�a/b�a/b/cr�/a/b�/a/b/c)rr\r]rr^r_)rAr�as_posix)rrErZrrr
�test_as_posix_common
s
z&_BasePurePathTest.test_as_posix_commoncCs2tj|j�}|j}|jt|d��d|d�dS)Nza/b�a�b)�os�fsencoderrAr�bytes)rrrErrr
�test_as_bytes_commonsz&_BasePurePathTest.test_as_bytes_commoncCsL|j}|jt��|d�j�WdQRX|jt��|�j�WdQRXdS)Nr)rA�assertRaises�
ValueError�as_uri)rrErrr
�test_as_uri_commons
z$_BasePurePathTest.test_as_uri_commoncCs�x�d
D]�}|j|�}|jj}t|�}|j|j|d�|�|j|jd�|�|t|�d	d�}|jt	|�|j
��t	|tj�}|j
|j|j�|j||�|jt|�|�qWdS)Nr�a/b�a/b/cr�/a/b�/a/b/c�(�)�)rrlrmrrnro���)rA�	__class__r�repr�
assertTrue�
startswith�endswith�lenr�evalr`r,�__dict__rK)rrZrBZclsname�r�inner�qrrr
�test_repr_commons

z"_BasePurePathTest.test_repr_commoncCs�|j}|j|d�|d��|j|d�|dd��|j|d�|d��|j|d�|d��|j|d�|��|j|d�|d��|j|�|d��|j|�d�|j|�i�|j|�t�dS)Nza/brrz/a/brr)rAr�assertNotEqual�int)rrErrr
�test_eq_common,sz _BasePurePathTest.test_eq_commoncCs&|j}|jt|d�jd�|jt|d�jd�|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d	�jd��|j|d
�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d
�jd��|j|d
�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��dS)Nrrrzb.pyza/b.pyz/a/b.pyza.pyzb/pyz/a.pyzb.py/cz*.pyzb.pyczb./pyzab/c.pyza*/*.pyz
/d/ab/c.pyz	/dab/c.pyz	ab/c.py/dz/b.pyz/*.pyz/a/*.pyz/ab.pyz	/a/b/c.py)rArhri�matchrv�assertFalse)rrErrr
�test_match_common9s8z#_BasePurePathTest.test_match_commonc	s��fdd�}�j}|d�}|d�}|d�}|d�}|||�|||�|||�|||�|||��j}|d�}|d�}|d	�}|d
�}|||�|||�|||�|||�|||��jt��|�ikWdQRXdS)Ncs�j||��j||�dS)N)�
assertLessZ
assertGreater)rr)rrr
r�^sz:_BasePurePathTest.test_ordering_common.<locals>.assertLessrza/b�abcrz/az/a/bz/abcz/b)rArh�	TypeError)rr�rErrrrr)rr
�test_ordering_common\s.









z&_BasePurePathTest.test_ordering_commoncCsX|j}|j}|d�}|j}|j|d�|j||j�|d�}|j}|j||ddf�dS)Nza/brrz/a/b)rr)rrArJrrK)rrrErBrJrrr
�test_parts_commonxsz#_BasePurePathTest.test_parts_commoncCs4|j}|d�}|j|j�d�|jtj|�d�dS)N�a/b)r�)r�)rArU�
__fspath__rd�fspath)rrErBrrr
�test_fspath_common�sz$_BasePurePathTest.test_fspath_commoncs�xƈjj�D]�\}}|jd�j�}|j�jd�}||krZ|�fdd�|D�}|j|f��j|�}x^|D]V}�j|�}�j||dj|���jt|�t|���jt	|�|��j|j
�|�qjWqWdS)Nrcs"g|]}t�fdd�|D���qS)c3s|]}|jd�j�VqdS)rN)rr)r	rN)rrr
rH�szA_BasePurePathTest.test_equivalences.<locals>.<listcomp>.<genexpr>)�tuple)r	�t)rrr
r�sz7_BasePurePathTest.test_equivalences.<locals>.<listcomp>zfailed with args {})�equivalences�itemsrr�appendrAr�format�hashrIr`)r�kZtuplesZcanon�posixZpcanonr�rBr)rr
�test_equivalences�s




z#_BasePurePathTest.test_equivalencescCs�|j}|d�}|j|j|d��|j|jj|d��|j|jjj|��|j|jjjj|��|d�}|j|j|d��|j|jj|d��|j|jjj|d��|j|jjjj|d��dS)Nza/b/cza/brz/a/b/cz/a/bz/ar)rAr�parent)rrErBrrr
�test_parent_common�sz$_BasePurePathTest.test_parent_commoncCsz|j}|d�}|j}|jt|�d�|j|d|d��|j|d|d��|j|d|d��|jt|�|d�|d�|d�g�|jt��|d
WdQRX|jt��|dWdQRX|jt��||d<WdQRX|d	�}|j}|jt|�d�|j|d|d
��|j|d|d��|j|d|d��|jt|�|d
�|d�|d�g�|jt��|dWdQRXdS)Nza/b/c�rza/brrr�rz/a/b/cz/a/bz/arrs)rA�parentsrry�listrh�
IndexErrorr�)rrErB�parrrr
�test_parents_common�s.""z%_BasePurePathTest.test_parents_commoncCs@|j}|j|d�jd�|j|d�jd�|j|d�jd�dS)Nza/brz/a/b)rAr�drive)rrErrr
�test_drive_common�sz#_BasePurePathTest.test_drive_commoncCsX|j}|j}|j|d�jd�|j|d�jd�|j|d�j|�|j|d�j|�dS)Nrza/brz/a/b)rArr�root)rrErrrr
�test_root_common�sz"_BasePurePathTest.test_root_commoncCsX|j}|j}|j|d�jd�|j|d�jd�|j|d�j|�|j|d�j|�dS)Nrza/brz/a/b)rArr�anchor)rrErrrr
�test_anchor_common�sz$_BasePurePathTest.test_anchor_commoncCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd	�|j|d
�jd	�dS)Nrrrza/brz/a/bz/a/b/.za/b.pyzb.pyz/a/b.py)rAr�name)rrErrr
�test_name_common�sz"_BasePurePathTest.test_name_commoncCs<|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd	�|j|d
�jd	�|j|d�jd�|j|d�jd�|j|d
�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�dS)Nrrz..rza/bz/a/bz/a/b/.za/b.pyz.pyz/a/b.pyza/.hgrcz/a/.hgrcza/.hg.rcz.rcz	/a/.hg.rcz
a/b.tar.gzz.gzz/a/b.tar.gzza/Some name. Ending with a dot.z /a/Some name. Ending with a dot.)rAr�suffix)rrErrr
�test_suffix_common�s$z$_BasePurePathTest.test_suffix_commoncCs:|j}|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jdg�|j|d	�jdg�|j|d
�jg�|j|d�jg�|j|d�jd
g�|j|d�jd
g�|j|d�jddg�|j|d�jddg�|j|d�jg�|j|d�jg�dS)Nrrrza/bz/a/bz/a/b/.za/b.pyz.pyz/a/b.pyza/.hgrcz/a/.hgrcza/.hg.rcz.rcz	/a/.hg.rcz
a/b.tar.gzz.tarz.gzz/a/b.tar.gzza/Some name. Ending with a dot.z /a/Some name. Ending with a dot.)rAr�suffixes)rrErrr
�test_suffixes_common�s"z&_BasePurePathTest.test_suffixes_commoncCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd	�|j|d
�jd�|j|d�jd
�|j|d�jd�dS)Nrrz..rza/brza/b.pyza/.hgrcz.hgrcza/.hg.rcz.hgz
a/b.tar.gzzb.tarza/Some name. Ending with a dot.zSome name. Ending with a dot.)rAr�stem)rrErrr
�test_stem_commonsz"_BasePurePathTest.test_stem_commoncCs2|j}|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d	�jd�|d��|jt|d
�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd
�|jt|d�jd
�|jt|d�jd�|jt|d�jd�dS)Nza/bzd.xmlza/d.xmlz/a/bz/a/d.xmlza/b.pyz/a/b.pyz
a/Dot ending.z/a/Dot ending.rrrz/czc/zc/d)rAr�	with_namerhri)rrErrr
�test_with_name_commonsz'_BasePurePathTest.test_with_name_commoncCs�|j}|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|jt|d�jd�|jt|d	�jd�|jt|d
�jd�|jt|d�jd�|jt|d�jd
�|jt|d�jd	�|jt|d�jd�|jt|d�jd
�|jt|d�jd�|jt|d�jd�|jt|d�jd�dS)Nza/bz.gzza/b.gzz/a/bz/a/b.gzza/b.pyz/a/b.pyrrr�gzz/.gzzc/dz.c/.dz./.dz.d/.)rAr�with_suffixrhri)rrErrr
�test_with_suffix_common.s$z)_BasePurePathTest.test_with_suffix_commoncCsR|j}|d�}|jt|j�|jt|jd�|j|j|��|d��|j|jd�|d��|j|j|d��|d��|j|jd�|d��|j|jd�|d��|j|j|d��|��|j|jd�|��|j|jdd�|��|jt|j|d��|jt|j|d��|jt|j|d	��|jt|j|d
��|d�}|j|j|d��|d��|j|jd�|d��|j|j|d
��|d��|j|jd
�|d��|j|jd
�|d��|j|j|d��|��|j|jd�|��|jt|j|d��|jt|j|d��|jt|j|d��|jt|j|��|jt|jd�|jt|j|d��dS)Nza/brbrrrza/rza/b/cza/cz/az/a/brz/a/z/cz/a/b/cz/a/c)rArhr��relative_torri)rrErBrrr
�test_relative_to_commonEs<z)_BasePurePathTest.test_relative_to_commoncCs�|j}|d�}xrtdtjd�D]^}tj||�}tj|�}|j|j|j�|j||�|jt	|�t	|��|jt
|�t
|��q WdS)Nz/a/brrr)rA�range�pickle�HIGHEST_PROTOCOL�dumps�loadsrKrtrr�rI)rrErB�proto�dumpedrRrrr
�test_pickling_commonhs
z&_BasePurePathTest.test_pickling_commonN)rr)r5r)rr6)r5r6)r7)r8)r9)rrr)rrr)rrr)rr:r)rr;r<)r=r:r)rrrr>)rrr?)rr@)#rr r!r�rCrFrOrPrSrTrUr[rargrkrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
r4�sJ

##r4c@sZeZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�ZdS)�PurePosixPathTestcCs@|j}|j|d�jd�|j|d�jd�|j|d�jd�dS)Nz/a/brz///a/bz//a/bz//)rArr�)rrErrr
�	test_rootwszPurePosixPathTest.test_rootcCsF|j}|j|d�|d��|j|d�|d��|j|d�|d��dS)Nza/bzA/bz/az///az//a)rAr�r)rrErrr
�test_eq~szPurePosixPathTest.test_eqcCsF|j}|j|d�j�d�|j|d�j�d�|j|d�j�d�dS)Nrzfile:///z/a/b.cz
file:///a/b.cz/a/b%#czfile:///a/b%25%23c)rArrj)rrErrr
�test_as_uri�szPurePosixPathTest.test_as_uricCsfddlm}|j}ytjd�Wntk
r>|jd�YnX|j|d�j�d|tjd���dS)Nr)�quote_from_bytes�éz1\xe9 cannot be encoded to the filesystem encodingu/a/bézfile:///a/b)	Zurllib.parser�rArdre�UnicodeEncodeError�skipTestrrj)rr�rErrr
�test_as_uri_non_ascii�sz'PurePosixPathTest.test_as_uri_non_asciicCs|j}|j|d�jd��dS)NzA.pyza.PY)rAr�r�)rrErrr
�
test_match�szPurePosixPathTest.test_matchcCs�|j}|j|�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��|j|d�j��dS)Nrza/b/rz/az/a/b/z//az//a/b)rAr��is_absoluterv)rrErrr
�test_is_absolute�sz"PurePosixPathTest.test_is_absolutecCsZ|j}|jd|d�j��|jd|d�j��|jd|d�j��|jd|d�j��dS)NFrrz/foo/barz/dev/con/PRN/NUL)rArK�is_reserved)rrErrr
�test_is_reserved�s
z"PurePosixPathTest.test_is_reservedcCsh|j}|d�}|jd�}|j||d��|d�jd�}|j||d��|d�jd�}|j||d��dS)Nz//arz//a/bz/az//cz/c)rArQr)rrErBrRrrr
�	test_join�s
zPurePosixPathTest.test_joincCsb|j}|d�}|d}|j||d��|d�d}|j||d��|d�d}|j||d��dS)Nz//arz//a/bz/az//cz/c)rAr)rrErBrRrrr
�test_div�szPurePosixPathTest.test_divN)rr r!r,�
PurePosixPathrAr�r�r�r�r�r�r�r�r�rrrr
r�ts

r�c	@s�eZdZejZejj�Zej	d<d=d>gd?d@dAdBdCgdDgdEdFgd��d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;S)G�PureWindowsPathTest�c:r�a/r�c:/�/a�/z�//x/y�//a/br�//a/b/)zc:azc:/az//a/b/z//a/b/ccCs�|jd�}|jt|�d�|jd�}|jt|�d�|jd�}|jt|�d�|jd�}|jt|�d�|jd	�}|jt|�d
�dS)Nza/b/cza\b\czc:/a/b/czc:\a\b\cz//a/bz\\a\b\z//a/b/cz\\a\b\cz	//a/b/c/dz	\\a\b\c\d)rArrI)rrBrrr
�test_str�s




zPureWindowsPathTest.test_strcCs^|jd�|jd�|jd�|jd�|jd�|jd�|jd�|jd�|jd	�dS)
Nzc:zc:az	c:a\b.txtzc:\zc:\az
c:\a\b.txtz\\some\sharez\\some\share\az\\some\share\a\b.txt)rO)rrrr
�test_str_subclass�s







z%PureWindowsPathTest.test_str_subclasscCs�|j}|j|d�|d��|j|d�|ddd��|j|d�|d��|j|d�|d��|j|d�|d��|j|d�|d	��|j|d
�|d��|j|d�|d
��dS)Nzc:a/bzc:rrzd:a/bzc:/a/bz/a/bza/BzA/bzC:a/Bzc:A/bz//Some/SHARE/a/Bz//somE/share/A/b)rArr�)rrErrr
r��szPureWindowsPathTest.test_eqcCs�|j}|jt��|d�j�WdQRX|jt��|d�j�WdQRX|j|d�j�d�|j|d�j�d�|j|d�j�d�|j|d	�j�d
�|j|d�j�d�|j|d
�j�d�|j|d�j�d�dS)Nz/a/bzc:a/bzc:/zfile:///c:/zc:/a/b.czfile:///c:/a/b.cz	c:/a/b%#czfile:///c:/a/b%25%23cuc:/a/bézfile:///c:/a/b%C3%A9z
//some/share/zfile://some/share/z//some/share/a/b.czfile://some/share/a/b.cu//some/share/a/b%#céz"file://some/share/a/b%25%23c%C3%A9)rArhrirjr)rrErrr
r��szPureWindowsPathTest.test_as_uricCsr|j}|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d�jd��|j|d	�jd��|j|d	�jd
��|j|d�jd
��|j|d�jd
��|j|d
�jd��|j|d�jd��|j|d�jd��dS)Nzc:/b.pyz/*.pyzc:*.pyzc:/*.pyzd:/b.pyzb.pyzc:b.pyz/b.pyz//some/share/a.pyz//some/share/*.pyz//other/share/a.pyz//some/share/a/b.pyzB.pyzb.PYz	c:/a/B.Pyz	C:/A/*.pYz//Some/Share/B.Pyz//somE/sharE/*.pY)rArvr�r�)rrErrr
r�s&z%PureWindowsPathTest.test_match_commoncs��fdd�}�j}|d�}|d�}|||��j||k��j||k�|d�}|d�}|||��j||k��j||k�dS)Ncs�j||��j||�dS)N)ZassertLessEqual�assertGreaterEqual)rr)rrr
�assertOrderedEqualszDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualzc:A/bzC:a/Bz//some/Share/A/bz//Some/SHARE/a/B)rAr�)rr�rErBr~r)rr
r�s

z(PureWindowsPathTest.test_ordering_commoncCsX|j}|d�}|j}|j|d�|d�}|j}|j|d�|d�}|j}|j|d
�dS)Nzc:a/b�c:rrzc:/a/b�c:\z	//a/b/c/d�\\a\b\rr)r�rr)r�rr)r�rr)rArJr)rrErBrJrrr
�
test_parts,szPureWindowsPathTest.test_partscCs|j}|d�}|j|j|d��|j|jj|d��|j|jjj|d��|j|jjjj|d��|d�}|j|j|d��|j|jj|d��|j|jjj|d��|j|jjjj|d��|d	�}|j|j|d
��|j|jj|d��|j|jjj|d��dS)Nzz:a/b/czz:a/bzz:azz:zz:/a/b/czz:/a/bzz:/azz:/z	//a/b/c/dz//a/b/cz//a/b)rArr�)rrErBrrr
�test_parent8szPureWindowsPathTest.test_parentcCs�|j}|d�}|j}|jt|�d�|j|d|d��|j|d|d��|jt|�|d�|d�g�|jt��|dWdQRX|d�}|j}|jt|�d�|j|d|d��|j|d|d	��|jt|�|d�|d	�g�|jt��|dWdQRX|d
�}|j}|jt|�d�|j|d|d��|j|d|d��|jt|�|d�|d�g�|jt��|dWdQRXdS)
Nzz:a/b/r�rzz:arrzz:zz:/a/b/zz:/azz:/z	//a/b/c/dz//a/b/cz//a/b)rAr�rryr�rhr�)rrErBr�rrr
�test_parentsJs2z PureWindowsPathTest.test_parentscCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�dS)	Nzc:zc:a/bzc:/zc:/a/b/z//a/bz\\a\bz//a/b/z	//a/b/c/d)rArr�)rrErrr
�
test_drivefszPureWindowsPathTest.test_drivecCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d	�jd�dS)
Nzc:rzc:a/bzc:/r.zc:/a/b/z//a/bz//a/b/z	//a/b/c/d)rArr�)rrErrr
r�pszPureWindowsPathTest.test_rootcCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d	�jd�dS)
Nzc:zc:a/bzc:/zc:\zc:/a/b/z//a/bz\\a\b\z//a/b/z	//a/b/c/d)rArr�)rrErrr
�test_anchorzszPureWindowsPathTest.test_anchorcCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d	�jd�|j|d
�jd�|j|d�jd�dS)Nzc:rzc:/zc:a/brzc:/a/bzc:a/b.pyzb.pyz	c:/a/b.pyz//My.py/Share.phpz//My.py/Share.php/a/b)rArr�)rrErrr
�	test_name�szPureWindowsPathTest.test_namecCs*|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d	�jd�|j|d
�jd�|j|d�jd�|j|d
�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�dS)Nzc:rzc:/zc:a/bzc:/a/bzc:a/b.pyz.pyz	c:/a/b.pyz	c:a/.hgrcz
c:/a/.hgrcz
c:a/.hg.rcz.rczc:/a/.hg.rczc:a/b.tar.gzz.gzz
c:/a/b.tar.gzz!c:a/Some name. Ending with a dot.z"c:/a/Some name. Ending with a dot.z//My.py/Share.phpz//My.py/Share.php/a/b)rArr�)rrErrr
�test_suffix�s"zPureWindowsPathTest.test_suffixcCs:|j}|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jdg�|j|d�jdg�|j|d�jg�|j|d	�jg�|j|d
�jdg�|j|d�jdg�|j|d
�jddg�|j|d�jddg�|j|d�jg�|j|d�jg�|j|d�jg�|j|d�jg�dS)Nzc:zc:/zc:a/bzc:/a/bzc:a/b.pyz.pyz	c:/a/b.pyz	c:a/.hgrcz
c:/a/.hgrcz
c:a/.hg.rcz.rczc:/a/.hg.rczc:a/b.tar.gzz.tarz.gzz
c:/a/b.tar.gzz//My.py/Share.phpz//My.py/Share.php/a/bz!c:a/Some name. Ending with a dot.z"c:/a/Some name. Ending with a dot.)rArr�)rrErrr
�
test_suffixes�s"z!PureWindowsPathTest.test_suffixescCs�|j}|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d�jd�|j|d	�jd�|j|d
�jd�|j|d�jd
�|j|d�jd�|j|d�jd�dS)Nzc:rzc:.zc:..z..zc:/zc:a/brzc:a/b.pyz	c:a/.hgrcz.hgrcz
c:a/.hg.rcz.hgzc:a/b.tar.gzzb.tarz!c:a/Some name. Ending with a dot.zSome name. Ending with a dot.)rArr�)rrErrr
�	test_stem�szPureWindowsPathTest.test_stemcCs�|j}|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|jt|d�jd�|jt|d	�jd�|jt|d
�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd
�|jt|d�jd
�dS)Nzc:a/bzd.xmlz	c:a/d.xmlzc:/a/bz
c:/a/d.xmlzc:a/Dot ending.zc:/a/Dot ending.zc:zc:/z
//My/Sharezd:zd:ezd:/e)rArr�rhri)rrErrr
�test_with_name�sz"PureWindowsPathTest.test_with_namecCs�|j}|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|j|d�jd�|d��|jt|d�jd�|jt|d	�jd�|jt|d
�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd
�|jt|d�jd
�|jt|d�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd�|jt|d�jd�dS)Nzc:a/bz.gzzc:a/b.gzzc:/a/bz	c:/a/b.gzzc:a/b.pyz	c:/a/b.pyrrrz
//My/Sharer�r.zc:z/.gzz\.gzzc:.gzzc/dzc\dz.c/dz.c\d)rArr�rhri)rrErrr
�test_with_suffix�s(z$PureWindowsPathTest.test_with_suffixcCs0|j}|d�}|j|j|d��|d��|j|jd�|d��|j|j|d��|d��|j|jd�|d��|j|jd�|d��|j|j|d��|��|j|jd�|��|jt|j|��|jt|jd�|jt|j|d	��|jt|j|d
��|jt|j|d��|jt|j|d��|jt|j|d
��|jt|j|d��|jt|j|d��|d�}|j|j|d��|d��|j|jd�|d��|jt|j|d���d�|jt|jd��d�|j|j|d��|d��|j|jd�|d��|j|j|d��|d��|j|jd�|d��|j|jd�|d��|j|j|d��|��|j|jd�|��|jt|j|d��|jt|j|d��|jt|j|d��|jt|j|d��|jt|j|d	��|jt|j|d��|jt|j|d
��|jt|j|d��|jt|j|d��|d�}|j|j|d��|d��|j|jd�|d��|j|jd�|d��|j|j|d ��|d��|j|jd �|d��|j|jd!�|d��|j|j|d"��|��|j|jd"�|��|jt|j|d#��|jt|j|d$��|jt|j|d%��|jt|j|d&��dS)'Nz	C:Foo/Barzc:zFoo/Barzc:foOZBarzc:foO/z	c:foO/baRrzd:rZFooz/FoozC:/Fooz
C:Foo/Bar/Bazz	C:Foo/Bazz
C:/Foo/Barz/Foo/Barz\Foo\Barzc:/zc:/foOzc:/foO/z
c:/foO/baRzC:/BazzC:/Foo/Bar/Bazz
C:/Foo/BazzC:Foozd:/z//C/Fooz//Server/Share/Foo/Barz//sErver/sHarez//sErver/sHare/z//sErver/sHare/Fooz//sErver/sHare/Foo/z//sErver/sHare/Foo/Barz/Server/Share/Foozc:/Server/Share/Fooz
//z/Share/Fooz//Server/z/Foo)rArr�rhrirI)rrErBrrr
�test_relative_to�shz$PureWindowsPathTest.test_relative_tocCs(|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|d	�j��|j|d
�j��|j|d�j��|j|d�j��|j|d
�j��|j|d�j��|j|d�j��dS)Nrza/b/rz/az/a/b/zc:zc:azc:a/b/zc:/zc:/azc:/a/b/z//a/bz//a/b/z//a/b/cz	//a/b/c/d)rAr�r�rv)rrErrr
r�#s"z$PureWindowsPathTest.test_is_absolutecCs�|j}|d�}|jd�}|j||d��|jd�}|j||d��|jd�}|j||d��|jd�}|j||d��|jd�}|j||d��|jd	�}|j||d��|jd
�}|j||d��dS)NzC:/a/bzx/yz
C:/a/b/x/yz/x/yzC:/x/yzD:x/yzD:/x/yz//host/share/x/yzc:x/yzc:/x/y)rArQr)rrErBrRrrr
r�8s 






zPureWindowsPathTest.test_joincCs�|j}|d�}|j|d|d��|j|dd|d��|j|d|d��|j|dd|d��|j|d	|d	��|j|d
d|d	��|j|d|d��|j|d
d|d��|j|d|d��|j|d
|d��|j|d|d��dS)NzC:/a/bzx/yz
C:/a/b/x/yr
�yz/x/yzC:/x/yz/xzD:x/yzD:zD:/x/yz//host/share/x/yzc:x/yzc:/x/y)rAr)rrErBrrr
r�NszPureWindowsPathTest.test_divcCs"|j}|jd|d�j��|jd|d�j��|jd|d�j��|jd|d�j��|jd|d�j��|jd|d�j��|jd|d	�j��|jd|d
�j��|jd|d�j��|jd|d�j��|jd|d
�j��|jd|d�j��|jd|d�j��|jd|d�j��dS)NFrrz/foo/barTZconZNULzNUL.txtZcom1zcom9.barzbar.com9Zlpt1zlpt9.barzbar.lpt9zc:/NUL/con/bazz//my/share/nul/con/aux)rArKr�)rrErrr
r�bsz$PureWindowsPathTest.test_is_reservedN)r�r)r�r�)rr�r)r�r)r�rr)r�r�)r�r�r)r�r�r)r�)r�r)r�r)!rr r!r,�PureWindowsPathrAr4r��copy�updater�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
r��s>



:r�c@s*eZdZejZdd�Zdd�Zdd�ZdS)�PurePathTestcCs0|jd�}|jt|�tjdkr$tjntj�dS)Nr�nt)rArKrLrdr�r,r�r�)rrBrrr
�test_concrete_classxs

z PurePathTest.test_concrete_classcCs$tjd�}tjd�}|j||�dS)Nr)r,r�r�r�)rrBr~rrr
�test_different_flavours_unequal}s

z,PurePathTest.test_different_flavours_unequalcCs�tjd�}tjd�}|jt��||kWdQRX|jt��||kWdQRX|jt��||kWdQRX|jt��||kWdQRXdS)Nr)r,r�r�rhr�)rrBr~rrr
�!test_different_flavours_unordered�s

z.PurePathTest.test_different_flavours_unorderedN)	rr r!r,ZPurePathrAr�r�r�rrrr
r�usr�cGstjjtf|��S)N)rd�path�join�BASE)r
rrr
�<lambda>�sr�cGstjjtf|��S)N)rdr�r�r)r
rrr
r��scCsNtjs
dSytjtt�Wn$tk
r>}zt|�Sd}~XnXtj	t�dS)Nzno system support for symlinks)
r,Zsupports_symlinksrd�symlink�__file__r��OSErrorrIr�unlink)�errr
�symlink_skip_reason�s
r�r�z)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc@seZdZejZdS)�PosixPathAsPureTestN)rr r!r,�	PosixPathrArrrr
r��sr�c@s"eZdZejZdd�Zdd�ZdS)�WindowsPathAsPureTestc	Cs,|j}|jt��|d�j�WdQRXdS)Nzc:/)rArh�NotImplementedError�owner)rrErrr
�
test_owner�sz WindowsPathAsPureTest.test_ownerc	Cs,|j}|jt��|d�j�WdQRXdS)Nzc:/)rArhr�group)rrErrr
�
test_group�sz WindowsPathAsPureTest.test_groupN)rr r!r,�WindowsPathrArrrrrr
r�src@s�eZdZdZdd�Zejdkr(dd�Zndd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zed$d%��Zd&d'�Zd(d)�Zd*d+�Zed,d-��Zd.d/�Zd�d1d2�ZeZZed3d4��Z ed5d6��Z!d7d8�Z"d9d:�Z#d;d<�Z$ed=d>��Z%d?d@�Z&e'j(e)dA�dBdC��Z*e'j(e+dD�dEdF��Z,dGdH�Z-dIdJ�Z.dKdL�Z/dMdN�Z0dOdP�Z1dQdR�Z2dSdT�Z3dUdV�Z4dWdX�Z5dYdZ�Z6d[d\�Z7e8d]d^��Z9d_d`�Z:dadb�Z;dcdd�Z<ededf��Z=dgdh�Z>didj�Z?dkdl�Z@dmdn�ZAe'j(eBedo�dp�dqdr��ZCdsdt�ZDe'j(eBeEdu�dv�dwdx��ZFdydz�ZGd{d|�ZHd}d~�ZIdd��ZJd�d��ZKd�d��ZLed�d���ZMed�d���ZNed�d���ZOd�S)��
_BasePathTestz?Tests for the FS-accessing functionalities of the Path classes.c!Cs~dd�}|j|�tjt�tjtd��tjtd��tjtd��tjtdd��tjtd��ttd�d	��}|jd
�WdQRXttdd�d	��}|jd�WdQRXttdd
�d	��}|jd�WdQRXttddd�d	��}|jd�WdQRXtjtd�d�t�sztj	dtd��tj	dtd��|j
dtd��|j
tjjdd�tdd��|j
tjjdd�tdd��dS)NcSstjtd�d�tjt�dS)N�dirEi�)rd�chmodr�r�rmtreer�rrrr
�cleanup�sz$_BasePathTest.setUp.<locals>.cleanup�dirA�dirB�dirCZdirDr	�fileA�wbsthis is file A
�fileBsthis is file B
ZfileCsthis is file C
ZfileDsthis is file D
r�linkAznon-existing�
brokenLink�linkBz..�linkC�linkD)�
addCleanuprd�mkdirr�r��open�writer
r�r��dirlinkr�)rrrrrr
rC�s.

z_BasePathTest.setUpr�cCstj||dd�dS)NT)�target_is_directory)rdr�)r�src�destrrr
r�sz_BasePathTest.dirlinkcCstj||�dS)N)rdr�)rrrrrr
r�scCs*|jtjjt|�t|��d||f�dS)Nz&%r and %r don't point to the same file)rvrdr��samefilerI)rZpath_aZpath_brrr
�
assertSame�sz_BasePathTest.assertSamec
Os6|jt��}|||�WdQRX|j|jjtj�dS)N)rh�FileNotFoundErrorr�	exception�errno�ENOENT)r�funcrM�kwargs�cmrrr
�assertFileNotFound�sz _BasePathTest.assertFileNotFoundcCsT|jtj��}|j||�|jt|�t|��|jt|�t|��|j|j��dS)N)	rArd�getcwdrrIrKrLrvr�)rrBr~rrr
�	_test_cwds
z_BasePathTest._test_cwdcCs|jj�}|j|�dS)N)rA�cwdr+)rrBrrr
�test_cwd
s
z_BasePathTest.test_cwdcCsX|jtjjd��}|j||�|jt|�t|��|jt|�t|��|j|j	��dS)N�~)
rArdr��
expanduserrrIrKrLrvr�)rrBr~rrr
�
_test_homes
z_BasePathTest._test_homecCs|jj�}|j|�dS)N)rA�homer0)rrBrrr
�	test_homes
z_BasePathTest.test_homecCs�tjjtd�}tjjtdd�}|j|�}|j|�}|j|�}|j|j|��|j|j|��|j|j|��|j|j|��tjjtd�}|j|�}|jt	|j|�|jt	|j|�|jt	|j|�|jt	|j|�|jt	|j|�|jt	|j|�dS)Nrrr�foo)
rdr�r�r�rArvr r�rhr")rZ
fileA_pathZ
fileB_pathrBrRr~Znon_existentr|rrr
�
test_samefiles"



z_BasePathTest.test_samefilecCs$|jd�}|j|j�tjd��dS)Nrr)rAr�statrd)rrBrrr
�test_empty_path-s
z_BasePathTest.test_empty_pathcCs�|j}|d�}|j|j�|tjjd���|d�}|j|j�|�|d�}|j|j�|�|d�}|j|j�|�||d�j�j�d}|j|j�|�dS)Nr.r3z/~z../~r)rArr/rdr��absoluter�)rrErBrrr
�test_expanduser_common2sz$_BasePathTest.test_expanduser_commoncCs�|j}|t�}|jd|j��|jd|dj��|jd|dj��|jd|ddj��ts�|jd|dj��|jd|dj��|jd|ddj��|jd|ddj��|jd|d	j��|jd|d
�j��dS)NTr
rF�bahrrrr3z/xyzzy)rAr�rK�existsr�)rrErBrrr
�test_exists?sz_BasePathTest.test_existscCs�|jt�}|djd��$}|j|tj�|j|j�d�WdQRX|djd��(}|j|tj�|j|j�j	�d�WdQRX|djddd��(}|j|tj
�|j|j�j	�d�WdQRXdS)Nrr|zthis is file A
�rbsthis is file Ar)�	buffering)rAr�rrD�io�
TextIOBaser�read�BufferedIOBase�strip�	RawIOBase)rrBrrrr
�test_open_commonNs
z_BasePathTest.test_open_commoncCsX|jt�}|djd�|j|dj�d�|jt|djd�|j|dj�d�dS)NrsabcdefgZsomestr)rAr�Zwrite_bytesrZ
read_bytesrhr�)rrBrrr
�test_read_write_bytesZs

z#_BasePathTest.test_read_write_bytescCsf|jt�}|djddd�|j|djddd�d�|jt|djd	�|j|djdd�d�dS)
Nruäbcdefgzlatin-1)�encodingzutf-8�ignore)rF�errorsZbcdefgs	somebytes)rAr�Z
write_textrZ	read_textrhr�)rrBrrr
�test_read_write_textbs
z"_BasePathTest.test_read_write_textcs\|j��t�}|j�}t|�}dddddg}ts>|dddg7}|j|�fd	d
�|D��dS)Nr
rrr	rrrrcsh|]}�t|��qSr)r�)r	r~)rErr
�	<setcomp>ssz-_BasePathTest.test_iterdir.<locals>.<setcomp>)rAr��iterdir�setr�r)rrB�it�pathsrr)rEr
�test_iterdirksz_BasePathTest.test_iterdircs>|j��td�}t|j��}�fdd�dD�}|j||�dS)Nrcsh|]}�td|��qS)r)r�)r	r~)rErr
rJ{sz5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>rr)rr)rAr�rLrKr)rrBrNrr)rEr
�test_iterdir_symlinkus

z"_BasePathTest.test_iterdir_symlinkcCsN|jtd�}|jt��}t|j��WdQRX|j|jjtj	tj
tjf�dS)Nr)rAr�rhr��nextrK�assertInr#r$�ENOTDIRr%ZEINVAL)rrBr(rrr
�test_iterdir_nodir~s
z _BasePathTest.test_iterdir_nodircs���fdd�}�j��t�}|jd�}�j|tj�||dg�||jd�g�||jd�ddg�tr~||jd�d	dg�n||jd�d	dd
g�tr�||jd�dg�n||jd�ddd
dg�tr�||jd�dg�n||jd�dd
g�dS)Ncs"�jt|��fdd�|D��dS)Ncsh|]}�t|��qSr)r�)r	r~)rErr
rJ�szA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>)rrL)�globr)rErrr
�_check�sz._BasePathTest.test_glob_common.<locals>._checkrrz
dir*/file*z
dirB/fileBz
dirC/fileCz*Ar
rz*B/*z
dirB/linkDzlinkB/fileBzlinkB/linkDz*/fileB)rAr�rUrD�collections�Iteratorr�)rrVrBrMr)rErr
�test_glob_common�s$

z_BasePathTest.test_glob_commoncs���fdd�}�j��t�}|jd�}�j|tj�||dg�||jd�dg�||jd�g�trz||jd�dg�n||jd�ddd	d
g�||jd�dddd
g��td�}||jd�dd
g�||jd�d
g�dS)Ncs"�jt|��fdd�|D��dS)Ncsh|]}�t|��qSr)r�)r	r~)rErr
rJ�szB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>)rrL)rUr)rErrr
rV�sz/_BasePathTest.test_rglob_common.<locals>._checkrrz
dirB/fileBz*/fileAz*/fileBzdirB/linkD/fileBzlinkB/fileBzdirA/linkC/fileBzfile*z
dirC/fileCzdirC/dirD/fileDrz*/*)rAr��rglobrDrWrXr�)rrVrBrMr)rErr
�test_rglob_common�s"



z_BasePathTest.test_rglob_commoncsZ|j}|t��t�jd��}dddddddd	d
ddd
ddh}|j|�fdd�|D��dS)N�*rr
z
dirA/linkCrz
dirB/fileBz
dirB/linkDrz	dirC/dirDzdirC/dirD/fileDz
dirC/fileCr	rrrcsh|]}�|�qSrr)r	r
)rBrr
rJ�sz8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)rAr�rLrZr)rrE�given�expectr)rBr
�test_rglob_symlink_loop�sz%_BasePathTest.test_rglob_symlink_loopcCsf|j}|t�}|jt|jd��|td�h�|jt|jd��|td�h�|jt|jd��t��dS)Nz..z
dirA/../file*z
dirA/../fileAz../xyzzy)rAr�rrLrU)rrErBrrr
�test_glob_dotdot�s
z_BasePathTest.test_glob_dotdotTcCs|j|�}|j||�dS)N)�resolver)rrBr�strictr~rrr
�_check_resolve�s
z_BasePathTest._check_resolvecCs�|j}|td�}|jt��}|jdd�WdQRX|j|jjtj�|jt	|jdd��t
jjtd��|tddd�}|jt	|jdd��t
jjtddd��|tdddd�}|jt	|jdd��t
jj
t
jjddd���|tdd	�}|j||�|td
�}|j||td��|tdd
d	�}|j||tdd	��|tddd	�}|j||tdd	��|tdd
d	ddd�}|j||tdd	ddd�d�|tdd
dddd�}t
jdk�r�|j||tdddd�d�n|j||tddd�d�tjtjdd��}|jtj|�t
jt
jj|�tdd��t
jtd�t
jj|d��|tdddd	�}|j||tdd	��|tdddddd�}|j||tdddd�d�|tddddddd�}t
jdk�r�|j|||ddd�d�n|j||tddd�d�dS)Nr3T)rbF�inZspamz..rrrrr
rrr�z-dirD)r��linkX�linkY)rAr�rhr�rarr#r$r%rIrdr�r��abspath�_check_resolve_relativer�rZ	_longpath�tempfileZmkdtemprrr��_check_resolve_absolute)rrErBr(rrrr
�test_resolve_common�sT


z!_BasePathTest.test_resolve_commoncCs�|jt�}|jdtd��|jtjjdd�td��|jtjjdd�td��|d}|j|jdd�|�|dd}|jt	|jdd�|j|jd	d�|dd�dS)
Nr�0�1�2T)rb�3�4F)
rAr�rr�rdr�rrarhr")rrBr~r|rrr
�test_resolve_dots
z_BasePathTest.test_resolve_dotcCs�|jt�}|j�}|j�}t|�|�WdQRX|jtt|�|jtt|�|jt|j�|jt|j�|jt|j�|jt|j	�dS)N)
rAr�rKrQrhrirrar7�	__enter__)rrBrMZit2rrr
�	test_with s

z_BasePathTest.test_withcCsd|jt�d}|j�j}|d@}|j|�|j|j�j|�|dB}|j|�|j|j�j|�dS)Nr�im���)rAr�r5�st_moder
r)rrB�modeZnew_moderrr
�
test_chmod/s


z_BasePathTest.test_chmodcCsZ|jt�d}|j�}|j|j�|�|j|jdA�|j|j|j�|j|j�|�dS)Nrrt)rAr�r5rr
rurr�)rrB�strrr
�	test_stat=sz_BasePathTest.test_statcCs*|jt�d}|j�}|j||j��dS)Nr)rAr�r5r��lstat)rrBrxrrr
�
test_lstatFsz_BasePathTest.test_lstatcCs*|jt�d}|j�}|j||j��dS)Nr)rAr�r5rrz)rrBrxrrr
�test_lstat_nosymlinkLsz"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testcCs`|jt�d}|j�j}ytj|�j}Wn"tk
rJ|jd|�YnX|j	||j
��dS)Nrz4user %d doesn't have an entry in the system database)rAr�r5�st_uid�pwd�getpwuid�pw_name�KeyErrorr�rr)rrBZuidr�rrr
rQs
z_BasePathTest.test_ownerz&the grp module is needed for this testcCs`|jt�d}|j�j}ytj|�j}Wn"tk
rJ|jd|�YnX|j	||j
��dS)Nrz5group %d doesn't have an entry in the system database)rAr�r5�st_gid�grpZgetgrgidZgr_namer�r�rr)rrB�gidr�rrr
r\s
z_BasePathTest.test_groupcCs2|jt�d}|j�|j|j�|j|j�dS)Nr)rAr�r�r)r5)rrBrrr
�test_unlinkgsz_BasePathTest.test_unlinkcCsL|jt�d}x|j�D]}|j�qW|j�|j|j�|j|j�dS)Nr
)rAr�rKr��rmdirr)r5)rrBr~rrr
�
test_rmdirmsz_BasePathTest.test_rmdircCs�|jt�}|d}|j�j}|dd}|j|�|j|j�j|�|j|j�td�}|j|�|jtj|�j|�|j|j�dS)Nrr
�fileAAZfileAAA)	rAr�r5�st_size�renamerr)�rel_joinrd)rrErB�sizer~r|rrr
�test_renameus



z_BasePathTest.test_renamecCs�|jt�}|d}|j�j}|dd}|j|�|j|j�j|�|j|j�tdd�}|j|�|jtj|�j|�|j|j�dS)Nrr
r�rr)	rAr�r5r�rrr)r�rd)rrErBr�r~r|rrr
�test_replace�s




z_BasePathTest.test_replacecCs�|jt�}|d}|j|j��|j�|j|j��|j�}|j}|j}t	j
t|�|d|df�|j�|j�}|j|j|�|j|j|�|d}|j|j��|jddd�|j|j��|j
t|jdd�dS)NZnewfileA�
ZnewfileBi�F)rv�exist_ok)r�)rAr�r�r:�touchrvr5�st_mtime�st_mtime_nsrd�utimerIr�rhr�)rrErBrxZ	old_mtimeZold_mtime_nsrrr
�test_touch_common�s$
z_BasePathTest.test_touch_commonc
CsH|jt�}|d}|j�|jd��}|j|j�j�d�WdQRXdS)Nrr<sthis is file A)rAr�r�rrr@rB)rrErBrrrr
�test_touch_nochange�s

z!_BasePathTest.test_touch_nochangec
Csx|jt�}|d}|j|j��|j�|j|j��|j|j��|jt��}|j�WdQRX|j	|j
jtj�dS)NZnewdirA)
rAr�r�r:rrv�is_dirrhr�rr#r$�EEXIST)rrErBr(rrr
�
test_mkdir�s
z_BasePathTest.test_mkdircCs6|jtdd�}|j|j��|jt��}|j�WdQRX|j|jj	t	j
�|jdd�|j|j��|j|j��|jt��}|jdd�WdQRX|j|jj	t	j
�tj|j�j�}|jtdd�}|jddd�|j|j��|j|j��tjdk�r|jtj|j�j�d	|@�|jtj|jj�j�|�dS)
NZnewdirB�newdirCT)r�ZnewdirDZnewdirEimr�im)rAr�r�r:rhr�rrr#r$r%rvr�r�r5�S_IMODErurdr�r�)rrBr(rvrrr
�test_mkdir_parents�s&z _BasePathTest.test_mkdir_parentsc
Cs�|jtd�}|j�j}|j|j��|j|j��|jt��}|j	�WdQRX|j
|jjtj
�|j	dd�|j|j��|j
|j�j|�dS)NrT)r�)rAr�r5�st_ctimervr:r�rh�FileExistsErrorrrr#r$r�)rrB�st_ctime_firstr(rrr
�test_mkdir_exist_ok�s
z!_BasePathTest.test_mkdir_exist_okcCs�|jtd�}|j|j��|jt��}|j�WdQRX|j|jj	t	j
�|d}|jdd�|j�j}|j|j��|jt��}|jdd�WdQRX|j|jj	t	j
�|jddd�|j|j��|j|j�j|�dS)Nrr�T)r�)r�r�)
rAr�rvr:rhr�rrr#r$r�r5r�)rrBr(r�rrr
�test_mkdir_exist_ok_with_parent�s
z-_BasePathTest.test_mkdir_exist_ok_with_parentcCs2|jd�j�jdd�|jd�j�jddd�dS)NrT)r�)r�r�)rArar)rrrr
�test_mkdir_exist_ok_root�sz&_BasePathTest.test_mkdir_exist_ok_rootc
Cs^x.dD]}|j|d�}|j�sPqW|jd�|jt��|ddjdd�WdQRXdS)NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't existZchildr�T)r�)rAr�r�rhr�r)rrrBrrr
�test_mkdir_with_unknown_drive�s

z+_BasePathTest.test_mkdir_with_unknown_drivecCs�|jtdd�}|j|j��|jt��}|jdd�WdQRX|j|jj	t	j
�|jt��}|jddd�WdQRX|j|jj	t	j
�dS)NrrT)r�)r�r�)rAr�rvr:rhr�rrr#r$r�)rrBr(rrr
�test_mkdir_with_child_filesz(_BasePathTest.test_mkdir_with_child_filecCs�|jtd�}|j|j��|jt��}|j�WdQRX|j|jj	t	j
�|jt��}|jdd�WdQRX|j|jj	t	j
�dS)NrT)r�)rAr�rvr:rhr�rrr#r$r�)rrBr(rrr
�test_mkdir_no_parents_filesz(_BasePathTest.test_mkdir_no_parents_filecs�x�td�D]ȉ|jtd��}|j|j��d��fdd�	}�fdd�td�D��t��|d	d
}y*tjd|��|jdd
d�WdQRXWn$t	k
r�|j
t|���YnX|jt|���|j
|j��q
WdS)N� zdirCPC%d�cs6t|�}�j�r&tj||��j|�tj||�dS)N)rI�poprdr�add)r�rv)�concurrently_created�patternrr
�my_mkdir s

zE_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.my_mkdircsg|]}t�d|>@��qS)rr)�bool)r	�n)�pattern_numrr
r,szG_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.<listcomp>�Zdir1Zdir2zpathlib._normal_accessor.mkdirTF)r�r�)r�)r�rAr�r�r:rLrZpatchrr�rRrIZassertNotInrv)rrBr�Zp12r)r�r�r�r
�%test_mkdir_concurrent_parent_creationsz3_BasePathTest.test_mkdir_concurrent_parent_creationcCs|jt�}|d}|dd}|j|�|j|j�|j��|j|j�|j��|dd}|jt|��|j|j�|j��|j|j�|j��|j|j	��|d}|dd}|j|dd�|j|j�|j��|j|j�|j��|j
|j	��|j
t|j���dS)	Nrr
ZlinkAAZlinkAAArZlinkAAAAT)r)
rAr�Z
symlink_torr5r�rzrIr�r�rvr�rK)rrE�target�linkrrr
�test_symlink_to8s$

z_BasePathTest.test_symlink_tocCs�|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��ts�|j|dj��|j|dj��|j|dj��dS)Nr
rznon-existingr9rrr)rAr�rvr�r�r�)rrErrr
�test_is_dirPs
z_BasePathTest.test_is_dircCs�|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��ts�|j|dj��|j|dj��|j|dj��dS)Nrr
znon-existingr9rrr)rAr�rv�is_filer�r�)rrErrr
�test_is_file[s
z_BasePathTest.test_is_filecCs�|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��ts�|j|dj��|j|dj��|j|dj��dS)Nrr
znon-existingr9rrr)rAr�r��
is_symlinkr�rv)rrErrr
�test_is_symlinkfs
z_BasePathTest.test_is_symlinkcCsZ|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr
znon-existingr9)rAr�r��is_fifo)rrErrr
�test_is_fifo_falseqs

z _BasePathTest.test_is_fifo_false�mkfifozos.mkfifo() requiredcCs~|jtd�}ytjt|��Wn0tk
rN}z|jd|�WYdd}~XnX|j|j��|j	|j
��|j	|j��dS)NZmyfifozos.mkfifo(): %s)rAr�rdr�rI�PermissionErrorr�rvr�r��	is_socketr�)rrEr�rrr
�test_is_fifo_truexs z_BasePathTest.test_is_fifo_truecCsZ|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr
znon-existingr9)rAr�r�r�)rrErrr
�test_is_socket_false�s

z"_BasePathTest.test_is_socket_false�AF_UNIXzUnix sockets requiredcCs�|jtd�}tjtjtj�}|j|j�y|jt|��WnJt	k
r�}z.t
|t�sbdt|�krt|jdt|��WYdd}~XnX|j
|j��|j|j��|j|j��dS)NZmysockzAF_UNIX path too longzcannot bind Unix socket: )rAr��socketr�ZSOCK_STREAMr�closeZbindrIr��
isinstancer�r�rvr�r�r�r�)rrEZsockr�rrr
�test_is_socket_true�s
$z!_BasePathTest.test_is_socket_truecCsZ|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr
znon-existingr9)rAr�r��is_block_device)rrErrr
�test_is_block_device_false�s

z(_BasePathTest.test_is_block_device_falsecCsZ|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr
znon-existingr9)rAr�r��is_char_device)rrErrr
�test_is_char_device_false�s

z'_BasePathTest.test_is_char_device_falsecCsJ|jd�}|j�s|jd�|j|j��|j|j��|j|j��dS)Nz	/dev/nullz/dev/null required)rAr:r�rvr�r�r�r�)rrErrr
�test_is_char_device_true�s

z&_BasePathTest.test_is_char_device_truecCsT|jtd�}xBtdtjd�D].}tj||�}tj|�}|j|j�|j��qWdS)Nrrrr)	rAr�r�r�r�r�r�rr5)rrBr�r�rRrrr
r��s

z"_BasePathTest.test_pickling_commoncCsJ|j}|d�}|d�}|j|jd|jd�|j|jd|jd�dS)Nz/usr/bin/fooz/usr/local/binrrr�r�)rArKrJ)rrErBr~rrr
�test_parts_interning�s
z"_BasePathTest.test_parts_interningcCs�|jt�}|jtjjdd�td��|jtjjdd�td��|jtjjdd�td��|j|td��|dj�}|j||�|jt|�t�|dj�}|j||�|jt|�t�|dj�}|j||�|jt|�t�|dj�}|j||�|jt|�t�tj	�}tj
t�z�|jd�j�}|j||�|jt|�t�|jd�j�}|j||�|jt|�t�|jd�j�}|j||�|jt|�t�|jd�j�}|j||�|jt|�t�Wdtj
|�XdS)NZlink0Zlink1Zlink2Zlink3)rAr�rrdr�r�rarrIr*�chdir)rZlink0_targetrErBZold_pathrrr
�_check_complex_symlinks�sB

z%_BasePathTest._check_complex_symlinkscCs|jt�dS)N)r�r�)rrrr
�test_complex_symlinks_absolute�sz,_BasePathTest.test_complex_symlinks_absolutecCs|jd�dS)Nr)r�)rrrr
�test_complex_symlinks_relative�sz,_BasePathTest.test_complex_symlinks_relativecCs|jtjjdd��dS)Nr
z..)r�rdr�r�)rrrr
�&test_complex_symlinks_relative_dot_dot�sz4_BasePathTest.test_complex_symlinks_relative_dot_dotN)T)Prr r!�__doc__rCrdr�rr!r)r+r-r0r2r4r6r8r;rDrErIrO�
with_symlinksrPrTrYr[r_r`rcrhrjrkrqrsrwryr{r|�unittest�
skipUnlessr~rr�rr�r�r�r�r�r�r�r�r�r�r��only_ntr�r�r�r�r�r�r�r�r��hasattrr�r�r�r�r�r�r�r�r�r�r�r�r�rrrr
r�s�


	
	
	
<			)rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�PathTestcCs0|jd�}|jt|�tjdkr$tjntj�dS)Nrr�)rArKrLrdr�r,rr)rrBrrr
r��s

zPathTest.test_concrete_classcCs,tjdkr|jttj�n|jttj�dS)Nr�)rdr�rhrr,rr)rrrr
�test_unsupported_flavour�s
z!PathTest.test_unsupported_flavourc
Cs2|j�}|jtd��t|jd��WdQRXdS)NzUnacceptable patternr)rAZassertRaisesRegexrir�rU)rrBrrr
�test_glob_empty_patternsz PathTest.test_glob_empty_patternN)	rr r!r,ZPathrAr�r�r�rrrr
r��sr�c@sfeZdZejZdd�dd�Zdd�Zdd�Ze	d	d
��Z
dd�Zd
d�Ze
jeed�d�dd��ZdS)�
PosixPathTestT)rbc
Gs2|j|�}|jt��t|j|��WdQRXdS)N)rArh�RuntimeError�printra)rrbrMr�rrr
�_check_symlink_loops
z!PosixPathTest._check_symlink_loopcCs�tjd�}|jtj|�|jt�}|djd��WdQRXtjtd��}|jtj	|j
�d�tjd�|djd��WdQRXtjtd��}|jtj	|j
�d�dS)Nr�new_fileri���other_new_filei�)rd�umaskrrAr�rr5r�rr�ru)r�old_maskrBrxrrr
�test_open_modes




zPosixPathTest.test_open_modecCs�tjd�}|jtj|�|jt�}|dj�tjtd��}|jtj	|j
�d�tjd�|dj�tjtd��}|jtj	|j
�d�|djdd	�tjtd��}|jtj	|j
�d�dS)
Nrr�i�r�r�i�Zmasked_new_filei�)rv)rdr�rrAr�r�r5r�rr�ru)rr�rBrxrrr
�test_touch_mode!s


zPosixPathTest.test_touch_modecCs�tjdtd��|jtd�tjdtd��|jtd�tjdtd��|jtd�|jtdddd�tjtd	�td
��|jtd
�tjtd�td��|jtd�tjtd�td
��|jtd
�|jtd
ddd�dS)NzlinkX/insidererfzlinkZ/../linkZZlinkZr3F)rbzlinkU/insideZlinkUZlinkVzlinkW/../linkWZlinkW)rdr�r�r�r�)rrrr
�test_resolve_loop0szPosixPathTest.test_resolve_loopcCsX|j}|t�}t|jd��}tjt�s,t�n|}|j||�|jt|jd��t��dS)N�FILEazFILEa*)rAr�rLrUr�fs_is_case_insensitiver)rrErBr]r^rrr
�	test_globEszPosixPathTest.test_globcCsZ|j}|td�}t|jd��}tjt�s.t�n|}|j||�|jt|jd��t��dS)Nr�FILEdzFILEd*)rAr�rLrZrr�r)rrErBr]r^rrr
�
test_rglobMs
zPosixPathTest.test_rglob�getpwallz%pwd module does not expose getpwall()cCs|j}tjd�ddl}|jtj��}|j}|jj	d�p:d}x8|j
�D]$}|j}|jj	d�}||krF|rFPqFW|}|}|d�}|d|d�}	|d|d�}
|d|d�}|d|d�}|d	�}
|d
�}tj���"}|jdd�|j
|j�||�d�|j
|	j�||�d�|j
|
j�||�d�|j
|j�|�|j
|j�|�|j
|
j�|
�|jt|j�d
|d<|j
|j�|d��|j
|	j�||�d�|j
|
j�||�d�|j
|j�|�|j
|j�|�|j
|
j�|
�|jt|j�WdQRXdS)Nr~rrz~/Documentsr.z
/Documentsz../~z/~rz~fakeuser/Documents�HOMEZ	Documentsz/tmpz/tmp/Documents)rAr�
import_moduler~rrd�getuidr��pw_dir�rstripr��EnvironmentVarGuardr�rr/rhr�)rrEr~ZpwdentZusername�userhomeZ	othernameZ	otherhome�p1�p2�p3�p4�p5�p6Zp7�envrrr
�test_expanduserUsJ
zPosixPathTest.test_expanduserN)rr r!r,rrAr�r�r�r�r�r�r�r�r�r�r~r�rrrr
r�
sr�c@s*eZdZejZdd�Zdd�Zdd�ZdS)�WindowsPathTestcCs0|j}|t�}|jt|jd��|td�h�dS)Nr�r)rAr�rrLrU)rrErBrrr
r��szWindowsPathTest.test_globcCs2|j}|td�}|jt|jd��|td�h�dS)Nrr�zdirC/dirD/fileD)rAr�rrLrZ)rrErBrrr
r��s
zWindowsPathTest.test_rglobcsb�j�tj���H��jdd��jdd��jdd��jdd�d�d<�d���d���d	���d
���d���d���jt�j��jt�j��jt�j��j�j����j�j����j�j������������f	d
d�}d�d<|��jdd�d�d<|�d�d<d�d<|��jdd��jdd�d�d<|�WdQRXdS)Nr�ZUSERPROFILEZHOMEPATHZ	HOMEDRIVE�alice�USERNAMEz~/My Documentsz~alice/My Documentsz~bob/My Documentsz/~/My Documentszd:~/My Documentsrcs��jdd��j�j��d���jt�j�d�d<�j�j��d���j�j��d���j�j����j�j����j�j���dS)Nr�zC:/Users/alice/My Documentsr�zC:/Users/bob/My Documents)r�rr/rhr�r)	rEr�r�r�r�r�r�r�rrr
r�s





z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alice)rArr�r�rhr�r/r)rrr)	rEr�r�r�r�r�r�r�rr
r��s@zWindowsPathTest.test_expanduserN)	rr r!r,rrAr�r�r�rrrr
r��sr��__main__)/rWr>rdr$r,r�r�r5rir�rZtestrZtest.supportrrr�r~�ImportError�objectrZTestCaser"r-r4r�r�r�r��realpathr�r�r�r�ZskipIfr�r�Z
only_posixr�r�rrr�r�r�r�mainrrrr
�<module>sr)$BRL8=zE


Youez - 2016 - github.com/yon3zu
LinuXploit