Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_pathlib.cpython-310.pyc
o

�9jn��@s(ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZddl
mZddl
mZddlmZmZz
ddlZddlZWn
ey]dZZYnwGdd�de�ZGdd	�d	eej�ZGd
d�deej�ZGdd
�d
e�ZGdd�deej�ZGdd�deej�ZGdd�deej�Zej� e�Z!dd�Z"dd�Z#e�$ej%dkd�Z&e�$ej%dkd�Z'e'Gdd�de��Z(e&Gdd�de��Z)Gdd�de�Z*Gd d!�d!e*ej�Z+e'Gd"d#�d#e*ej��Z,e&Gd$d%�d%e*ej��Z-Gd&d'�d'ej�Z.e/d(k�re�0�dSdS))�N)�mock)�
import_helper)�	os_helper)�TESTFN�FakePathc@seZdZdd�Zdd�ZdS)�_BaseFlavourTestcsh|jj}|jj�|jj�|�fdd�|D��}|�||��r2|�fdd�|D��}|�||�dSdS)Nc�g|]}|�d���qS��/��replace��.0�x)�sep��(/usr/lib/python3.10/test/test_pathlib.py�
<listcomp>�z7_BaseFlavourTest._check_parse_parts.<locals>.<listcomp>crr	rr
)�altseprrr!r)�flavour�parse_partsrr�assertEqual)�self�arg�expected�f�actualr)rrr�_check_parse_partss�z#_BaseFlavourTest._check_parse_partscCs�|j}|jj}|gddgf�|dgdddgf�|dgdddgf�|ddgddddgf�|dgddddgf�|dgddddgf�|gd�ddgd�f�|gd	�ddgd�f�|gd
�ddgd�f�|dgddgf�|gd�dddgf�|gd
�ddddgf�|gd�dddgf�|dgd||ddgf�|ddgd||ddgf�|ddgd||ddgf�|gd�d||ddgf�|gd�d||dgf�dS)N��a�a/�b�a/b�a/b/)r zb/c�d)r r"�cr%)r zb//cr%)r zb/c/r%�.)r'r'r")r r'r")r r'r'�/a/b�/a�/a/�r �/br&r&)r r,�/c)rrr)r�checkrrrr�test_parse_parts_common$s(z(_BaseFlavourTest.test_parse_parts_commonN)�__name__�
__module__�__qualname__rr/rrrrrs
rc@�"eZdZejZdd�Zdd�ZdS)�PosixFlavourTestcCs�|j}|ddgddgd�f�|ddgddgd�f�|d	dgddgd�f�|d
gddd
gf�|dgdddgf�|dgdddgf�dS)
N�//ar"r�//)r6r r"�///ar
)r
r r"z////a�c:a�c:\a�\a�r�rr.rrr�test_parse_partsDsz!PosixFlavourTest.test_parse_partscCs�|jj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�|�|d
�d�|�|d�d�|�|d�d
�|�|d�d�|�|d�d�|�|d�d�|�|d�d�dS)Nr�rrrr �rrr r#)rrr#r$)rrr$r))rr
r r()rr
r#�/a/b/)rr
r$r5)rr6r r7�///a/b�c:/a/b)rrrB�\/a/b)rrrC�\a\b)rrrD�r�	splitrootr�rrrrr�test_splitrootPszPosixFlavourTest.test_splitrootN)r0r1r2�pathlib�_posix_flavourrr=rHrrrrr4Asr4c@r3)�
NTFlavourTestcCs�|j}|dgdddgf�|dgdddgf�|dgdddgf�|dgddddgf�|d	gddddgf�|d
gddddgf�|dgddd
gf�|dgddd
gf�|dgddd
dgf�|gd�ddgd�f�|gd�ddgd�f�|gd�ddddgf�|gd�ddgd�f�|gd�ddddgf�|dgdddgf�|d gddddgf�|d d!gdddd"gf�|d#gd$dd%gf�|d&gd$dd%dgf�|gd'�ddgd(�f�|gd)�ddgd�f�|gd*�d+dgd,�f�dS)-N�c:r�c:/�\�c:\r
r8r �c:/ar)�//a/b�\\a\b�\\a\b\�//a/b/�//a/b/cr&)r zZ:br&�Z:)rVr"r&)r zZ:/br&)�Z:\r"r&)r z//b/cr%z\\b\cz\\b\c\r%)r z	Z://b//c/�d/)rWr"r&r%)r z//b/c//r%z//?/c:/z\\?\c:z\\?\c:\z//?/c:/ar,r"z//?/UNC/b/cz\\?\UNC\b\cz\\?\UNC\b\c\z
//?/UNC/b/c/dr+)rNr"r&)zZ:/ar,r&)z//?/Z:/ar,r&z\\?\Z:)z\\?\Z:\r"r&r;r<rrrr=hs.zNTFlavourTest.test_parse_partscCs|jj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�|�|d
�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d
�|�|d�d�dS)Nrr>r r?�a\b)rrrYr:)rrNr rD)rrNrYzc:a\b)rLrrYzc:\a\b)rLrNrYz\\az\\\a/b)rrNr#zc:\\a)rLrNr zc:\\\a/b)rLrNr#rR)rRrNrrS�	\\a\b\c\d)rRrN�c\dz\\\a\brErGrrrrH�s"zNTFlavourTest.test_splitrootN)r0r1r2rI�_windows_flavourrr=rHrrrrrKes"rKc@s&eZdZgd�gd�d�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFS)G�_BasePurePathTest)
�r r")r!r")r �b/)r!r_)r$)za//b)za//b//)rr r")r rr")r r"r))r �/b/cr%)r z///b//crX)r)r`r%)r
r"r�c/d)r
rzb/c/d)r�/b/c/d)r#rbcCs*|�d�}|j|_|jj|_|jj|_dS�Nr )�cls�_flavourrrr�r�prrr�setUp�s

z_BasePurePathTest.setUpcCs�|j}|d�}|�||�|ddd�|ddd�|d�|d�|td��|�||d��|d��|�||d�d�|d��|�||d�|d��|d��|�||d�|d�|d��|td���dS)Nr r"r&r)�a/b/c�/a/b/cr#)rd�assertIsInstancerr�r�Prgrrr�test_constructor_common�s,z)_BasePurePathTest.test_constructor_commoncs\Gdd�dt��|j}|�fdd�|D��}|�|||��|jD]
}|�t|�t�q!dS)Nc@seZdZdS)z:_BasePurePathTest._check_str_subclass.<locals>.StrSubclassN)r0r1r2rrrr�StrSubclass�sroc3s�|]}�|�VqdS�Nrr
�rorr�	<genexpr>�s�z8_BasePurePathTest._check_str_subclass.<locals>.<genexpr>)�strrdr�parts�assertIs�type)r�argsrmrg�partrrqr�_check_str_subclass�s
�z%_BasePurePathTest._check_str_subclasscCs6|�d�|�d�|�d�|�d�|�d�dS)Nrr'r za/b.txtz/a/b.txt�ry�rrrr�test_str_subclass_common�s




z*_BasePurePathTest.test_str_subclass_commoncCs�|j}|d�}|�d�}|�||d��|�t|�t|��|�dd�}|�||d��|�|d��}|�||d��|�d�}|�||d��dS)Nr#r&rir%�a/b/c/dr-)rd�joinpathrrurv�rrmrg�pprrr�test_join_common�s

z"_BasePurePathTest.test_join_commoncCs�|j}|d�}|d}|�||d��|�t|�t|��|d}|�||d��|dd}|�||d��d|d}|�||d��||d�}|�||d��|d}|�||d��dS)	Nr#r&rirar}r%zc/a/b/dr-)rdrrurvrrrr�test_div_common�sz!_BasePurePathTest.test_div_commoncCs(|j|�}|�t|�|�d|j��dS�Nr
)rdrrsrr)rrrwrgrrr�
_check_strs
z_BasePurePathTest._check_strcCs(dD]	}|�||f�q|�dd�dS)N�r r#rir
r(rjr')r)r�)r�pathstrrrr�test_str_commonsz!_BasePurePathTest.test_str_commoncCs(|j}dD]}|�||���|�qdS)Nr�)rdr�as_posix)rrmr�rrr�test_as_posix_commons�z&_BasePurePathTest.test_as_posix_commoncCs2t�|j�}|j}|�t|d��d|d�dS)Nr#�a�b)�os�fsencoderrdr�bytes)rrrmrrr�test_as_bytes_commons z&_BasePurePathTest.test_as_bytes_commoncCsv|j}|�t��|d���Wd�n1swY|�t��|���Wd�dS1s4wYdSrc)rd�assertRaises�
ValueError�as_uri�rrmrrr�test_as_uri_commons�"�z$_BasePurePathTest.test_as_uri_commoncCs�dD]S}|�|�}|jj}t|�}|�|�|d�|�|�|�d�|�|t|�dd�}|�t	|�|�
��t	|tj�}|�
|j|j�|�||�|�t|�|�qdS)Nr��(�)����)rd�	__class__r0�repr�
assertTrue�
startswith�endswith�lenr�evalr�rI�__dict__ru)rr�rg�clsname�r�inner�qrrr�test_repr_commons
�z"_BasePurePathTest.test_repr_commoncCs�|j}|�|d�|d��|�|d�|dd��|�|d�|d��|�|d�|d��|�|d�|��|�|d�|d��|�|�|d��|�|�d�|�|�i�|�|�t�dS)Nr#r r"r(r
r)rdr�assertNotEqual�intr�rrr�test_eq_common.sz _BasePurePathTest.test_eq_commoncCsN|j}|�t|d�jd�|�t|d�jd�|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d	��d��|�|d
��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d
��d��|�|d
��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��dS)Nr rr'�b.py�a/b.py�/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/d�/b.py�/*.pyz/a/*.pyz/ab.pyz	/a/b/c.pyz/**/*.pyz
/a/**/*.py)rdr�r��matchr��assertFalser�rrr�test_match_common;s<z#_BasePurePathTest.test_match_commoncs��fdd�}�j}|d�}|d�}|d�}|d�}|||�|||�|||�|||�|||��j}|d�}|d�}|d	�}|d
�}|||�|||�|||�|||�|||���t��|�ikWd�dS1stwYdS)Nc���||���||�dSrp)�
assertLess�
assertGreaterr^r{rrr�c�z:_BasePurePathTest.test_ordering_common.<locals>.assertLessr r#�abcr"r)r(z/abcr,)rdr��	TypeError)rr�rmr r"r&r%rr{r�test_ordering_commonas0









"�z&_BasePurePathTest.test_ordering_commoncCsX|j}|j}|d�}|j}|�|d�|�||j�|d�}|j}|�||ddf�dS)Nr#r^r(r r")rrdrtrru)rrrmrgrtrrr�test_parts_common}sz#_BasePurePathTest.test_parts_commoncCs4|j}|d�}|�|��d�|�t�|�d�dS)Nr#)r#)rdr��
__fspath__r��fspathrlrrr�test_fspath_common�sz$_BasePurePathTest.test_fspath_commonc	s��j��D]Z\}}|�d�j�}|��jd�}||kr,|�fdd�|D�}|�|f���|�}|D]+}�j|�}��||d�|����t|�t|����t	|�|���|�
�|�q3qdS)Nr
cs"g|]
}t�fdd�|D���qS)c3s�|]
}|�d�j�VqdS)r
N)rr)rrxr{rrrr�s�zA_BasePurePathTest.test_equivalences.<locals>.<listcomp>.<genexpr>)�tuple)r�tr{rrr�s��z7_BasePurePathTest.test_equivalences.<locals>.<listcomp>zfailed with args {})�equivalences�itemsrr�appendrdr�format�hashrsr�)r�k�tuples�canon�posix�pcanonr�rgrr{r�test_equivalences�s"�

��z#_BasePurePathTest.test_equivalencescCs�|j}|d�}|�|j|d��|�|jj|d��|�|jjj|��|�|jjjj|��|d�}|�|j|d��|�|jj|d��|�|jjj|d��|�|jjjj|d��dS)Nrir#r rjr(r)r
�rdr�parentrlrrr�test_parent_common�sz$_BasePurePathTest.test_parent_commoncCs|j}|d�}|j}|�t|�d�|�|d|d��|�|d|d��|�|d|d��|�|d	|d��|�|d
|d��|�|d|d��|�|dd�|d�f�|�|dd�|d�|d�f�|�|dd	�|d�|d�f�|�|dd�|d�|d�f�|�|ddd�|d�|d�f�|�|ddd	�|d�|d�|d�f�|�t|�|d�|d�|d�g�|�t��|dWd�n1s�wY|�t��|dWd�n1s�wY|�t��||d<Wd�n	1�swY|d
�}|j}|�t|�d�|�|d|d��|�|d|d��|�|d|d��|�|d	|d��|�|d
|d��|�|d|d��|�|dd�|d�f�|�|dd�|d�|d�f�|�|dd	�|d�|d�f�|�|dd�|d�|d�f�|�|ddd�|d�|d�f�|�|ddd	�|d�|d�|d�f�|�t|�|d�|d�|d�g�|�t��|dWd�n	1�s�wY|�t��
|dWd�dS1�s�wYdS)Nri�rr#r�r �r'r����������rjr(r)r
)rd�parentsrr��listr��
IndexErrorr��rrmrg�parrrr�test_parents_common�s`   "("
�
�
�   "("
�
$�z%_BasePurePathTest.test_parents_commoncCs@|j}|�|d�jd�|�|d�jd�|�|d�jd�dS)Nr#rr(�rdr�driver�rrr�test_drive_common�sz#_BasePurePathTest.test_drive_commoncC�X|j}|j}|�|d�jd�|�|d�jd�|�|d�j|�|�|d�j|�dS�Nrr#r
r()rdrr�root�rrmrrrr�test_root_common��z"_BasePurePathTest.test_root_commoncCr�r�)rdrr�anchorr�rrr�test_anchor_common�r�z$_BasePurePathTest.test_anchor_commoncCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd	�|�|d
�jd	�dS)Nrr'r
r#r"r(�/a/b/.r�r�r��rdr�namer�rrr�test_name_common��z"_BasePurePathTest.test_name_commoncCs<|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd	�|�|d
�jd	�|�|d�jd�|�|d�jd�|�|d
�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�dS)Nrr'�..r
r#r(r�r��.pyr��a/.hgrc�/a/.hgrc�a/.hg.rc�.rc�	/a/.hg.rc�
a/b.tar.gz�.gz�/a/b.tar.gz�a/Some name. Ending with a dot.� /a/Some name. Ending with a dot.�rdr�suffixr�rrr�test_suffix_commons$z$_BasePurePathTest.test_suffix_commoncCs:|j}|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jdg�|�|d	�jdg�|�|d
�jg�|�|d�jg�|�|d�jd
g�|�|d�jd
g�|�|d�jddg�|�|d�jddg�|�|d�jg�|�|d�jg�dS)Nrr'r
r#r(r�r�r�r�r�r�r�r�r�r��.tarr�r�r�r��rdr�suffixesr�rrr�test_suffixes_commons"z&_BasePurePathTest.test_suffixes_commoncCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd	�|�|d
�jd�|�|d�jd
�|�|d�jd�dS)Nrr'r�r
r#r"r�r��.hgrcr��.hgr��b.tarr��Some name. Ending with a dot.�rdr�stemr�rrr�test_stem_common)��z"_BasePurePathTest.test_stem_commoncCs2|j}|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d	��d�|d��|�t|d
�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd
�|�t|d�jd
�|�t|d�jd�|�t|d�jd�dS)Nr#�d.xmlza/d.xmlr(z/a/d.xmlr�r��
a/Dot ending.�/a/Dot ending.rr'r
r-�c/ra�rdr�	with_namer�r�r�rrr�test_with_name_common7sz'_BasePurePathTest.test_with_name_commoncCsL|j}|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d	��|�|d
��d�|d��|�|d��d�|d��|�|d
��d�|d��|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�dS)Nr#r%za/dr(z/a/dr�za/d.pyr�z/a/d.pyr�z/a/d.gzrrrr'r
r-rra�rdr�	with_stemr�r�r�rrr�test_with_stem_commonGsz'_BasePurePathTest.test_with_stem_commoncCs�|j}|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�t|d�jd�|�t|d	�jd�|�t|d
�jd�|�t|d�jd�|�t|d�jd
�|�t|d�jd	�|�t|d�jd�|�t|d�jd
�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�j|jjdf�dS)Nr#r�za/b.gzr(z/a/b.gzr�r�rr'r
�gz�/.gzraz.c/.dz./.dz.d/.r%)rdr�with_suffixr�r�rrr�rrr�test_with_suffix_commonXs*
�z)_BasePurePathTest.test_with_suffix_commoncCsR|j}|d�}|�t|j�|�t|jd�|�|�|��|d��|�|�d�|d��|�|�|d��|d��|�|�d�|d��|�|�d�|d��|�|�|d��|��|�|�d�|��|�|�dd�|��|�t|j|d��|�t|j|d��|�t|j|d	��|�t|j|d
��|d�}|�|�|d��|d��|�|�d�|d��|�|�|d
��|d��|�|�d
�|d��|�|�d
�|d��|�|�|d��|��|�|�d�|��|�t|j|d��|�t|j|d��|�t|j|d��|�t|j|��|�t|jd�|�t|j|d��dS)Nr#r�rr r"r!r&ri�a/cr)r(r
r*r-rj�/a/c)rdr�r��relative_torr�rlrrr�test_relative_to_commonqs<z)_BasePurePathTest.test_relative_to_commoncCs�|j}|d�}|�t|j�|�t|jd�|�|�|���|�|�d��|�|�|d���|�|�d��|�|�|d���|�|�d��|�|�dd��|�|�|d���|�|�|d���|�|�|d	���|�|�|d
���|d�}|�|�|d���|�|�d��|�|�|d
���|�|�d
��|�|�d
��|�|�|d���|�|�d��|�|�|d���|�|�|d���|�|�|d���|�|�|���|�|�d��|�|�|d���dS)Nr#r�rr r!r"r&rirr)r(r
r*r-rjr)rdr�r��is_relative_tor�r�rlrrr�test_is_relative_to_common�s:z,_BasePurePathTest.test_is_relative_to_commoncCs�|j}|d�}tdtjd�D]/}t�||�}t�|�}|�|j|j�|�||�|�t	|�t	|��|�t
|�t
|��qdS)Nr(rr�)rd�range�pickle�HIGHEST_PROTOCOL�dumps�loadsrur�rr�rs)rrmrg�proto�dumpedr�rrr�test_pickling_common�s
�z&_BasePurePathTest.test_pickling_commonN)%r0r1r2r�rhrnryr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrrrrrr]�sJ�

&/#"r]c@sZeZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�ZdS)�PurePosixPathTestcCs@|j}|�|d�jd�|�|d�jd�|�|d�jd�dS)Nr(r
rArQr6�rdrr�r�rrr�	test_root�szPurePosixPathTest.test_rootcCsF|j}|�|d�|d��|�|d�|d��|�|d�|d��dS)Nr#�A/br)r7r5)rdr�rr�rrr�test_eq��zPurePosixPathTest.test_eqcCsF|j}|�|d���d�|�|d���d�|�|d���d�dS)Nr
zfile:///z/a/b.cz
file:///a/b.cz/a/b%#czfile:///a/b%25%23c)rdrr�r�rrr�test_as_uri�r#zPurePosixPathTest.test_as_uricCsdddlm}|j}zt�d�Wnty|�d�Ynw|�|d���d|t�d���dS)Nr)�quote_from_bytes�éz1\xe9 cannot be encoded to the filesystem encodingu/a/bézfile:///a/b)	�urllib.parser%rdr�r��UnicodeEncodeError�skipTestrr�)rr%rmrrr�test_as_uri_non_ascii�s��z'PurePosixPathTest.test_as_uri_non_asciicCs|j}|�|d��d��dS)NzA.pyza.PY)rdr�r�r�rrr�
test_match�szPurePosixPathTest.test_matchcCs�|j}|�|����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����dS)Nr r$r
r)r@r5rQ�rdr��is_absoluter�r�rrr�test_is_absolute�sz"PurePosixPathTest.test_is_absolutecCsZ|j}|�d|d����|�d|d����|�d|d����|�d|d����dS)NFrr
�/foo/barz/dev/con/PRN/NUL�rdru�is_reservedr�rrr�test_is_reserved�s
z"PurePosixPathTest.test_is_reservedcCsh|j}|d�}|�d�}|�||d��|d��d�}|�||d��|d��d�}|�||d��dS�Nr5r"rQr)z//cr-�rdr~rrrrr�	test_join�s
zPurePosixPathTest.test_joincCsb|j}|d�}|d}|�||d��|d�d}|�||d��|d�d}|�||d��dSr3�rdrrrrr�test_divszPurePosixPathTest.test_divN)r0r1r2rI�
PurePosixPathrdr r"r$r*r+r.r2r5r7rrrrr�s

rc@seZdZejZej��Ze�	gd�gd�dgddgd��dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9S):�PureWindowsPathTest))rLr )rLr!)r
rLr ))rMr )rLr
r )rLr))z/zrMr )z//x/yrMr )rQ)rQr&)rTr&)r8rPrTrUcCs�|�d�}|�t|�d�|�d�}|�t|�d�|�d�}|�t|�d�|�d�}|�t|�d�|�d	�}|�t|�d
�dS)Nriza\b\czc:/a/b/czc:\a\b\crQrSrUz\\a\b\c�	//a/b/c/drZ)rdrrsrfrrr�test_strs




zPureWindowsPathTest.test_strcCs^|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�dS)
NrLr8z	c:a\b.txtrOr9z
c:\a\b.txtz\\some\sharez\\some\share\az\\some\share\a\b.txtrzr{rrr�test_str_subclass*s







z%PureWindowsPathTest.test_str_subclasscCs�|j}|�|d�|d��|�|d�|ddd��|�|d�|d��|�|d�|d��|�|d�|d��|�|d�|d	��|�|d
�|d��|�|d�|d
��dS)N�c:a/brLr r"zd:a/brBr(za/Br!�C:a/B�c:A/b�//Some/SHARE/a/Bz//somE/share/A/b)rdrr�r�rrrr"5szPureWindowsPathTest.test_eqcCs|j}|�t��|d���Wd�n1swY|�t��|d���Wd�n1s4wY|�|d���d�|�|d���d�|�|d���d�|�|d	���d
�|�|d���d�|�|d
���d�|�|d���d�dS)Nr(r=rMzfile:///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)rdr�r�r�rr�rrrr$As$����zPureWindowsPathTest.test_as_uricCsr|j}|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d��d��|�|d	��d��|�|d	��d
��|�|d��d
��|�|d��d
��|�|d
��d��|�|d��d��|�|d��d��dS)Nzc:/b.pyr�zc:*.pyzc:/*.pyzd:/b.pyr�zc:b.pyr�z//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)rdr�r�r�r�rrrr�Qs&z%PureWindowsPathTest.test_match_commoncs��fdd�}�j}|d�}|d�}|||���||k���||k�|d�}|d�}|||���||k���||k�dS)Ncr�rp)�assertLessEqual�assertGreaterEqualr^r{rr�assertOrderedEqualkr�zDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualr?r>z//some/Share/A/br@)rdr�)rrCrmrgr�rr{rr�is

z(PureWindowsPathTest.test_ordering_commoncCsX|j}|d�}|j}|�|d�|d�}|j}|�|d�|d�}|j}|�|d�dS)Nr=)rLr r"rB)rOr r"r:)rSr&r%)rdrtr)rrmrgrtrrr�
test_partszszPureWindowsPathTest.test_partscCs|j}|d�}|�|j|d��|�|jj|d��|�|jjj|d��|�|jjjj|d��|d�}|�|j|d��|�|jj|d��|�|jjj|d��|�|jjjj|d��|d	�}|�|j|d
��|�|jj|d��|�|jjj|d��dS)Nzz:a/b/czz:a/b�z:a�z:zz:/a/b/czz:/a/b�z:/a�z:/r:rUrQr�rlrrr�test_parent�szPureWindowsPathTest.test_parentcCs�|j}|d�}|j}|�t|�d�|�|d|d��|�|d|d��|�|dd�|d�f�|�|dd�|d�f�|�|dd�|d�|d�f�|�|dd�|d�f�|�|ddd�|d�f�|�|ddd�|d�|d�f�|�t|�|d�|d�g�|�t��|dWd�n1s�wY|d�}|j}|�t|�d�|�|d|d	��|�|d|d
��|�|dd�|d	�f�|�|dd�|d	�f�|�|dd�|d	�|d
�f�|�|dd�|d
�f�|�|ddd�|d	�f�|�|ddd�|d
�|d	�f�|�t|�|d	�|d
�g�|�t��|dWd�n	1�s?wY|d�}|j}|�t|�d�|�|d|d��|�|d|d
��|�|dd�|d�f�|�|dd�|d�f�|�|dd�|d�|d
�f�|�|dd�|d
�f�|�|ddd�|d�f�|�|ddd�|d
�|d�f�|�t|�|d�|d
�g�|�t��
|dWd�dS1�s�wYdS)Nzz:a/b/r�rrEr�rFr�zz:/a/b/rGrHr:rUrQ)rdr�rr�r�r�r�r�rrr�test_parents�s\ "
� "
� "
$�z PureWindowsPathTest.test_parentscCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�dS)	NrLr=rM�c:/a/b/rQrRrTr:r�r�rrr�
test_drive��zPureWindowsPathTest.test_drivecCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrLrr=rMrNrKrQrTr:rr�rrrr �rMzPureWindowsPathTest.test_rootcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrLr=rMrOrKrQrSrTr:)rdrr�r�rrr�test_anchor�rMzPureWindowsPathTest.test_anchorcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�|�|d
�jd�|�|d�jd�dS)NrLrrMr=r"rB�c:a/b.pyr��	c:/a/b.py�//My.py/Share.php�//My.py/Share.php/a/br�r�rrr�	test_name�r�zPureWindowsPathTest.test_namecCs*|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�|�|d
�jd�|�|d�jd�|�|d
�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�dS)NrLrrMr=rBrOr�rP�	c:a/.hgrc�
c:/a/.hgrc�
c:a/.hg.rcr��c:/a/.hg.rc�c:a/b.tar.gzr��
c:/a/b.tar.gz�!c:a/Some name. Ending with a dot.�"c:/a/Some name. Ending with a dot.rQrRr�r�rrr�test_suffix�s"zPureWindowsPathTest.test_suffixcCs:|j}|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jdg�|�|d�jdg�|�|d�jg�|�|d	�jg�|�|d
�jdg�|�|d�jdg�|�|d
�jddg�|�|d�jddg�|�|d�jg�|�|d�jg�|�|d�jg�|�|d�jg�dS)NrLrMr=rBrOr�rPrTrUrVr�rWrXr�r�rYrQrRrZr[r�r�rrr�
test_suffixess"z!PureWindowsPathTest.test_suffixescCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�|�|d
�jd�|�|d�jd
�|�|d�jd�|�|d�jd�dS)NrLrzc:.zc:..r�rMr=r"rOrTr�rVr�rXr�rZr�r�r�rrr�	test_stemrzPureWindowsPathTest.test_stemcC�|j}|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�t|d�jd�|�t|d	�jd�|�t|d
�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd
�|�t|d�jd
�dS)Nr=rz	c:a/d.xmlrBz
c:/a/d.xml�c:a/Dot ending.�c:/a/Dot ending.rLrM�
//My/Share�d:�d:e�d:/err�rrr�test_with_name#�z"PureWindowsPathTest.test_with_namecCr_)Nr=r%zc:a/drBzc:/a/dr`rarLrMrbrcrdrer	r�rrr�test_with_stem1rgz"PureWindowsPathTest.test_with_stemcCs�|j}|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�|d��d�|d��|�t|d�jd�|�t|d	�jd�|�t|d
�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd
�|�t|d�jd
�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�|�t|d�jd�dS)Nr=r�zc:a/b.gzrBz	c:/a/b.gzrOrPrr'r
rbrrNrLr
z\.gzzc:.gzrar[z.c/dz.c\d)rdrrr�r�r�rrr�test_with_suffix?s(z$PureWindowsPathTest.test_with_suffixcCs0|j}|d�}|�|�|d��|d��|�|�d�|d��|�|�|d��|d��|�|�d�|d��|�|�d�|d��|�|�|d��|��|�|�d�|��|�t|j|��|�t|jd�|�t|j|d	��|�t|j|d
��|�t|j|d��|�t|j|d��|�t|j|d
��|�t|j|d��|�t|j|d��|d�}|�|�|d��|d��|�|�d�|d��|�t|�|d���d�|�t|�d��d�|�|�|d��|d��|�|�d�|d��|�|�|d��|d��|�|�d�|d��|�|�d�|d��|�|�|d��|��|�|�d�|��|�t|j|d��|�t|j|d��|�t|j|d��|�t|j|d��|�t|j|d	��|�t|j|d��|�t|j|d
��|�t|j|d��|�t|j|d��|d�}|�|�|d��|d��|�|�d�|d��|�|�d�|d��|�|�|d ��|d��|�|�d �|d��|�|�d!�|d��|�|�|d"��|��|�|�d"�|��|�t|j|d#��|�t|j|d$��|�t|j|d%��|�t|j|d&��dS)'N�	C:Foo/BarrLzFoo/Bar�c:foO�Bar�c:foO/�	c:foO/baRrrcr
�Foo�/Foo�C:/Foo�
C:Foo/Bar/Baz�	C:Foo/Baz�
C:/Foo/Barz/Foo/Barz\Foo\BarrM�c:/foO�c:/foO/�
c:/foO/baR�C:/Baz�C:/Foo/Bar/Baz�
C:/Foo/Baz�C:Foo�d:/�//C/Foo�//Server/Share/Foo/Bar�//sErver/sHare�//sErver/sHare/�//sErver/sHare/Foo�//sErver/sHare/Foo/�//sErver/sHare/Foo/Bar�/Server/Share/Foo�c:/Server/Share/Foo�
//z/Share/Foo�//Server/z/Foo)rdrrr�r�rsrlrrr�test_relative_toWshz$PureWindowsPathTest.test_relative_tocCsH|j}|d�}|�|�|d���|�|�d��|�|�|d���|�|�d��|�|�d��|�|�|d���|�|�d��|�|�|���|�|�d��|�|�|d���|�|�|d���|�|�|d	���|�|�|d
���|�|�|d���|�|�|d���|�|�|d
���|d�}|�|�d��|�|�|d���|�|�|d���|�|�d��|�|�|d���|�|�d��|�|�|d���|�|�|d���|�|�|d���|�|�|d���|�|�|d���|�|�|d���|�|�|d���|�|�|d
���|�|�|d���|d�}|�|�|d���|�|�d��|�|�d��|�|�|d���|�|�d��|�|�d��|�|�|d���|�|�d��|�|�|d���|�|�|d ���|�|�|d!���|�|�|d"���dS)#NrjrLrkrmrnrrcr
rorprqrrrsrtrMrurvrwrxryrzr{r|r}r~rr�r�r�r�r�r�r�r�)rdr�rr�rlrrr�test_is_relative_to�s^z'PureWindowsPathTest.test_is_relative_tocCs(|j}|�|����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d	����|�|d
����|�|d����|�|d����|�|d
����|�|d����|�|d����dS)Nr r$r
r)r@rLr8zc:a/b/rMrPrKrQrTrUr:r,r�rrrr.�s"z$PureWindowsPathTest.test_is_absolutecCs�|j}|d�}|�d�}|�||d��|�d�}|�||d��|�d�}|�||d��|�d�}|�||d��|�d�}|�||d��|�d	�}|�||d��|�d
�}|�||d��dS)N�C:/a/b�x/y�
C:/a/b/x/y�/x/y�C:/x/y�D:x/y�D:/x/y�//host/share/x/y�c:x/y�c:/x/yr4rrrrr5�s 






zPureWindowsPathTest.test_joincCs�|j}|d�}|�|d|d��|�|dd|d��|�|d|d��|�|dd|d��|�|d	|d	��|�|d
d|d	��|�|d|d��|�|d
d|d��|�|d|d��|�|d
|d��|�|d|d��dS)Nr�r�r�r�yr�r�z/xr�zD:r�r�r�r�r6rlrrrr7�szPureWindowsPathTest.test_divcCs�|j}|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d	����|�d|d
����|�d|d����|�d|d����|�d|d
����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����|�d|d����dS)NFrr
r/z//my/share/nul/con/auxT�nul�aux�prn�conzconin$zconout$�COM1�LPT9ucom¹ucom²ulpt³zNUL.txtzPRN  z	AUX  .txtzCOM1:barzLPT9   :barzbar.com9zbar.lpt9zc:/baz/con/NULzc:/NUL/con/bazr0r�rrrr2s2z$PureWindowsPathTest.test_is_reservedN)#r0r1r2rI�PureWindowsPathrdr]r��copy�updater;r<r"r$r�r�rDrIrJrLr rNrSr\r]r^rfrhrir�r�r.r5r7r2rrrrr9sF
��.


:5r9c@�*eZdZejZdd�Zdd�Zdd�ZdS)�PurePathTestcC�6|�d�}|�t|�tjdkrtj�dStj�dS�Nr �nt)rdrurvr�r�rIr�r8rfrrr�test_concrete_class+�

��z PurePathTest.test_concrete_classcCs$t�d�}t�d�}|�||�dSrc)rIr8r�r��rrgr�rrr�test_different_flavours_unequal0s

z,PurePathTest.test_different_flavours_unequalcCs�t�d�}t�d�}|�t��||kWd�n1swY|�t��||kWd�n1s7wY|�t��||kWd�n1sPwY|�t��
||kWd�dS1sjwYdSrc)rIr8r�r�r�r�rrr�!test_different_flavours_unordered5s


�
�
�
"�z.PurePathTest.test_different_flavours_unorderedN)	r0r1r2rI�PurePathrdr�r�r�rrrrr�(s
r�cG�tjjtg|�R�Srp)r��path�join�BASE�rrrr�<lambda>H�r�cGr�rp)r�r�r�rr�rrrr�Ir�r�z)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc@seZdZejZdS)�PosixPathAsPureTestN)r0r1r2rI�	PosixPathrdrrrrr�Ps
r�c@r3)�WindowsPathAsPureTestcC�B|j}|�t��|d���Wd�dS1swYdS�NrM)rdr��NotImplementedError�ownerr�rrr�
test_ownerX�"�z WindowsPathAsPureTest.test_ownercCr�r�)rdr�r��groupr�rrr�
test_group]r�z WindowsPathAsPureTest.test_groupN)r0r1r2rI�WindowsPathrdr�r�rrrrr�Tsr�c@sveZdZdZdd�Zejdkrdd�Zndd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zejd(d)��Zd*d+�Zd,d-�Zd.d/�Zejd0d1��Zd2d3�Zd4d5�Z ejd6d7��Z!d�d9d:�Z"e"Z#Z$ejd;d<��Z%ejd=d>��Z&d?d@�Z'dAdB�Z(dCdD�Z)e*dEdF��Z+dGdH�Z,ejdIdJ��Z-dKdL�Z.ejdMdN��Z/dOdP�Z0e1�2e3dQ�dRdS��Z4e1�2e5dT�dUdV��Z6dWdX�Z7dYdZ�Z8d[d\�Z9e1�2e:ed]�d^�d_d`��Z;e1�2e:ed]�d^�dadb��Z<e1�=e:ed]�dc�ddde��Z>dfdg�Z?dhdi�Z@ejdjdk��ZAdldm�ZBdndo�ZCdpdq�ZDdrds�ZEdtdu�ZFdvdw�ZGdxdy�ZHeIdzd{��ZJd|d}�ZKd~d�ZLd�d��ZMejd�d���ZNd�d��ZOd�d��ZPe*d�d���ZQd�d��ZRd�d��ZSe1�2e:ed��d��e1�=eTjUd�kd��d�d����ZVd�d��ZWe1�2e:eXd��d��d�d���ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_ejd�d���Z`ejd�d���Zaejd�d���Zbd�S)��
_BasePathTestz?Tests for the FS-accessing functionalities of the Path classes.cCs�dd�}|�|�t�t�t�td��t�td��t�td��t�tdd��t�td��ttd�d	��
}|�d
�Wd�n1sIwYttdd�d	��
}|�d�Wd�n1sfwYttdd
�d	��
}|�d�Wd�n1s�wYttddd�d	��
}|�d�Wd�n1s�wYt�td�d�t�	�r�t�
dtd��t�
dtd��|�dtd��|�tj�dd�tdd��|�tj�dd�tdd��t�
dtd��dSdS)NcSst�td�d�t�t�dS)N�dirE�)r��chmodr�r�rmtreer�rrrr�cleanupzsz$_BasePathTest.setUp.<locals>.cleanup�dirA�dirB�dirC�dirDr��fileA�wbsthis is file A
�fileBsthis is file B
�fileCsthis is file C
�fileDsthis is file D
r�linkA�non-existing�
brokenLink�linkBr��linkC�linkD�brokenLinkLoop)
�
addCleanupr��mkdirr�r��open�writer�r�can_symlink�symlink�dirlinkr�)rr�rrrrrhys:

�����z_BasePathTest.setUpr�cCstj||dd�dS)NT��target_is_directory�r�r��r�src�destrrrr��sz_BasePathTest.dirlinkcCst�||�dSrpr�r�rrrr��scCs*|�tj�t|�t|��d||f�dS)Nz&%r and %r don't point to the same file)r�r�r��samefilers�r�path_a�path_brrr�
assertSame�s
��z_BasePathTest.assertSamecOsN|�t��}||i|��Wd�n1swY|�|jjtj�dSrp)r��FileNotFoundErrorr�	exception�errno�ENOENT)r�funcrw�kwargs�cmrrr�assertFileNotFound�s�z _BasePathTest.assertFileNotFoundcCs |�tj�|�tj�|��dSrp)rr�r��normcaser�rrr�assertEqualNormCase�s z!_BasePathTest.assertEqualNormCasecCsT|�t���}|�||�|�t|�t|��|�t|�t|��|�|�	��dSrp)
rdr��getcwdrr�rsrurvr�r-r�rrr�	_test_cwd�s
z_BasePathTest._test_cwdcCs|j��}|�|�dSrp)rd�cwdr�rfrrr�test_cwd�s
z_BasePathTest.test_cwdcCsX|�tj�d��}|�||�|�t|�t|��|�t|�t|��|�	|�
��dS)N�~)rdr�r��
expanduserrr�rsrurvr�r-r�rrr�
_test_home�s
z_BasePathTest._test_homecCs�t���7}|�|j���|��tj�t	d�|d<|�|j���tj�t	d�|d<|�|j���Wd�dS1s>wYdS)N�userprofile�USERPROFILE�home�HOME)
r�EnvironmentVarGuardr�rdr��clearr�r�r�r�)r�envrrr�	test_home�s
"�z_BasePathTest.test_homecCs�tj�td�}tj�tdd�}|�|�}|�|�}|�|�}|�|�|��|�|�|��|�|�|��|�|�|��tj�td�}|�|�}|�t	|j|�|�t	|j|�|�t	|j|�|�t	|j|�|�t	|j|�|�t	|j|�dS)Nr�r�r��foo)
r�r�r�r�rdr�r�r�r�r�)r�
fileA_path�
fileB_pathrgr�r��non_existentr�rrr�
test_samefile�s"



z_BasePathTest.test_samefilecCs$|�d�}|�|��t�d��dS)Nrr')rdr�statr�rfrrr�test_empty_path�s
z_BasePathTest.test_empty_pathcCs�|j}|d�}|�|��|tj�d���|d�}|�|��|�|d�}|�|��|�|d�}|�|��|�||d���j�d}|�|��|�dS)Nr�r��/~�../~r)rdrr�r�r��absoluter�rlrrr�test_expanduser_common�sz$_BasePathTest.test_expanduser_commoncCs|j}|t�}|�d|���|�d|d���|�d|d���|�d|dd���t��r_|�d|d���|�d|d���|�d|dd���|�d|dd���|�d|d	���|�d|d
����|�d|td����|�d|td����dS)
NTr�r�F�bahr�r�r�r�z/xyzzyu��)rdr�ru�existsrr�rlrrr�test_exists�sz_BasePathTest.test_existscCs|�t�}|d�d��}|�|tj�|�|��d�Wd�n1s&wY|d�d��}|�|tj�|�|���	�d�Wd�n1sNwY|djddd��}|�|tj
�|�|���	�d�Wd�dS1sywYdS)Nr�r�zthis is file A
�rb�this is file Ar)�	buffering)rdr�r�rk�io�
TextIOBaser�read�BufferedIOBase�strip�	RawIOBase)rrgrrrr�test_open_commons
��"�z_BasePathTest.test_open_commoncCsX|�t�}|d�d�|�|d��d�|�t|djd�|�|d��d�dS)Nr�sabcdefg�somestr)rdr��write_bytesr�
read_bytesr�r�rfrrr�test_read_write_bytess

z#_BasePathTest.test_read_write_bytescCsf|�t�}|djddd�|�|djddd�d�|�t|djd	�|�|djdd�d�dS)
Nr�uäbcdefgzlatin-1��encodingzutf-8�ignore)r�errors�bcdefgs	somebytes)rdr��
write_textr�	read_textr�r�rfrrr�test_read_write_texts
��z"_BasePathTest.test_read_write_textcCs�|�t�}|djddd�|�|d��d�|djddd�|�|d��d�|djddd�|�|d��d	�ttjd
d�}|d�d�|�|d��d
|d|d�dS)Nr�zabcde
fghlk

mnopq�
)�newlinesabcde
fghlk

mnopq�
sabcde

fghlk

mnopqz
sabcde

fghlk

mnopq�asciirzabcde
fghlk

mnopqsabcdesfghlks
mnopq)rdr�rrrr�r��linesep)rrg�os_linesep_byterrr�test_write_text_with_newliness$
����z+_BasePathTest.test_write_text_with_newlinescsX|j��t�}|��}t|�}gd�}t��r|gd�7}|�|�fdd�|D��dS)N)r�r�r�r�r�)r�r�r�r�c�h|]}�t|��qSr�r��rr��rmrr�	<setcomp>;�z-_BasePathTest.test_iterdir.<locals>.<setcomp>)rdr��iterdir�setrr�r)rrg�it�pathsrrr,r�test_iterdir3sz_BasePathTest.test_iterdircs>|j��td�}t|���}�fdd�dD�}|�||�dS)Nr�csh|]}�td|��qS)r�r*r+r,rrr-Crz5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>)r�r�)rdr�r0r/r)rrgr2rrr,r�test_iterdir_symlink=s

z"_BasePathTest.test_iterdir_symlinkcCsb|�td�}|�t��}t|���Wd�n1swY|�|jjtj	tj
tjf�dS�Nr�)rdr�r��OSError�nextr/�assertInr�r��ENOTDIRr��EINVAL�rrgr�rrr�test_iterdir_nodirFs�
�z _BasePathTest.test_iterdir_nodircs���fdd�}�j��t�}|�d�}��|tjj�||dg�||�d�g�||�d�ddg�t��sB||�d�d	dg�n
||�d�gd
��t��sZ||�d�dg�n
||�d�gd��t��ss||�d
�dg�dS||�d
�ddg�dS)Nc�"��t|��fdd�|D��dS)Ncr)rr*r+r,rrr-Rr.zA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>�rr0��globr�rmrrr�_checkQ�"z._BasePathTest.test_glob_common.<locals>._checkr�r�z
dir*/file*�
dirB/fileB�
dirC/fileCz*Ar�)r�r�r�z*B/*)rD�
dirB/linkD�linkB/fileBzlinkB/linkD�*/fileBrG)	rdr�r@rk�collectionsr��Iteratorrr��rrBrgr1rrAr�test_glob_commonPs"
z_BasePathTest.test_glob_commoncs���fdd�}�j��t�}|�d�}��|tjj�||dg�||�d�dg�||�d�g�t��s@||�d�dg�n
||�d�gd��||�d	�gd
���td�}||�d	�dd
g�||�d�d
g�dS)Ncr=)Ncr)rr*r+r,rrr-jr.zB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>r>r?rArrrBirCz/_BasePathTest.test_rglob_common.<locals>._checkr�r�rDz*/fileArH)rDzdirB/linkD/fileBrGzdirA/linkC/fileBzfile*)r�rDrE�dirC/dirD/fileDr�rErMz*/*)	rdr��rglobrkrIr�rJrr�rKrrAr�test_rglob_commonhs

z_BasePathTest.test_rglob_commoncsB|j}|t��t��d��}hd�}|�|�fdd�|D��dS)N�*>�	dirC/dirD�
dirA/linkCr�r�r�r�r�r�r�r�r�rDrFrErMcsh|]}�|�qSrrr
�rgrrr-�r�z8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)rdr�r0rNr)rrm�given�expectrrSr�test_rglob_symlink_loop}s

z%_BasePathTest.test_rglob_symlink_loopcs�d}|j}|t�d�|�gdg|�R�}|jdd�d�dg|����fdd	�td
�D�}|D]
}|�t|�|�q2�fdd	�td
�D�}�}t|�D]}|d}|D]
}|�t|�|�qVqNdS)N��deepr%T�r�r
rPcsg|]}�����qSr)r@�r�j��base�patternrrr�r.z;_BasePathTest.test_glob_many_open_files.<locals>.<listcomp>�dcsg|]}��d��qS)r%)rNrZ)r]rrr�r.)rdr�r�r�rrr7)r�depthrmrg�itersr1�irr\r�test_glob_many_open_files�s"��z'_BasePathTest.test_glob_many_open_filescCsf|j}|t�}|�t|�d��|td�h�|�t|�d��|td�h�|�t|�d��t��dS)Nr�z
dirA/../file*z
dirA/../fileAz../xyzzy)rdr�rr0r@rlrrr�test_glob_dotdot�s
z_BasePathTest.test_glob_dotdotcCsl|j}|t�d}|��|d}|��|d}|��|d}|d}|�|d�t�d��}tt�	|��|_
|�tt
|�d���d	�Wd�n1sQwY|��t�d��}tt�	|��|_
|�tt
|�d���d
�Wd�n1swY|�d�t�d��}tt�	|��|_
|�tt
|�d���d
�Wd�dS1s�wYdS)N�permissions�file1�file2�subdir�file3�otherz
os.scandirrPr��r)rdr�r��touch�
symlink_tor�patch�sortedr��scandir�return_valuerr�r0r@r�)rrmr]rfrgrhrirprrr�test_glob_permissions�s0��
"�z#_BasePathTest.test_glob_permissionsTcCs|�|�}|�||�dSrp)�resolver)rrgr�strictr�rrr�_check_resolve�s
z_BasePathTest._check_resolvec
Cs�|j}|td�}|�t��}|jdd�Wd�n1swY|�|jjtj�|�	t
|jdd��tj�
td��|tddd�}|�	t
|jdd��tj�
tddd��|tdddd�}|�	t
|jdd��tj�tj�
ddd���|tdd	�}|�||�|td
�}|�||td��|tdd
d	�}|�||tdd	��|tddd	�}|�||tdd	��|tdd
d	ddd�}|�||tdd	ddd�d�|tdd
dddd�}tjdkr�|�||tdddd�d�n|�||tddd�d�t�tjdt��d��}|�tj|�t�tj�
|�t
dd��t�t
d�tj�
|d��|tdddd	�}|�||tdd	��|tdddddd�}|�||tdddd�d�|tddddddd�}tjdk�rg|�|||ddd�d�dS|�||tddd�d�dS)Nr�T�rtF�in�spamr�r�r�r�r�r�r�r�r�z-dirD)r��dir�linkX�linkY)rdr�r�r6rsrr�r�r�r�rsr�r�r��abspath�_check_resolve_relativer�r�	_longpath�tempfile�mkdtempr�r�r�r��_check_resolve_absolute)rrmrgr�r%rrr�test_resolve_common�sn
����
��
��
��z!_BasePathTest.test_resolve_commoncCs�|�t�}|�dtd��|�tj�dd�td��|�tj�dd�td��|d}|�|jdd�|�|dd}|jt	|jdd�|�|jd	d�|dd�dS)
Nr'�0�1�2Trv�3�4F)
rdr�r�r�r�r�rrsr�r�)rrgr�r�rrr�test_resolve_dots
 z_BasePathTest.test_resolve_dotc	CsT|�dd�}t��}t�t�z|�|��|�t|��Wt�|�dSt�|�w)N�non�exist)rdr�r��chdirr�rrs)rrg�old_cwdrrr�)test_resolve_nonexist_relative_issue38671s
z7_BasePathTest.test_resolve_nonexist_relative_issue38671cCs�|�t�}|��}|��}t|�|�Wd�n1swYt|�t|�|��|��|��|�	Wd�dS1sEwYdSrp)rdr�r/r7r
rsr)rrgr1�it2rrr�	test_with)s
�"�z_BasePathTest.test_withcCsd|�t�d}|��j}|d@}|�|�|�|��j|�|dB}|�|�|�|��j|�dS)Nr��m����)rdr�r�st_moder�r)rrg�mode�new_moderrr�
test_chmod:s


z_BasePathTest.test_chmodcCst|�t�d}|��}|��j}|d@}|j|dd�|�|��j|�|dB}|j|dd�|�|��j|�dS)Nr�r�T��follow_symlinksr�)rdr�rsrr�r�r)rrgr�r�r�rrr�test_chmod_follow_symlinks_trueGs
z-_BasePathTest.test_chmod_follow_symlinks_truecCsZ|�t�d}|��}|�|��|�|�|jdA�|�|j|j�|�|��|�dS)Nr�r�)rdr�rrr�r�r�r��rrg�strrr�	test_statWsz_BasePathTest.test_statcC�.|�t�d}|��}|�||jdd��dS)Nr�Fr�)rdr�rr�r�rrr�test_stat_no_follow_symlinks`sz*_BasePathTest.test_stat_no_follow_symlinkscCr�)Nr�Fr�)rdr�rrr�rrr�&test_stat_no_follow_symlinks_nosymlinkfsz4_BasePathTest.test_stat_no_follow_symlinks_nosymlinkcC�*|�t�d}|��}|�||���dS)Nr�)rdr�rr��lstatr�rrr�
test_lstatksz_BasePathTest.test_lstatcCr�r5)rdr�rrr�r�rrr�test_lstat_nosymlinkqsz"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testcC�^|�t�d}|��j}zt�|�j}Wnty$|�d|�Ynw|�	||�
��dS)Nr�z4user %d doesn't have an entry in the system database)rdr�r�st_uid�pwd�getpwuid�pw_name�KeyErrorr)rr�)rrg�uidr�rrrr�v�
��z_BasePathTest.test_ownerz&the grp module is needed for this testcCr�)Nr�z5group %d doesn't have an entry in the system database)rdr�r�st_gid�grp�getgrgid�gr_namer�r)rr�)rrg�gidr�rrrr��r�z_BasePathTest.test_groupcCs2|�t�d}|��|�|j�|�|j�dSr5)rdr��unlinkr�rrfrrr�test_unlink�sz_BasePathTest.test_unlinkcCs*|�t�d}|�|j�|jdd�dS)N�fileAAAT)�
missing_ok)rdr�r�r�rfrrr�test_unlink_missing_ok�sz$_BasePathTest.test_unlink_missing_okcCsH|�t�d}|��D]}|��q|��|�|j�|�|j�dS)Nr�)rdr�r/r��rmdirr�rr�rrr�
test_rmdir�s
z_BasePathTest.test_rmdir�linkzos.link() is not presentc
Cs(|�t�}|d}|��j}|dd}z|�t��
|�|�Wd�n1s*wYWntyI}z
|�d|�WYd}~nd}~ww|�	|��j|�|�	t
j�||�d�|�
|j�td�}|�t��
|�|�Wd�n1s}wY|�	t
�|�j|�|�
|j�dS)Nr�r��fileAAz
os.link(): %sTr�)rdr�r�st_size�assertWarns�DeprecationWarning�link_to�PermissionErrorr)rr�r�r�r��rel_join)rrmrg�sizer��er�rrr�test_link_to�s,

�����z_BasePathTest.test_link_tocCs�|�t�}|d}|��j}|dd}|�|�|�|��j|�|�tj�	||��|�|�
��|dd}td�}|�|�|�t�|�j|�|�|�
��dS�Nr�r�r�r�)rdr�rr��hardlink_torr�r�r�r�r
r�)rrm�targetr�r��link2�target2rrr�test_hardlink_to�s



z_BasePathTest.test_hardlink_tozos.link() is presentcCsX|�t�}|d}|dd}|�t��|�|�Wd�dS1s%wYdS)Nr�r�r�)rdr�r�r�r��rrmrgr�rrr�test_link_to_not_implemented�s
"�z*_BasePathTest.test_link_to_not_implementedcCs�|�t�}|d}|��j}|dd}|�|�}|�||�|�|��j|�|�|j�td�}|�|�}|�||�|��|�t�|�j|�|�|j�dSr�)	rdr�rr��renamerr�r�r�)rrmrgr�r��	renamed_pr��	renamed_qrrr�test_rename�s



z_BasePathTest.test_renamecCs�|�t�}|d}|��j}|dd}|�|�}|�||�|�|��j|�|�|j�tdd�}|�|�}|�||�|��|�t�|�j|�|�|j�dS)Nr�r�r�r�r�)	rdr�rr�rrr�r�r�)rrmrgr�r��
replaced_pr��
replaced_qrrr�test_replace�s




z_BasePathTest.test_replacecCs�|�t�}|�|d��|�d��|�|d��|�d��|�|d��|�d��|�t��|d��Wd�dS1sCwYdS)Nr�r�r�r�r�r�)rdr�r�readlinkr�r6r�rrr�
test_readlink�s
�"�z_BasePathTest.test_readlinkcCs�|�t�}|d}|�|���|��|�|���|��}|j}|j}t	�
t|�|d|df�|��|��}|�|j|�|�|j|�|d}|�|���|jddd�|�|���|j
t|jdd�dS)N�newfileA�
�newfileBi�F)r��exist_ok�r�)rdr�r�r
rlr�r�st_mtime�st_mtime_nsr��utimersrBr�r6)rrmrgr��	old_mtime�old_mtime_nsrrr�test_touch_common�s$
z_BasePathTest.test_touch_commoncCs^|�t�}|d}|��|�d��}|�|����d�Wd�dS1s(wYdS)Nr�rr
)rdr�rlr�rrr)rrmrgrrrr�test_touch_nochanges
"�z!_BasePathTest.test_touch_nochangecCs�|�t�}|d}|�|���|��|�|���|�|���|�t��}|��Wd�n1s6wY|�	|j
jtj�dS)N�newdirA)
rdr�r�r
r�r��is_dirr�r6rr�r��EEXIST)rrmrgr�rrr�
test_mkdirs

�z_BasePathTest.test_mkdircCs\|�tdd�}|�|���|�t��}|��Wd�n1s"wY|�|jj	t	j
�|jdd�|�|���|�|���|�t��}|jdd�Wd�n1sZwY|�|jj	t	j
�t�|��j�}|�tdd�}|jddd�|�|���|�|���tjdkr�|�t�|��j�d	|@�|�t�|j��j�|�dS)
N�newdirB�newdirCTrY�newdirD�newdirEimr�im)rdr�r�r
r�r6r�rr�r�r�r�r�r�r�S_IMODEr�r�r�r�)rrgr�r�rrr�test_mkdir_parents&s*
��
z _BasePathTest.test_mkdir_parentscCs�|�td�}|��j}|�|���|�|���|�t��}|�	�Wd�n1s-wY|�
|jjtj
�|j	dd�|�|���|�
|��j|�dS)Nr�Tr�)rdr�r�st_ctimer�r
r�r��FileExistsErrorr�rr�r�r�)rrg�st_ctime_firstr�rrr�test_mkdir_exist_ok?s

�z!_BasePathTest.test_mkdir_exist_okcCs|�td�}|�|���|�t��}|��Wd�n1s!wY|�|jj	t	j
�|d}|jdd�|��j}|�|���|�t��}|jdd�Wd�n1s[wY|�|jj	t	j
�|jddd�|�|���|�|��j|�dS)Nr�r�TrY�r�r�)
rdr�r�r
r�r�r�rr�r�r�rr�)rrgr�r�rrr�test_mkdir_exist_ok_with_parentKs"
�
�z-_BasePathTest.test_mkdir_exist_ok_with_parentcCs2|�d���jdd�|�d���jddd�dS)Nr
Tr�r�)rdrsr�r{rrr�test_mkdir_exist_ok_root\sz&_BasePathTest.test_mkdir_exist_ok_rootcCsrdD]}|�|d�}|��snq|�d�|�t��|ddjdd�Wd�dS1s2wYdS)N�ZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't exist�childr�TrY)rdr�r)r�r6r�)rr%rgrrr�test_mkdir_with_unknown_driveas�
"�z+_BasePathTest.test_mkdir_with_unknown_drivecCs�|�tdd�}|�|���|�t��}|jdd�Wd�n1s$wY|�|jj	t	j
�|�t��}|jddd�Wd�n1sIwY|�|jj	t	j
�dS)Nr�r�TrYr��rdr�r�r
r�r�r�rr�r�r�r;rrr�test_mkdir_with_child_filels��z(_BasePathTest.test_mkdir_with_child_filecCs�|�td�}|�|���|�t��}|��Wd�n1s!wY|�|jj	t	j
�|�t��}|jdd�Wd�n1sEwY|�|jj	t	j
�dS)Nr�Tr�r�r;rrr�test_mkdir_no_parents_filexs
��z(_BasePathTest.test_mkdir_no_parents_filec	s�td�D]m�|�td��}|�|���d��fdd�	}�fdd�td�D��t��|d	d
}zt�d|��|jdd
d�Wd�n1sJwYWnt	ya|�
t|���Yn	w|�t|���|�
|���qdS)N� zdirCPC%dr�cs6t|�}���rt�||���|�t�||�dSrp)rs�popr�r��add)r�r�)�concurrently_createdr^rr�my_mkdir�s

zE_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.my_mkdircsg|]
}t�d|>@��qS)r�)�bool)r�n)�pattern_numrrr�szG_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.<listcomp>��dir1�dir2zpathlib._normal_accessor.mkdirTFr�)r�)rrdr�r�r
r0rrnr�r�r8rs�assertNotInr�)rrgr��p12r)r�r^r�r�%test_mkdir_concurrent_parent_creation�s$����z3_BasePathTest.test_mkdir_concurrent_parent_creationcCs|�t�}|d}|dd}|�|�|�|��|���|�|��|���|dd}|�t|��|�|��|���|�|��|���|�|�	��|d}|dd}|j|dd�|�|��|���|�|��|���|�
|�	��|�
t|����dS)	Nr�r��linkAA�linkAAAr��linkAAAATr�)
rdr�rmrrr�r�rsr�r�r�r�r/)rrmr�r�rrr�test_symlink_to�s$

z_BasePathTest.test_symlink_tocCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��rK|�|d���|�|d���|�|d��d�|�|d	��d�|�|d
��d�dS)Nr�r�r�rr�r�r�FudirA�zdirA)rdr�r�r�r�rr�rur�rrr�test_is_dir�s
z_BasePathTest.test_is_dircCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��rJ|�|d���|�|d���|�|d���|�|d��d	�|�|d
��d	�dS)Nr�r�r�rr�r�r��fileA�F�fileA)rdr�r��is_filer�rr�rur�rrr�test_is_file�s
z_BasePathTest.test_is_filecCs�|�t�}|�d�}|�|d���|�|d���|�|d���|�|dd���|�|���t��rD|�|d���|�|�d���d�|�|�d	���d�dS)
Nr
r�r�r�rr�u/�Fz/)rdr�r��is_mountr�rr�ru)rrm�Rrrr�
test_is_mount�s

z_BasePathTest.test_is_mountcCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��rJ|�|d���|�|d���|�|d���|�|d��d	�|�|d
��d	�t��rx|�|d��d	�|�|d��d	�dSdS)
Nr�r�r�rr�r�r�r	Fr
ulinkA�zlinkA)	rdr�r��
is_symlinkrr�r�rurr�rrr�test_is_symlink�s
�z_BasePathTest.test_is_symlinkcC�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dS�Nr�r�r�rr	Fr
)rdr�r��is_fiforur�rrr�test_is_fifo_false��
z _BasePathTest.test_is_fifo_false�mkfifozos.mkfifo() required�vxworksz%fifo requires special path on VxWorksc
Cs�|�td�}z	t�t|��Wnty(}z
|�d|�WYd}~nd}~ww|�|���|�	|�
��|�	|���|�|�td���d�|�|�td���d�dS)N�myfifozos.mkfifo(): %su	myfifo�Fzmyfifo)
rdr�r�rrsr�r)r�rr��	is_socketrru)rrmr�rrr�test_is_fifo_true�s��z_BasePathTest.test_is_fifo_truecCrr)rdr�r�rrur�rrr�test_is_socket_false		rz"_BasePathTest.test_is_socket_false�AF_UNIXzUnix sockets requiredc
Cs�|�td�}t�tjtj�}|�|j�z	|�t|��Wn&t	yC}zt
|t�s0dt|�vr9|�dt|��WYd}~nd}~ww|�
|���|�|���|�|���|�|�td���d�|�|�td���d�dS)N�mysockzAF_UNIX path too longzcannot bind Unix socket: u	mysock�Fzmysock)rdr��socketr�SOCK_STREAMr��close�bindrsr6�
isinstancer�r)r�rr�rrru)rrm�sockr�rrr�test_is_socket_true	s 
��z!_BasePathTest.test_is_socket_truecCrr)rdr�r��is_block_devicerur�rrr�test_is_block_device_false#	rz(_BasePathTest.test_is_block_device_falsecCrr)rdr�r��is_char_devicerur�rrr�test_is_char_device_false,	rz'_BasePathTest.test_is_char_device_falsecCsv|�d�}|��s|�d�|�|���|�|���|�|���|�|�d���d�|�|�d���d�dS)Nz	/dev/nullz/dev/null requiredu/dev/null�Fz
/dev/null)	rdr
r)r�r(r�r&rrur�rrr�test_is_char_device_true5	s

z&_BasePathTest.test_is_char_device_truecCsP|�td�}tdtjd�D]}t�||�}t�|�}|�|��|���qdS)Nr�rr�)	rdr�rrrrrrr)rrgrrr�rrrr@	s
�z"_BasePathTest.test_pickling_commoncCsJ|j}|d�}|d�}|�|jd|jd�|�|jd|jd�dS)Nz/usr/bin/fooz/usr/local/binr�r�r�)rdrurtr�rrr�test_parts_interningG	s
z"_BasePathTest.test_parts_interningc	Cs�|�t�}|�tj�dd�td��|�tj�dd�td��|�tj�dd�td��|�|td��|d��}|�||�|�t	|�t�|d��}|�||�|�t	|�t�|d��}|�||�|�t	|�t�|d��}|�||�|�t	|�t�t�
�}t�t�z\|�d���}|�||�|�t	|�t�|�d���}|�||�|�t	|�t�|�d���}|�||�|�t	|�t�|�d���}|�||�|�t	|�t�Wt�|�dSt�|�w)N�link0�link1r��link3)rdr�r�r�r�r�rsrr�rsr�r�)r�link0_targetrmrg�old_pathrrr�_check_complex_symlinksP	sB

z%_BasePathTest._check_complex_symlinkscCs|�t�dSrp)r1r�r{rrr�test_complex_symlinks_absolutey	�z,_BasePathTest.test_complex_symlinks_absolutecCs|�d�dS)Nr')r1r{rrr�test_complex_symlinks_relative}	r3z,_BasePathTest.test_complex_symlinks_relativecCs|�tj�dd��dS)Nr�r�)r1r�r�r�r{rrr�&test_complex_symlinks_relative_dot_dot�	sz4_BasePathTest.test_complex_symlinks_relative_dot_dotN)T)cr0r1r2�__doc__rhr�r�r�r�r�r�r�r�r�r�rrrrrrr!r(r3r�skip_unless_symlinkr4r<rLrOrVrcrdrrrur}r�r�r�r�r�r��
only_posixr�r�r�r�r�r��unittest�
skipUnlessr�r�r�r�r�r�r��hasattrr�r��skipIfr�r�r�r�r�r�r�r�r�r�r��only_ntr�r�r�rrrrrrr�sys�platformrrrr%r'r)r*rr+r1r2r4r5rrrrr�cs�


	





$
<



	











	





	�	
			)

r�c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�PathTestcCs|�|jt|j�dSrp)rurdrsr{rrr�test_class_getitem�	�zPathTest.test_class_getitemcCr�r�)rdrurvr�r�rIr�r�rfrrrr��	r�zPathTest.test_concrete_classcCs.tjdkr|�ttj�dS|�ttj�dS)Nr�)r�r�r�r�rIr�r�r{rrr�test_unsupported_flavour�	s
z!PathTest.test_unsupported_flavourcCsH|��}|�td��t|�d��Wd�dS1swYdS)NzUnacceptable patternr)rd�assertRaisesRegexr�r�r@rfrrr�test_glob_empty_pattern�	s"�z PathTest.test_glob_empty_patternN)
r0r1r2rI�PathrdrAr�rCrErrrrr@�	sr@c@s�eZdZejZdd�dd�Zdd�Zdd�Zd	d
�Z	e
jdd��Zd
d�Z
dd�Ze�eed�d�e�ejdkd�dd���Ze�ejdkd�dd��ZdS)�
PosixPathTestTrvcGsH|j|�}|�t��t|�|��Wd�dS1swYdSrp)rdr��RuntimeError�printrs)rrtrwr�rrr�_check_symlink_loop�	s
"�z!PosixPathTest._check_symlink_loopcCs�t�d�}|�tj|�|�t�}|d�d��Wd�n1s#wYt�td��}|�t�	|j
�d�t�d�|d�d��Wd�n1sPwYt�td��}|�t�	|j
�d�dS)Nr�new_filer����other_new_file�)r��umaskr�rdr�r�rr�rr�r��r�old_maskrgr�rrr�test_open_mode�	s

�
�zPosixPathTest.test_open_modec	CsNt��}zt�d�|�d�}|�t|���d�Wt�|�dSt�|�w)Nr
rxz/spam)r�r�r�rdrrsrs)r�current_directoryrgrrr�test_resolve_root�	s

zPosixPathTest.test_resolve_rootcCs�t�d�}|�tj|�|�t�}|d��t�td��}|�t�	|j
�d�t�d�|d��t�td��}|�t�	|j
�d�|djdd	�t�td��}|�t�	|j
�d�dS)
NrrKrLrMrNrO�masked_new_filei�)r�)r�rPr�rdr�rlrr�rr�r�rQrrr�test_touch_mode�	s


zPosixPathTest.test_touch_modecCs�t�dtd��|�td�t�dtd��|�td�t�dtd��|�td�|jtdddd�t�td	�td
��|�td
�t�td�td��|�td�t�td�td
��|�td
�|jtd
ddd�dS)NzlinkX/insiderzr{zlinkZ/../linkZ�linkZr�FrvzlinkU/inside�linkU�linkVzlinkW/../linkW�linkW)r�r�r�rJr�r{rrr�test_resolve_loop�	szPosixPathTest.test_resolve_loopcCsX|j}|t�}t|�d��}t�t�st�n|}|�||�|�t|�d��t��dS)N�FILEazFILEa*)rdr�r0r@r�fs_is_case_insensitiver�rrmrgrTrUrrr�	test_glob�	szPosixPathTest.test_globcCsZ|j}|td�}t|�d��}t�t�st�n|}|�||�|�t|�d��t��dS)Nr��FILEdzFILEd*)rdr�r0rNrr^rr_rrr�
test_rglob�	s
zPosixPathTest.test_rglob�getpwallz%pwd module does not expose getpwall()rzno home directory on VxWorkscCsX|j}t�d�ddl}|�t���}|j}|j�	d�pd}|�
�D]}|j}|j�	d�}||kr5|r5nq"|}|}d}z|�|�rK|d7}|�|�sBWn	tyUYnw|d�}	|d|�d��}
|d|�d��}|d	|�d��}|d
|�d��}
|d�}|d|�d��}t
����}|�dd�|�|	��||�d
�|�|
��||�d
�|�|��||�d
�|�|��|�|�|
��|
�|�|��|�|�t|j�d|d<|�|	��|d��|�|
��||�d
�|�|��||�d
�|�|��|�|�|
��|
�|�|��|�|�t|j�Wd�dS1�s%wYdS)Nr�rr
�fakeuserr�z~/Documentsr�z
/Documentsrrrr��	Documentsz/tmpz/tmp/Documents)rdr�
import_moduler�r�r��getuidr��pw_dir�rstriprc�getpwnamr�rr�r�rr�r�rH)rrmr��pwdent�username�userhome�	othername�	otherhome�fakename�p1�p2�p3�p4�p5�p6�p7r�rrr�test_expanduser�	s`
�

���
$�zPosixPathTest.test_expanduser�darwinz1Bad file descriptor in /dev/fd affects only macOSc
Cs�z=tt�d��d��dd�}|s|�d�|D]"}|��|��|��|��|�	�|�
�|��|��qWdSt
yU}z|jtjkrP|�d��d}~ww)Nz/dev/fdrPr�z.no file descriptors - issue was not reproducedz Bad file descriptor not handled.)r�rIrFrNr)r
r�rrr&r(rrr6r��EBADF�fail)r�file_descriptorsrr�rrr�test_handling_bad_descriptor*
s(

�	
��z*PosixPathTest.test_handling_bad_descriptorN)r0r1r2rIr�rdrJrSrUrWrr7r\r`rbr9r:r;r�r<r>r?rxr}rrrrrG�	s*	
��5�rGc@r�)�WindowsPathTestcCs�|j}|t�}|�t|�d��|td�h�|�t|�d��|td�h�|�ttt|�d���|�d�h�|�ttt|�d���|�d�h�dS)Nr]r�zF*az\FILEaz\fileA)rdr�rr0r@�maprsrlrrrr`F
s$(zWindowsPathTest.test_globcCsV|j}|td�}|�t|�d��|td�h�|�ttt|�d���|�d�h�dS)Nr�rarMz\dirD\FILEd)rdr�rr0rNrrsrlrrrrbN
s
(zWindowsPathTest.test_rglobc
sj�j�t�������dd���dd���dd���dd�d�d<�d���d���d	���d
���d���d����t�j���t�j���t�j�������������������������������f	d
d�}d�d<|�d�d<d�d<|���dd���dd�d�d<|�d�d<|�Wd�dS1s�wYdS)Nr�r��HOMEPATH�	HOMEDRIVE�alice�USERNAMEz~/My Documentsz~alice/My Documentsz~bob/My Documentsz/~/My Documentszd:~/My Documentsrcs���dd�������d����t�j�d�d<������d��������d�����������������������dS)Nr�zC:/Users/alice/My Documentsr�zC:/Users/bob/My Documents)r�rr�r�rHr�	rmr�rqrrrsrtrurvrrrr.k
s
�
�
�z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alicezC:\Users\eve)rdrr�r�r�rHr�rr<rr�rrxT
s@
"�zWindowsPathTest.test_expanduserN)	r0r1r2rIr�rdr`rbrxrrrrr~B
s
r~c@s.eZdZdZGdd�d�Zdd�Zdd�ZdS)	�CompatiblePathTestz|
    Test that a type can be made compatible with PurePath
    derivatives by implementing division operator overloads.
    c@s(eZdZdZdd�Zdd�Zdd�ZdS)	zCompatiblePathTest.CompatPathz�
        Minimum viable class to test PurePath compatibility.
        Simply uses the division operator to join a given
        string and the string value of another object with
        a forward slash.
        cCs
||_dSrp)�string)rr�rrr�__init__�
s
z&CompatiblePathTest.CompatPath.__init__cCst|�|j�d|���Sr��rvr��rrjrrr�__truediv__�
rBz)CompatiblePathTest.CompatPath.__truediv__cCst|�|�d|j���Sr�r�r�rrr�__rtruediv__�
rBz*CompatiblePathTest.CompatPath.__rtruediv__N)r0r1r2r6r�r�r�rrrr�
CompatPath�
s
r�cCsnt�d�|�d�}|�||j�|�|jd�|�t��t�d�dWd�dS1s0wYdS)N�test�rightz
test/rightr�)rIr�r�rkrr�r�r��r�resultrrr�test_truediv�
�"�zCompatiblePathTest.test_truedivcCsn|�d�t�d�}|�||j�|�|jd�|�t��dt�d�Wd�dS1s0wYdS)N�leftr�z	left/testr�)r�rIr�rkrr�r�r�r�rrr�
test_rtruediv�
r�z CompatiblePathTest.test_rtruedivN)r0r1r2r6r�r�r�rrrrr��
s
	r��__main__)1�collections.abcrIrr�r>r�rIrrrrr9r�test.supportrr�test.support.os_helperrrr�r��ImportError�objectr�TestCaser4rKr]rr9r�r��realpathr�r�r�r<r�r=r8r�r�r�r@rGr~r�r0�mainrrrr�<module>s��)$BL��+%G
)�

Youez - 2016 - github.com/yon3zu
LinuXploit