Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_pathlib.cpython-35.opt-2.pyc



���];U�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl	m
Z
ddlmZej
Z
yddlZddlZWnek
r�dZZYnXGdd�de�ZGdd�dee	j�ZGdd	�d	ee	j�ZGd
d�de�ZGdd
�d
ee	j�ZGdd�dee	j�ZGdd�dee	j�Zejje
�Zdd�Zdd�Zdd�Ze�Ze	j ej!dkd�Z"e	j ej!dkd�Z#e	j ee�Z$e#Gdd�de��Z%e"Gdd�de��Z&Gdd�de�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&kr�e	j,�dS)'�N)�mock)�supportc@s(eZdZdd�Zdd�ZdS)�_BaseFlavourTestcs�|jj}|jj�|jj�|�fdd�|D��}|j||��r�|�fdd�|D��}|j||�dS)Ncs"g|]}|jd���qS)�/)�replace)�.0�x)�sep��1/opt/alt/python35/lib64/python3.5/test_pathlib.py�
<listcomp>s	z7_BaseFlavourTest._check_parse_parts.<locals>.<listcomp>cs"g|]}|jd���qS)r)r)rr)�altsepr
rrs	)�flavourZparse_partsr	r
�assertEqual)�self�arg�expected�f�actualr
)r
r	r�_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�checkr	r
r
r�test_parse_parts_common"s(	"+++"%""%%(z(_BaseFlavourTest.test_parse_parts_commonN)�__name__�
__module__�__qualname__rrr
r
r
rrs
rc@s1eZdZejZdd�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_partsBs	%%%z!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_splitrootNszPosixFlavourTest.test_splitrootN)rrr �pathlibZ_posix_flavourrr"r*r
r
r
rr!?s	r!c@s1eZdZejZdd�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
rr"fs.	((%+%"((zNTFlavourTest.test_parse_partscCsp|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.)r/rr.)r/r-r.)rr-r)rr-r0)r/r-r)r/r-r0)r1r-r)r1r-r)r1r-r2)rr-r.)rr-r)rr)r)rrr
r
rr*�s"zNTFlavourTest.test_splitrootN)rrr r+Z_windows_flavourrr"r*r
r
r
rr,cs	"r,c
@s�eZdZddPdQdRdSdTdUdVdWdXdYg
d
dZd[d\d]d^d_giZdd�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!dOS)`�_BasePurePathTestza/brr�a/�b/�a/b/�a//b�a//b//r�/b/c/d�/b/cr�///b//c�d/�/ar�c/d�b/c/dcCs=|jd�}|j|_|jj|_|jj|_dS)Nr)�clsZ_flavourrr	r
)r�pr
r
r�setUp�sz_BasePurePathTest.setUpcCs�|j}|d�}|j||�|ddd�|ddd�|d�|d�|j||d��|d��|j||d�d�|d��|j||d�|d��|d��dS)Nrrrz/aza/b/cz/a/b/cza/b)r@�assertIsInstancer)r�PrAr
r
r�test_constructor_common�s	

"%z)_BasePurePathTest.test_constructor_commoncs�Gdd�dt��|j}|�fdd�|D��}|j|||��x'|jD]}|jt|�t�q^WdS)Nc@seZdZdS)z:_BasePurePathTest._check_str_subclass.<locals>.StrSubclassN)rrr r
r
r
r�StrSubclass�srFc3s|]}�|�VqdS)Nr
)rr)rFr
r�	<genexpr>�sz8_BasePurePathTest._check_str_subclass.<locals>.<genexpr>)�strr@r�parts�assertIs�type)r�argsrDrA�partr
)rFr�_check_str_subclass�s	z%_BasePurePathTest._check_str_subclasscCsE|jd�|jd�|jd�|jd�|jd�dS)Nrrrza/b.txtz/a/b.txt)rN)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)r@�joinpathrrJrK)rrDrA�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)r@rrJrK)rrDrArQr
r
r�test_div_common�s	


z!_BasePurePathTest.test_div_commoncCs8|j|�}|jt|�|jd|j��dS)Nr)r@rrHrr	)rrrLrAr
r
r�
_check_str�sz_BasePurePathTest._check_strcCs8x!d	D]}|j||f�qW|jdd
�dS)Nr�a/b�a/b/cr�/a/b�/a/b/crr)rrUrVrrWrX)r)rT)r�pathstrr
r
r�test_str_commons
z!_BasePurePathTest.test_str_commoncCs:|j}x*dD]"}|j||�j�|�qWdS)Nr�a/b�a/b/cr�/a/b�/a/b/c)rr[r\rr]r^)r@r�as_posix)rrDrYr
r
r�test_as_posix_commons	
z&_BasePurePathTest.test_as_posix_commoncCsCtj|j�}|j}|jt|d��d|d�dS)Nza/b�a�b)�os�fsencoder	r@r�bytes)rr	rDr
r
r�test_as_bytes_commons	z&_BasePurePathTest.test_as_bytes_commoncCsX|j}|jt��|d�j�WdQRX|jt��|�j�WdQRXdS)Nr)r@�assertRaises�
ValueError�as_uri)rrDr
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�(�)�)rrkrlrrmrn���)r@�	__class__r�repr�
assertTrue�
startswith�endswith�lenr�evalr_r+�__dict__rJ)rrYrAZclsname�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)r@r�assertNotEqual�int)rrDr
r
r�test_eq_common*s	z _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)r@rgrh�matchru�assertFalse)rrDr
r
r�test_match_common7s8	z#_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
rr�\sz:_BasePurePathTest.test_ordering_common.<locals>.assertLessrza/b�abcrz/az/a/bz/abcz/b)r@rg�	TypeError)rr�rDrrrrr
)rr�test_ordering_commonZs.	




	




z&_BasePurePathTest.test_ordering_commoncCs||j}|j}|d�}|j}|j|d�|j||j�|d�}|j}|j||ddf�dS)Nza/brrz/a/b)rr)r	r@rIrrJ)rr	rDrArIr
r
r�test_parts_commonvs				z#_BasePurePathTest.test_parts_commoncsx�jj�D]\}}|jd�j�}|j�jd�}||kr|�fdd�|D�}|j|f��j|�}x�|D]y}�j|�}�j||dj|���jt|�t|���jt	|�|��j|j
�|�q�WqWdS)Nrcs/g|]%}t�fdd�|D���qS)c3s$|]}|jd�j�VqdS)rN)rr	)rrM)rr
rrG�szA_BasePurePathTest.test_equivalences.<locals>.<listcomp>.<genexpr>)�tuple)r�t)rr
rr�s	z7_BasePurePathTest.test_equivalences.<locals>.<listcomp>zfailed with args {})�equivalences�itemsrr	�appendr@r�format�hashrHr_)r�kZtuplesZcanon�posixZpcanonr�rAr
)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)r@r�parent)rrDrAr
r
r�test_parent_common�s	z$_BasePurePathTest.test_parent_commoncCs�|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/brqr�rz/a/b/cz/a/bz/arrr)r@�parentsrrx�listrg�
IndexErrorr�)rrDrA�parr
r
r�test_parents_common�s.		1	1z%_BasePurePathTest.test_parents_commoncCsX|j}|j|d�jd�|j|d�jd�|j|d�jd�dS)Nza/brz/a/b)r@r�drive)rrDr
r
r�test_drive_common�s	z#_BasePurePathTest.test_drive_commoncCsz|j}|j}|j|d�jd�|j|d�jd�|j|d�j|�|j|d�j|�dS)Nrza/brz/a/b)r@r	r�root)rrDr	r
r
r�test_root_common�s		z"_BasePurePathTest.test_root_commoncCsz|j}|j}|j|d�jd�|j|d�jd�|j|d�j|�|j|d�j|�dS)Nrza/brz/a/b)r@r	r�anchor)rrDr	r
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)r@r�name)rrDr
r
r�test_name_common�s	z"_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.)r@r�suffix)rrDr
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.)r@r�suffixes)rrDr
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.)r@r�stem)rrDr
r
r�test_stem_commons	z"_BasePurePathTest.test_stem_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�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)r@r�	with_namergrh)rrDr
r
r�test_with_name_commons	%%%%%%z'_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/.)r@r�with_suffixrgrh)rrDr
r
r�test_with_suffix_common&s$	%%%%%%z)_BasePurePathTest.test_with_suffix_commoncCsC|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/brarrrza/rza/b/cza/cz/az/a/brz/a/z/cz/a/b/cz/a/c)r@rgr��relative_torrh)rrDrAr
r
r�test_relative_to_common=s<	"%"%%"z)_BasePurePathTest.test_relative_to_commoncCs�|j}|d�}x�tdtjd�D]�}tj||�}tj|�}|j|j|j�|j||�|jt	|�t	|��|jt
|�t
|��q,WdS)Nz/a/brrq)r@�range�pickle�HIGHEST_PROTOCOL�dumps�loadsrJrsrr�rH)rrDrA�proto�dumpedrQr
r
r�test_pickling_common`s	z&_BasePurePathTest.test_pickling_commonN)rr)r4r)rr5)r4r5)r6)r7)r8)rrr)rrr)rrr)rr:r)rr;r<)r=r:r)rrrr>)rrr?)rr9)"rrr r�rBrErNrOrRrSrTrZr`rfrjr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr3�sL	

##r3c@s�eZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�ZdS)�PurePosixPathTestcCsX|j}|j|d�jd�|j|d�jd�|j|d�jd�dS)Nz/a/brz///a/bz//a/bz//)r@rr�)rrDr
r
r�	test_rootos	zPurePosixPathTest.test_rootcCsa|j}|j|d�|d��|j|d�|d��|j|d�|d��dS)Nza/bzA/bz/az///az//a)r@rr)rrDr
r
r�test_eqvs	zPurePosixPathTest.test_eqcCsa|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)r@rri)rrDr
r
r�test_as_uri|s	zPurePosixPathTest.test_as_uricCsddlm}|j}ytjd�Wntk
rK|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�r@rcrd�UnicodeEncodeError�skipTestrri)rr�rDr
r
r�test_as_uri_non_ascii�s	
z'PurePosixPathTest.test_as_uri_non_asciicCs)|j}|j|d�jd��dS)NzA.pyza.PY)r@r�r�)rrDr
r
r�
test_match�s	zPurePosixPathTest.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)r@r��is_absoluteru)rrDr
r
r�test_is_absolute�s	z"PurePosixPathTest.test_is_absolutecCs}|j}|jd|d�j��|jd|d�j��|jd|d�j��|jd|d�j��dS)NFrrz/foo/barz/dev/con/PRN/NUL)r@rJ�is_reserved)rrDr
r
r�test_is_reserved�s
	z"PurePosixPathTest.test_is_reservedcCs�|j}|d�}|jd�}|j||d��|d�jd�}|j||d��|d�jd�}|j||d��dS)Nz//arz//a/bz/az//cz/c)r@rPr)rrDrArQr
r
r�	test_join�s	zPurePosixPathTest.test_joincCs�|j}|d�}|d}|j||d��|d�d}|j||d��|d�d}|j||d��dS)Nz//arz//a/bz/az//cz/c)r@r)rrDrArQr
r
r�test_div�s	
zPurePosixPathTest.test_divN)rrr r+�
PurePosixPathr@r�r�r�r�r�r�r�r�r�r
r
r
rr�ls	

r�c@s�eZdZejZejj�Zej	dd>d?d@gddAdBdCdDdEgddFgd
dGdHgi�dd�Z
dd�Zdd�Zdd�Z
dd�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:�Zd;d<�Z d=S)I�PureWindowsPathTestzc:a�c:r�a/rzc:/a�c:/�/a�/z�//x/y�//a/b/�//a/bz//a/b/crcCs�|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)r@rrH)rrAr
r
r�test_str�szPureWindowsPathTest.test_strcCsy|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)rN)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)r@rr)rrDr
r
rr��s	"zPureWindowsPathTest.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)r@rgrhrir)rrDr
r
rr��s	zPureWindowsPathTest.test_as_uricCs|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)r@rur�r�)rrDr
r
rr��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�assertOrderedEqualszDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualzc:A/bzC:a/Bz//some/Share/A/bz//Some/SHARE/a/B)r@r�)rr�rDrAr}r
)rrr�s	

z(PureWindowsPathTest.test_ordering_commoncCs||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)r@rIr)rrDrArIr
r
r�
test_parts$s				zPureWindowsPathTest.test_partscCsq|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)r@rr�)rrDrAr
r
r�test_parent0s	""zPureWindowsPathTest.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:arqzz:zz:/a/b/zz:/azz:/z	//a/b/c/dz//a/b/cz//a/b)r@r�rrxr�rgr�)rrDrAr�r
r
r�test_parentsBs2		(	(	(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)r@rr�)rrDr
r
r�
test_drive^s	zPureWindowsPathTest.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)r@rr�)rrDr
r
rr�hs	zPureWindowsPathTest.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)r@rr�)rrDr
r
r�test_anchorrs	zPureWindowsPathTest.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)r@rr�)rrDr
r
r�	test_name|s	zPureWindowsPathTest.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)r@rr�)rrDr
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.)r@rr�)rrDr
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.)r@rr�)rrDr
r
r�	test_stem�s	zPureWindowsPathTest.test_stemcCse|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)r@rr�rgrh)rrDr
r
r�test_with_name�s	%%%%z"PureWindowsPathTest.test_with_namecCsE|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)r@rr�rgrh)rrDr
r
r�test_with_suffix�s(	%%%%z$PureWindowsPathTest.test_with_suffixcCs�|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)r@rr�rgrhrH)rrDrAr
r
r�test_relative_to�sh	%%"%%%%"%%"z$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)r@r�r�ru)rrDr
r
rr�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)r@rPr)rrDrArQr
r
rr�0s 	zPureWindowsPathTest.test_joincCsG|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)r@r)rrDrAr
r
rr�Fs	zPureWindowsPathTest.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)r@rJr�)rrDr
r
rr�Zs	z$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)!rrr r+�PureWindowsPathr@r3r��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
rr��sB				


:r�c@s=eZdZejZdd�Zdd�Zdd�ZdS)�PurePathTestcCsD|jd�}|jt|�tjdkr6tjntj�dS)Nr�nt)r@rJrKrcr�r+r�r�)rrAr
r
r�test_concrete_classpsz PurePathTest.test_concrete_classcCs2tjd�}tjd�}|j||�dS)Nr)r+r�r�r)rrAr}r
r
r�test_different_flavours_unequalusz,PurePathTest.test_different_flavours_unequalcCs�tjd�}tjd�}|jt��||kWdQRX|jt��||kWdQRX|jt��||kWdQRX|jt��||kWdQRXdS)Nr)r+r�r�rgr�)rrAr}r
r
r�!test_different_flavours_unorderedzsz.PurePathTest.test_different_flavours_unorderedN)	rrr r+ZPurePathr@r�r�r�r
r
r
rr�ms	r�cGstjjt|�S)N)rc�path�join�BASE)rr
r
r�<lambda>�sr�cGstjjt|�S)N)rcr�r��TESTFN)rr
r
rr��scCsdtjs
dSytjtt�Wn/tk
rR}zt|�SWYdd}~XnXtj	t�dS)Nzno system support for symlinks)
r+Zsupports_symlinksrc�symlink�__file__r��OSErrorrHr�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)rrr r+�	PosixPathr@r
r
r
rr��sr�c@s1eZdZejZdd�Zdd�ZdS)�WindowsPathAsPureTestc	Cs4|j}|jt��|d�j�WdQRXdS)Nzc:/)r@rg�NotImplementedError�owner)rrDr
r
r�
test_owner�s	z WindowsPathAsPureTest.test_ownerc	Cs4|j}|jt��|d�j�WdQRXdS)Nzc:/)r@rgr��group)rrDr
r
r�
test_group�s	z WindowsPathAsPureTest.test_groupN)rrr r+�WindowsPathr@rrr
r
r
rr��s	r�c@s�eZdZdd�Zejdkr6dd�Zndd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zed#d$��Zd%d&�Zd'd(�Zd)d*�Zed+d,��Zd-d.�Zd/d0�Zd1d2�Zed3d4��Zed5d6��Zd7d8�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�Z.dOdP�Z/dQdR�Z0dSdT�Z1dUdV�Z2dWdX�Z3dYdZ�Z4d[d\�Z5e6d]d^��Z7d_d`�Z8dadb�Z9dcdd�Z:ededf��Z;dgdh�Z<didj�Z=dkdl�Z>dmdn�Z?e%j&e@edo�dp�dqdr��ZAdsdt�ZBe%j&e@eCdu�dv�dwdx��ZDdydz�ZEd{d|�ZFd}d~�ZGdd��ZHd�d��ZId�d��ZJed�d���ZKed�d���ZLed�d���ZMd�S)��
_BasePathTestc!Cs�dd�}|j|�tjt�tjtd��tjtd��tjtd��tjtdd��tjtd��ttd�d	��}|jd
�WdQRXttdd�d	��}|jd�WdQRXttdd
�d	��}|jd�WdQRXttddd�d	��}|jd�WdQRXtjtd�d�ts�tj	dtd��tj	dtd��|j
dtd��|j
tjjdd�tdd��|j
tjjdd�tdd��dS)NcSs'tjtd�d�tjt�dS)N�dirEi�)rc�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)�
addCleanuprc�mkdirr�r��open�writerr�r��dirlinkr�)rrrr
r
rrB�s.

(z_BasePathTest.setUpr�cCstj||dd�dS)N�target_is_directoryT)rcr�)r�src�destr
r
rr�sz_BasePathTest.dirlinkcCstj||�dS)N)rcr�)rrrr
r
rr�scCs9|jtjjt|�t|��d||f�dS)Nz&%r and %r don't point to the same file)rurcr��samefilerH)rZpath_aZpath_br
r
r�
assertSame�s$z_BasePathTest.assertSamec
OsC|jt��}|||�WdQRX|j|jjtj�dS)N)rg�FileNotFoundErrorr�	exception�errno�ENOENT)r�funcrL�kwargs�cmr
r
r�assertFileNotFound�sz _BasePathTest.assertFileNotFoundcCst|jtj��}|j||�|jt|�t|��|jt|�t|��|j|j��dS)N)	r@rc�getcwdrrHrJrKrur�)rrAr}r
r
r�	_test_cwd�s
z_BasePathTest._test_cwdcCs |jj�}|j|�dS)N)r@�cwdr')rrAr
r
r�test_cwdsz_BasePathTest.test_cwdcCsz|jtjjd��}|j||�|jt|�t|��|jt|�t|��|j|j	��dS)N�~)
r@rcr��
expanduserrrHrJrKrur�)rrAr}r
r
r�
_test_homes
z_BasePathTest._test_homecCs |jj�}|j|�dS)N)r@�homer,)rrAr
r
r�	test_home
sz_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)Nrr
r�foo)
rcr�r�r�r@rurr�rgr)rZ
fileA_pathZ
fileB_pathrArQr}Znon_existentr{r
r
r�
test_samefiles"z_BasePathTest.test_samefilecCs2|jd�}|j|j�tjd��dS)Nrr)r@r�statrc)rrAr
r
r�test_empty_path%sz_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*r/z/~z../~r)r@rr+rcr��absoluter�)rrDrAr
r
r�test_expanduser_common*s	(z$_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	rF�bahrrrr/z/xyzzy)r@r�rJ�existsr�)rrDrAr
r
r�test_exists7s	z_BasePathTest.test_existscCs�|jt�}|djd��0}|j|tj�|j|j�d�WdQRX|djd��6}|j|tj�|j|j�j	�d�WdQRX|djddd��6}|j|tj
�|j|j�j	�d�WdQRXdS)Nrr{zthis is file A
�rbsthis is file A�	bufferingr)r@r�rrC�io�
TextIOBaser�read�BufferedIOBase�strip�	RawIOBase)rrArr
r
r�test_open_commonFs#z_BasePathTest.test_open_commoncCsr|jt�}|djd�|j|dj�d�|jt|djd�|j|dj�d�dS)NrsabcdefgZsomestr)r@r�Zwrite_bytesrZ
read_bytesrgr�)rrAr
r
r�test_read_write_bytesRs
z#_BasePathTest.test_read_write_bytescCs�|jt�}|djddd�|j|djdddd�d�|jt|djd	�|j|djdd�d�dS)
Nruäbcdefg�encodingzlatin-1zutf-8�errors�ignoreZbcdefgs	somebytes)r@r�Z
write_textrZ	read_textrgr�)rrAr
r
r�test_read_write_textZsz"_BasePathTest.test_read_write_textcs�|j��t�}|j�}t|�}dddddg}ts[|dddg7}|j|�fd	d
�|D��dS)Nr	r
rrrrrrcsh|]}�t|��qSr
)r�)rr})rDr
r�	<setcomp>ks	z-_BasePathTest.test_iterdir.<locals>.<setcomp>)r@r��iterdir�setr�r)rrA�it�pathsrr
)rDr�test_iterdircs	z_BasePathTest.test_iterdircs]|j��td�}t|j��}�fdd�ddgD�}|j||�dS)Nrcs"h|]}�td|��qS)r)r�)rr})rDr
rrFss	z5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>rr)r@r�rHrGr)rrArJrr
)rDr�test_iterdir_symlinkms
	z"_BasePathTest.test_iterdir_symlinkcCsg|jtd�}|jt��}t|j��WdQRX|j|jjtj	tj
tjf�dS)Nr)r@r�rgr��nextrG�assertInrr �ENOTDIRr!�EINVAL)rrAr$r
r
r�test_iterdir_nodirvs
z _BasePathTest.test_iterdir_nodircsX��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�tr8||jd�dg�n||jd�dd
g�dS)Ncs-�jt|��fdd�|D��dS)Ncsh|]}�t|��qSr
)r�)rr})rDr
rrF�s	zA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>)rrH)�globr)rDrr
r�_check�sz._BasePathTest.test_glob_common.<locals>._checkrrz
dir*/file*z
dirB/fileBz
dirC/fileCz*Ar	rz*B/*z
dirB/linkDzlinkB/fileBzlinkB/linkDz*/fileB)r@r�rRrC�collections�Iteratorr�)rrSrArIr
)rDrr�test_glob_common�s$	
z_BasePathTest.test_glob_commoncs9��fdd�}�j��t�}|jd�}�j|tj�||dg�||jd�dg�||jd�g�tr�||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�)rr})rDr
rrF�s	zB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>)rrH)rRr)rDrr
rrS�sz/_BasePathTest.test_rglob_common.<locals>._checkrrz
dirB/fileBz*/fileAz*/fileBzdirB/linkD/fileBzlinkB/fileBzdirA/linkC/fileBzfile*z
dirC/fileCzdirC/dirD/fileDrz*/*)r@r��rglobrCrTrUr�)rrSrArIr
)rDrr�test_rglob_common�s"	

z_BasePathTest.test_rglob_commoncs�|j}|t��t�jd��}dddddddd	d
ddd
ddh}|j|�fdd�|D��dS)N�*rr	z
dirA/linkCr
z
dirB/fileBz
dirB/linkDrz	dirC/dirDzdirC/dirD/fileDz
dirC/fileCrrrrcsh|]}�|�qSr
r
)rr)rAr
rrF�s	z8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)r@r�rHrWr)rrD�given�expectr
)rAr�test_rglob_symlink_loop�s			z%_BasePathTest.test_rglob_symlink_loopcCs�|j}|t�}|jt|jd��|td�h�|jt|jd��|td�h�|jt|jd��t��dS)Nz..z
dirA/../file*z
dirA/../fileAz../xyzzy)r@r�rrHrR)rrDrAr
r
r�test_glob_dotdot�s
	++z_BasePathTest.test_glob_dotdotcCs |j�}|j||�dS)N)�resolver)rrArr}r
r
r�_check_resolve_relative�sz%_BasePathTest._check_resolve_relativecCs |j�}|j||�dS)N)r^r)rrArr}r
r
r�_check_resolve_absolute�sz%_BasePathTest._check_resolve_absolutec
Cs�|j}|td�}|jt��}|j�WdQRX|j|jjtj�|tdd�}|j	||�|td�}|j	||td��|tddd�}|j	||tdd��|tddd�}|j	||tdd��t
jd	d
�}|jt
j|�tjtjj|�tdd��tjtd�tjj|d��|tdddd�}|j||tdd��dS)
Nr/r
rrrr	rrr�z-dirD�linkX�linkY)r@r�rgr�r^rrr r!r_�tempfile�mkdtemprrrrcr�r�r�r`)rrDrAr$rr
r
r�test_resolve_common�s&	%%z!_BasePathTest.test_resolve_commoncCs�|jt�}|jdtd��|jtjjdd�td��|jtjjdd�td��|d}|j|j�|�dS)Nr�0�1�2)r@r�rr�rcr�rr^)rrAr}r
r
r�test_resolve_dot�s%%
z_BasePathTest.test_resolve_dotcCs�|jt�}|j�}|j�}t|�|�WdQRX|jtt|�|jtt|�|jt|j�|jt|j�|jt|j�|jt|j	�dS)N)
r@r�rGrMrgrhrr^r3�	__enter__)rrArIZit2r
r
r�	test_with�s
z_BasePathTest.test_withcCs�|jt�d}|j�j}|d@}|j|�|j|j�j|�|dB}|j|�|j|j�j|�dS)Nr�im���)r@r�r1�st_moderr)rrA�modeZnew_moder
r
r�
test_chmod�s



z_BasePathTest.test_chmodcCsy|jt�d}|j�}|j|j�|�|j|jdA�|j|j|j�|j|j�|�dS)Nrrl)r@r�r1rrrmrr)rrA�str
r
r�	test_stat
sz_BasePathTest.test_statcCs9|jt�d}|j�}|j||j��dS)Nr)r@r�r1r�lstat)rrArpr
r
r�
test_lstatsz_BasePathTest.test_lstatcCs9|jt�d}|j�}|j||j��dS)Nr)r@r�r1rrr)rrArpr
r
r�test_lstat_nosymlinksz"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testcCsx|jt�d}|j�j}ytj|�j}Wn#tk
r]|jd|�YnX|j	||j
��dS)Nrz4user %d doesn't have an entry in the system database)r@r�r1�st_uid�pwd�getpwuid�pw_name�KeyErrorr�rr�)rrA�uidr�r
r
rr!s
z_BasePathTest.test_ownerz&the grp module is needed for this testcCsx|jt�d}|j�j}ytj|�j}Wn#tk
r]|jd|�YnX|j	||j
��dS)Nrz5group %d doesn't have an entry in the system database)r@r�r1�st_gid�grp�getgrgid�gr_nameryr�rr)rrA�gidr�r
r
rr,s
z_BasePathTest.test_groupcCsA|jt�d}|j�|j|j�|j|j�dS)Nr)r@r�r�r%r1)rrAr
r
r�test_unlink7s
z_BasePathTest.test_unlinkcCsb|jt�d}x|j�D]}|j�q W|j�|j|j�|j|j�dS)Nr	)r@r�rGr��rmdirr%r1)rrAr}r
r
r�
test_rmdir=s
z_BasePathTest.test_rmdircCs�|jt�}|d}|j�j}|dd}|j|�|j|j�j|�|j|j�td�}|j|�|jtj|�j|�|j|j�dS)Nrr	�fileAAZfileAAA)	r@r�r1�st_size�renamerr%�rel_joinrc)rrDrA�sizer}r{r
r
r�test_renameEs


z_BasePathTest.test_renamecCs�|jt�}|d}|j�j}|dd}|j|�|j|j�j|�|j|j�tdd�}|j|�|jtj|�j|�|j|j�dS)Nrr	r�r
r)	r@r�r1r�rrr%r�rc)rrDrAr�r}r{r
r
r�test_replaceTs


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��|jdddd�|j|j��|j
t|jdd�dS)NZnewfileA�
ZnewfileBrni��exist_okF)r@r�r�r6�touchrur1�st_mtime�st_mtime_nsrc�utimerHr�rgr�)rrDrArpZ	old_mtimeZold_mtime_nsr
r
r�test_touch_commoncs$

		$

z_BasePathTest.test_touch_commonc
Cs\|jt�}|d}|j�|jd��#}|j|j�j�d�WdQRXdS)Nrr8sthis is file A)r@r�r�rrr<r>)rrDrArr
r
r�test_touch_nochange{s


z!_BasePathTest.test_touch_nochangec
Cs�|jt�}|d}|j|j��|j�|j|j��|j|j��|jt��}|j�WdQRX|j	|j
jtj�dS)NZnewdirA)
r@r�r�r6rru�is_dirrgr�rrr �EEXIST)rrDrAr$r
r
r�
test_mkdir�s

z_BasePathTest.test_mkdircCs�|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��tjdkrw|jtj|j�j�d	|@�|jtj|jj�j�|�dS)
NZnewdirB�newdirCr�TZnewdirDZnewdirEimr�im)r@r�r�r6rgr�rrrr r!rur�r�r1�S_IMODErmrcr�r�)rrAr$rnr
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)Nr
r�T)r@r�r1�st_ctimerur6r�rg�FileExistsErrorrrrr r�)rrA�st_ctime_firstr$r
r
r�test_mkdir_exist_ok�sz!_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
�|jdddd�|j|j��|j|j�j|�dS)Nrr�r�Tr�)
r@r�rur6rgr�rrrr r�r1r�)rrAr$r�r
r
r�test_mkdir_exist_ok_with_parent�s
z-_BasePathTest.test_mkdir_exist_ok_with_parentcCsH|jd�j�jdd�|jd�j�jdddd�dS)Nrr�Tr�)r@r^r)rr
r
r�test_mkdir_exist_ok_root�sz&_BasePathTest.test_mkdir_exist_ok_rootc
Csqx;dD]&}|j|d�}|j�sPqW|jd�|jt��|ddjdd�WdQRXdS)NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't existZchildr�r�T)r@r�r�rgr�r)rrrAr
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��}|jdddd�WdQRX|j|jj	t	j
�dS)Nr
rr�Tr�)r@r�rur6rgr�rrrr r�)rrAr$r
r
r�test_mkdir_with_child_file�sz(_BasePathTest.test_mkdir_with_child_filecCs�|jtd�}|j|j��|jt��}|j�WdQRX|j|jj	t	j
�|jt��}|jdd�WdQRX|j|jj	t	j
�dS)Nrr�T)r@r�rur6rgr�rrrr r�)rrAr$r
r
r�test_mkdir_no_parents_file�sz(_BasePathTest.test_mkdir_no_parents_filecsxtd�D]�|jtd��}|j|j��d��fdd�}�fdd�td�D��t��|d	d
}y4tjd|��|jdd
dd�WdQRXWn(t	k
r�|j
t|���YnX|jt|���|j
|j��q
WdS)N� zdirCPC%di�csIt|�}�j�r5tj||��j|�tj||�dS)N)rH�poprcr�add)r�rn)�concurrently_created�patternr
r�my_mkdir�s

zE_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.my_mkdircs$g|]}t�d|>@��qS)rq)�bool)r�n)�pattern_numr
rr�s	zG_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.<listcomp>�Zdir1Zdir2zpathlib._normal_accessor.mkdirr�Tr�F)r�r@r�r�r6rHrZpatchrr�rNrHZassertNotInru)rrAr�Zp12r
)r�r�r�r�%test_mkdir_concurrent_parent_creation�s	!
z3_BasePathTest.test_mkdir_concurrent_parent_creationcCsk|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)	Nrr	ZlinkAAZlinkAAAr
ZlinkAAAArT)
r@r�Z
symlink_torr1rrrrHr�r�rur�rG)rrD�target�linkr
r
r�test_symlink_tos$


z_BasePathTest.test_symlink_tocCs�|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��ts�|j|dj��|j|dj��|j|dj��dS)Nr	rznon-existingr5rrr)r@r�rur�r�r�)rrDr
r
r�test_is_dir sz_BasePathTest.test_is_dircCs�|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��ts�|j|dj��|j|dj��|j|dj��dS)Nrr	znon-existingr5rrr)r@r�ru�is_filer�r�)rrDr
r
r�test_is_file+sz_BasePathTest.test_is_filecCs�|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��ts�|j|dj��|j|dj��|j|dj��dS)Nrr	znon-existingr5rrr)r@r�r��
is_symlinkr�ru)rrDr
r
r�test_is_symlink6sz_BasePathTest.test_is_symlinkcCss|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr	znon-existingr5)r@r�r��is_fifo)rrDr
r
r�test_is_fifo_falseAs
z _BasePathTest.test_is_fifo_false�mkfifozos.mkfifo() requiredcCsb|jtd�}tjt|��|j|j��|j|j��|j|j	��dS)NZmyfifo)
r@r�rcr�rHrur�r��	is_socketr�)rrDr
r
r�test_is_fifo_trueHs
z_BasePathTest.test_is_fifo_truecCss|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr	znon-existingr5)r@r�r�r�)rrDr
r
r�test_is_socket_falsePs
z"_BasePathTest.test_is_socket_false�AF_UNIXzUnix sockets requiredcCs�|jtd�}tjtjtj�}|j|j�y|jt|��WnNt	k
r�}z.dt|�kr�|j
dt|��WYdd}~XnX|j|j��|j
|j��|j
|j��dS)NZmysockzAF_UNIX path too longzcannot bind Unix socket: )r@r��socketr��SOCK_STREAMr�close�bindrHr�r�rur�r�r�r�)rrD�sockr�r
r
r�test_is_socket_trueWs*z!_BasePathTest.test_is_socket_truecCss|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr	znon-existingr5)r@r�r��is_block_device)rrDr
r
r�test_is_block_device_falsees
z(_BasePathTest.test_is_block_device_falsecCss|jt�}|j|dj��|j|dj��|j|dj��|j|ddj��dS)Nrr	znon-existingr5)r@r�r��is_char_device)rrDr
r
r�test_is_char_device_falsels
z'_BasePathTest.test_is_char_device_falsecCse|jd�}|j�s(|jd�|j|j��|j|j��|j|j��dS)Nz	/dev/nullz/dev/null required)r@r6r�rur�r�r�r�)rrDr
r
r�test_is_char_device_truess
z&_BasePathTest.test_is_char_device_truecCst|jtd�}x[tdtjd�D]C}tj||�}tj|�}|j|j�|j��q)WdS)Nrrrq)	r@r�r�r�r�r�r�rr1)rrAr�r�rQr
r
rr�|s
z"_BasePathTest.test_pickling_commoncCsa|j}|d�}|d�}|j|jd|jd�|j|jd|jd�dS)Nz/usr/bin/fooz/usr/local/binrqr�r�)r@rJrI)rrDrAr}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)r@r�rrcr�r�r^rrHr&�chdir)rZlink0_targetrDrAZold_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�rcr�r�)rr
r
r�&test_complex_symlinks_relative_dot_dot�sz4_BasePathTest.test_complex_symlinks_relative_dot_dotN)Nrrr rBrcr�rrr%r'r)r,r.r0r2r4r7r@rArErK�
with_symlinksrLrQrVrXr\r]r_r`rerirkrorqrsrt�unittestZ
skipUnlessrvrr|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
rr�s�
	
	

	''		)rc@s=eZdZejZdd�Zdd�Zdd�ZdS)�PathTestcCsD|jd�}|jt|�tjdkr6tjntj�dS)Nrr�)r@rJrKrcr�r+rr�)rrAr
r
rr��szPathTest.test_concrete_classcCs<tjdkr%|jttj�n|jttj�dS)Nr�)rcr�rgr�r+r�r)rr
r
r�test_unsupported_flavour�sz!PathTest.test_unsupported_flavourc
Cs=|j�}|jtd��t|jd��WdQRXdS)NzUnacceptable patternr)r@ZassertRaisesRegexrhr�rR)rrAr
r
r�test_glob_empty_pattern�sz PathTest.test_glob_empty_patternN)	rrr r+ZPathr@r�r�r�r
r
r
rr��s	r�c@sseZdZejZdd�Zdd�Zdd�Ze	dd��Z
d	d
�Zdd�Zd
d�Z
dS)�
PosixPathTestc	Gs:|j|�}|jt��t|j��WdQRXdS)N)r@rg�RuntimeError�printr^)rrLr�r
r
r�_check_symlink_loop�sz!PosixPathTest._check_symlink_loopcCs�tjd�}|jtj|�|jt�}|djd��WdQRXtjtd��}|jtj	|j
�d�tjd�|djd��WdQRXtjtd��}|jtj	|j
�d�dS)Nr�new_filer
i���other_new_filei�)rc�umaskrr@r�rr1r�rr�rm)r�old_maskrArpr
r
r�test_open_mode�s
zPosixPathTest.test_open_modecCstjd�}|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_filerni�)rcr�rr@r�r�r1r�rr�rm)rr�rArpr
r
r�test_touch_mode�s
zPosixPathTest.test_touch_modecCs�tjdtd��|jtd�tjdtd��|jtd�tjdtd��|jtd�tjtd�td��|jtd�tjtd�td��|jtd�tjtd	�td
��|jtd
�dS)NzlinkX/insiderarbzlinkZ/../linkZZlinkZzlinkU/insideZlinkUZlinkVzlinkW/../linkWZlinkW)rcr�r�r�r�)rr
r
r�test_resolve_loop�szPosixPathTest.test_resolve_loopcCs~|j}|t�}t|jd��}tjt�sBt�n|}|j||�|jt|jd��t��dS)N�FILEazFILEa*)r@r�rHrRr�fs_is_case_insensitiver)rrDrArZr[r
r
r�	test_globs	zPosixPathTest.test_globcCs�|j}|td�}t|jd��}tjt�sEt�n|}|j||�|jt|jd��t��dS)Nr�FILEdzFILEd*)r@r�rHrWrr�r)rrDrArZr[r
r
r�
test_rglobs	zPosixPathTest.test_rglobcCs�|j}tjd�ddl}|jtj��}|j}|jj	d�pUd}xB|j
�D]4}|j}|jj	d�}||kre|rePqeW|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)Nrvrrz~/Documentsr*z
/Documentsz../~z/~rz~fakeuser/Documents�HOMEZ	Documentsz/tmpz/tmp/Documents)r@r�
import_modulervrwrc�getuidrx�pw_dir�rstrip�getpwall�EnvironmentVarGuardr�rr+rgr�)rrDrvZpwdentZusername�userhomeZ	othernameZ	otherhome�p1�p2�p3�p4�p5�p6Zp7�envr
r
r�test_expandusersF	
		   
  zPosixPathTest.test_expanduserN)rrr r+r�r@r�r�r�r�r�r�r�r�r
r
r
rr��s	r�c@s=eZdZejZdd�Zdd�Zdd�ZdS)�WindowsPathTestcCsD|j}|t�}|jt|jd��|td�h�dS)Nr�r)r@r�rrHrR)rrDrAr
r
rr�Ms	zWindowsPathTest.test_globcCsG|j}|td�}|jt|jd��|td�h�dS)Nrr�zdirC/dirD/fileD)r@r�rrHrW)rrDrAr
r
rr�Rs	zWindowsPathTest.test_rglobcs��j�tj�����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+rgryr
)	rDr�r�r�r�r�r�r�rr
rrns



z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alice)r@rr�r�rgr�r+r)rrr
)	rDr�r�r�r�r�r�r�rrr�Ws@	
*




zWindowsPathTest.test_expanduserN)	rrr r+rr@r�r�r�r
r
r
rr�Is	r��__main__)-rTr:rcr r+r�r�r1rcr�rZtestrr�r|rv�ImportError�objectrZTestCaser!r,r3r�r�r�r��realpathr�r�r�r�ZskipIfr�r�Z
only_posixr�r�r�rr�r�r�r�mainr
r
r
r�<module>sd	
)$B��L��			���rE