Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.118.252.210
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_pathlib.cpython-310.pyc
o

ab���@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/local/python-3.10/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�rgZclsname�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)�
assertLessZ
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�kZtuplesZcanon�posixZpcanonr�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��|�|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��
|dWd�dS1�s�wYdS)Nri�rr#r�r �r'r����������rjr(r)r
)rd�parentsrr��listr��
IndexErrorr��rrmrgZparrrr�test_parents_common�sT   "("
�
�
�   "("
$�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_common�s$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_common2sz'_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.gzr�r�rr'r
r-r�ra�rdr�	with_stemr�r�r�rrr�test_with_stem_commonBsz'_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_commonSs*
�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_commonls<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&rir
r)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�r�rrr	r
rrrrrrr]�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�rzPurePosixPathTest.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.parserrdr�r��UnicodeEncodeError�skipTestrr�)rrrmrrr�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��dSr-�rdrrrrr�test_div�szPurePosixPathTest.test_divN)r0r1r2rI�
PurePosixPathrdrrrr$r%r(r,r/r1rrrrr�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�rrrr0szPureWindowsPathTest.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(r7rMzfile:///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<s$����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�Ls&z%PureWindowsPathTest.test_match_commoncs��fdd�}�j}|d�}|d�}|||���||k���||k�|d�}|d�}|||���||k���||k�dS)Ncr�rp)ZassertLessEqual�assertGreaterEqualr^r{rr�assertOrderedEqualfr�zDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualr9r8z//some/Share/A/br:)rdr�)rr<rmrgr�rr{rr�ds

z(PureWindowsPathTest.test_ordering_commoncCsX|j}|d�}|j}|�|d�|d�}|j}|�|d�|d�}|j}|�|d�dS)Nr7)rLr r"rB)rOr r"r4)rSr&r%)rdrtr)rrmrgrtrrr�
test_partsus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:/r4rUrQr�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�rr>r�r?r�zz:/a/b/r@rAr4rUrQ)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)	NrLr7rM�c:/a/b/rQrRrTr4r�r�rrr�
test_drive��zPureWindowsPathTest.test_drivecCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrLrr7rMrNrDrQrTr4rr�rrrr�rFzPureWindowsPathTest.test_rootcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrLr7rMrOrDrQrSrTr4)rdrr�r�rrr�test_anchor�rFzPureWindowsPathTest.test_anchorcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�|�|d
�jd�|�|d�jd�dS)NrLrrMr7r"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)NrLrrMr7rBrHr�rI�	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.rJrKr�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)NrLrMr7rBrHr�rIrMrNrOr�rPrQr�r�rRrJrKrSrTr�r�rrr�
test_suffixes�s"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�rMr7r"rHrMr�rOr�rQr�rSr�r�r�rrr�	test_stemr�zPureWindowsPathTest.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)Nr7r�z	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_namecCrX)Nr7r%zc:a/drBzc:/a/drYrZrLrMr[r\r]r^rr�rrr�test_with_stem,r`z"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)Nr7r�zc:a/b.gzrBz	c:/a/b.gzrHrIrr'r
r[rrNrLrz\.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:foOZBar�c:foO/�	c:foO/baRrr\r
�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)rdrrr�r�rsrlrrr�test_relative_toRshz$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)#NrcrLrdrerfrr\r
rgrhrirjrkrlrMrmrnrorprqrrrsrtrurvrwrxryrzr{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/rMrPrDrQrTrUr4r&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/yr.rrrrr/�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�r0rlrrrr1�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�nulZauxZprnZconzconin$zconout$ZCOM1ZLPT9ucom¹ucom²ulpt³zNUL.txtzPRN  z	AUX  .txtzCOM1:barzLPT9   :barzbar.com9zbar.lpt9zc:/baz/con/NULzc:/NUL/con/bazr*r�rrrr,s2z$PureWindowsPathTest.test_is_reservedN)#r0r1r2rI�PureWindowsPathrdr]r��copy�updater5r6rrr�r�r=rBrCrErrGrLrUrVrWr_rarbr�r�r(r/r1r,rrrrr3	sF
��.


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

��z PurePathTest.test_concrete_classcCs$t�d�}t�d�}|�||�dSrc)rIr2r�r��rrgr�rrr�test_different_flavours_unequal+s

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


�
�
�
"�z.PurePathTest.test_different_flavours_unorderedN)	r0r1r2rI�PurePathrdr�r�r�rrrrr�#s
r�cG�tjjtg|�R�Srp)r��path�join�BASE�rrrr�<lambda>C�r�cGr�rp)r�r�r�rr�rrrr�Dr�r�z)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc@seZdZejZdS)�PosixPathAsPureTestN)r0r1r2rI�	PosixPathrdrrrrr�Ks
r�c@r3)�WindowsPathAsPureTestcC�B|j}|�t��|d���Wd�dS1swYdS�NrM)rdr��NotImplementedError�ownerr�rrr�
test_ownerS�"�z WindowsPathAsPureTest.test_ownercCr�r�)rdr�r��groupr�rrr�
test_groupXr�z WindowsPathAsPureTest.test_groupN)r0r1r2rI�WindowsPathrdr�r�rrrrr�Os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�cleanupusz$_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�linkA�non-existing�
brokenLink�linkBr��linkC�linkD�brokenLinkLoop)
�
addCleanupr��mkdirr�r��open�writer�r�can_symlink�symlink�dirlinkr�)rr�rrrrrhts:

�����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�rZpath_aZpath_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)NZuserprofile�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�)rZ
fileA_pathZ
fileB_pathrgr�r�Z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_common�s
��"�z_BasePathTest.test_open_commoncCsX|�t�}|d�d�|�|d��d�|�t|djd�|�|d��d�dS)Nr�sabcdefgZsomestr)rdr��write_bytesr�
read_bytesr�r�rfrrr�test_read_write_bytes	s

z#_BasePathTest.test_read_write_bytescCsf|�t�}|djddd�|�|djddd�d�|�t|djd	�|�|djdd�d�dS)
Nr�uäbcdefgzlatin-1��encodingzutf-8�ignore)r�errorsZbcdefgs	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)rrgZos_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>6�z-_BasePathTest.test_iterdir.<locals>.<setcomp>)rdr��iterdir�setrr�r)rrg�it�pathsrrrr�test_iterdir.sz_BasePathTest.test_iterdircs>|j��td�}t|���}�fdd�dD�}|�||�dS)Nr�csh|]}�td|��qS)r�rrrrrr>rz5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>)r�r�)rdr�rrr)rrgrrrrr�test_iterdir_symlink8s

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_nodirAs�
�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)NcrrrrrrrrMrzA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>�rr��globr�rmrrr�_checkL�"z._BasePathTest.test_glob_common.<locals>._checkr�r�z
dir*/file*�
dirB/fileB�
dirC/fileCz*Ar�)r�r�r�z*B/*)r+�
dirB/linkD�linkB/fileBzlinkB/linkD�*/fileBr.)	rdr�r'rk�collectionsr��Iteratorrr��rr)rgrrr(r�test_glob_commonKs"
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$)NcrrrrrrrrerzB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>r%r&r(rrr)dr*z/_BasePathTest.test_rglob_common.<locals>._checkr�r�r+z*/fileAr/)r+zdirB/linkD/fileBr.zdirA/linkC/fileBzfile*)r�r+r,�dirC/dirD/fileDr�r,r4z*/*)	rdr��rglobrkr0r�r1rr�r2rr(r�test_rglob_commoncs

z_BasePathTest.test_rglob_commoncsB|j}|t��t��d��}hd�}|�|�fdd�|D��dS)N�*>r�r4r�r�r�r,r�z
dirA/linkCr�r�r+r�z	dirC/dirDr�r-csh|]}�|�qSrrr
�rgrrr�r�z8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)rdr�rr5r)rrm�given�expectrr8r�test_rglob_symlink_loopxs

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�Zdeepr%T�r�r
r7csg|]}�����qSr)r'�r�j��base�patternrrr�rz;_BasePathTest.test_glob_many_open_files.<locals>.<listcomp>�dcsg|]}��d��qS)r%)r5r>)rArrr�r)rdr�r�r�rrr)r�depthrmrgZitersr�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�rrr'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)NZpermissions�file1�file2�subdir�file3�otherz
os.scandirr7r��r)rdr�r��touch�
symlink_tor�patch�sortedr��scandirZreturn_valuerr�rr'r�)rrmrArHrIrJrKrRrrr�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�rUF�in�spamr�r�r�r�r�r�r�r�r�z-dirD)r��dir�linkX�linkY)rdr�r�rrTrr�r�r�r�rsr�r�r��abspath�_check_resolve_relativer�rZ	_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�2TrW�3�4F)
rdr�r�r�r�r�rrTr�r�)rrgr�r�rrr�test_resolve_dots
 z_BasePathTest.test_resolve_dotc	CsT|�dd�}t��}t�t�z|�|��|�t|��Wt�|�dSt�|�w)NZnonZexist)rdr�r��chdirr�rrT)rrgZold_cwdrrr�)test_resolve_nonexist_relative_issue38671s
z7_BasePathTest.test_resolve_nonexist_relative_issue38671cCs�|�t�}|��}|��}t|�|�Wd�n1swYt|�t|�|��|��|��|�	Wd�dS1sEwYdSrp)rdr�rrr�rTr�)rrgrZit2rrr�	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_chmod5s


z_BasePathTest.test_chmodcCst|�t�d}|��}|��j}|d@}|j|dd�|�|��j|�|dB}|j|dd�|�|��j|�dS)Nr�rlT��follow_symlinksrm)rdr�rTr�rnr�r)rrgr�rorprrr�test_chmod_follow_symlinks_trueBs
z-_BasePathTest.test_chmod_follow_symlinks_truecCsZ|�t�d}|��}|�|��|�|�|jdA�|�|j|j�|�|��|�dS)Nr�rm)rdr�r�rr�rnr�r��rrg�strrr�	test_statRsz_BasePathTest.test_statcC�.|�t�d}|��}|�||jdd��dS)Nr�Frr)rdr�r�r�rurrr�test_stat_no_follow_symlinks[sz*_BasePathTest.test_stat_no_follow_symlinkscCrx)Nr�Frr)rdr�r�rrurrr�&test_stat_no_follow_symlinks_nosymlinkasz4_BasePathTest.test_stat_no_follow_symlinks_nosymlinkcC�*|�t�d}|��}|�||���dS)Nr�)rdr�r�r��lstatrurrr�
test_lstatfsz_BasePathTest.test_lstatcCr{r)rdr�r�rr|rurrr�test_lstat_nosymlinklsz"_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�q�
��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�dSr)rdr��unlinkr�r�rfrrr�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�rr��rmdirr�r�r�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_sizeZassertWarns�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�r�r��hardlink_torr�r�r�r�r�r�)rrm�targetr�r��link2Ztarget2rrr�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�r�r��renamerr�r�r�)rrmrgr�r�Z	renamed_pr�Z	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�r�r�rrr�r�r�)rrmrgr�r�Z
replaced_pr�Z
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�rr�rrr�
test_readlink�s
�"�z_BasePathTest.test_readlinkcCs�|�t�}|d}|�|���|��|�|���|��}|j}|j}t	�
t|�|d|df�|��|��}|�|j|�|�|j|�|d}|�|���|jddd�|�|���|j
t|jdd�dS)NZnewfileA�
ZnewfileBi�F)ro�exist_ok�r�)rdr�r�r�rNr�r��st_mtime�st_mtime_nsr��utimersr;r�r)rrmrgrvZ	old_mtimeZold_mtime_nsrrr�test_touch_common�s$
z_BasePathTest.test_touch_commoncCs^|�t�}|d}|��|�d��}|�|����d�Wd�dS1s(wYdS)Nr�r�r�)rdr�rNr�rr�r�)rrmrgrrrr�test_touch_nochanges
"�z!_BasePathTest.test_touch_nochangecCs�|�t�}|d}|�|���|��|�|���|�|���|�t��}|��Wd�n1s6wY|�	|j
jtj�dS)NZnewdirA)
rdr�r�r�r�r��is_dirr�rrr�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)
NZnewdirB�newdirCTr=ZnewdirDZnewdirEimr�im)rdr�r�r�r�rr�rr�r�r�r�r�r�r��S_IMODErnr�r�r�)rrgr�rorrr�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�Tr=�r�r�)
rdr�r�r�r�r�r�rr�r�r�r�r�)rrgr�r�rrr�test_mkdir_exist_ok_with_parentFs"
�
�z-_BasePathTest.test_mkdir_exist_ok_with_parentcCs2|�d���jdd�|�d���jddd�dS)Nr
Tr�r�)rdrTr�r{rrr�test_mkdir_exist_ok_rootWsz&_BasePathTest.test_mkdir_exist_ok_rootcCsrdD]}|�|d�}|��sqq|�d�|�t��|ddjdd�Wd�dS1s2wYdS)NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't exist�childr�Tr=)rdr�r#r�rr�)rr%rgrrr�test_mkdir_with_unknown_drive\s�
"�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�Tr=r��rdr�r�r�r�r�r�rr�r�r�r"rrr�test_mkdir_with_child_filegs��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_filess
��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�ro)�concurrently_createdrBrr�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>�Zdir1Zdir2zpathlib._normal_accessor.mkdirTFr�)r�)rrdr�r�r�rrrPr�r�rrsZassertNotInr�)rrgr�Zp12r)r�rBr�r�%test_mkdir_concurrent_parent_creations$����z3_BasePathTest.test_mkdir_concurrent_parent_creationcCs|�t�}|d}|dd}|�|�|�|��|���|�|��|���|dd}|�t|��|�|��|���|�|��|���|�|�	��|d}|dd}|j|dd�|�|��|���|�|��|���|�
|�	��|�
t|����dS)	Nr�r�ZlinkAAZlinkAAAr�ZlinkAAAATr�)
rdr�rOrr�r�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�r�r�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�r�r�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�r�r�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�r�r�r�r�r�Fr�ulinkA�zlinkA)	rdr�r��
is_symlinkrr�r�rur�r�rrr�test_is_symlink�s
�z_BasePathTest.test_is_symlinkcC�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dS�Nr�r�r�r�r�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)NZmyfifozos.mkfifo(): %su	myfifo�Fzmyfifo)
rdr�r�r�rsr�r#r�r�r��	is_socketr�ru)rrmr�rrr�test_is_fifo_true�s��z_BasePathTest.test_is_fifo_truecCr�r�)rdr�r�r�rur�rrr�test_is_socket_false	r�z"_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)NZmysockzAF_UNIX path too longzcannot bind Unix socket: u	mysock�Fzmysock)rdr��socketr��SOCK_STREAMr��close�bindrsr�
isinstancer�r#r�r�r�r�r�ru)rrm�sockr�rrr�test_is_socket_true
	s"

���z!_BasePathTest.test_is_socket_truecCr�r�)rdr�r��is_block_devicerur�rrr�test_is_block_device_false	r�z(_BasePathTest.test_is_block_device_falsecCr�r�)rdr�r��is_char_devicerur�rrr�test_is_char_device_false'	r�z'_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�r�rur�rrr�test_is_char_device_true0	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_interningB	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)NZlink0Zlink1r�Zlink3)rdr�r�r�r�r�rTrr�rsr�ri)rZlink0_targetrmrgZold_pathrrr�_check_complex_symlinksK	sB

z%_BasePathTest._check_complex_symlinkscCs|�t�dSrp)r�r�r{rrr�test_complex_symlinks_absolutet	�z,_BasePathTest.test_complex_symlinks_absolutecCs|�d�dS)Nr')r�r{rrr�test_complex_symlinks_relativex	r�z,_BasePathTest.test_complex_symlinks_relativecCs|�tj�dd��dS)Nr�r�)r�r�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�r�r�r�r�r�rr	rrr�skip_unless_symlinkrr#r3r6r;rFrGrSrVr^rarbrhrjrkrq�
only_posixrtrwryrzr}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�r�r�r�r�r�r�r��sys�platformr�r�r�r�r�r�r�rr�r�r�r�r�rrrrr�^s�


	





$
<



	











	





	�	
			)

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)rdZassertRaisesRegexr�r�r'rfrrr�test_glob_empty_pattern�	s"�z PathTest.test_glob_empty_patternN)
r0r1r2rI�Pathrdrr�rrrrrrr��	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)�
PosixPathTestTrWcGsH|j|�}|�t��t|�|��Wd�dS1swYdSrp)rdr��RuntimeError�printrT)rrUrwr�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�r�r�rr�rn�rZold_maskrgrvrrr�test_open_mode�	s

�
�zPosixPathTest.test_open_modec	CsNt��}zt�d�|�d�}|�t|���d�Wt�|�dSt�|�w)Nr
rYz/spam)r�r�rirdrrsrT)rZcurrent_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)
Nrr	r
rrr
Zmasked_new_filei�)ro)r�rr�rdr�rNr�r�rr�rnrrrr�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/insider[r\zlinkZ/../linkZZlinkZr�FrWzlinkU/insideZlinkUZlinkVzlinkW/../linkWZlinkW)r�r�r�rr�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�rr'r�fs_is_case_insensitiver�rrmrgr9r:rrr�	test_glob�	szPosixPathTest.test_globcCsZ|j}|td�}t|�d��}t�t�st�n|}|�||�|�t|�d��t��dS)Nr��FILEdzFILEd*)rdr�rr5rrrrrrr�
test_rglob�	s
zPosixPathTest.test_rglob�getpwallz%pwd module does not expose getpwall()r�zno home directory on VxWorkscCsX|j}t�d�ddl}|�t���}|j}|j�	d�pd}|�
�D]}|j}|j�	d�}||kr5|r5q:q"|}|}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
Zfakeuserrdz~/Documentsr�z
/Documentsr�r�rr�Z	Documentsz/tmpz/tmp/Documents)rdr�
import_moduler�r�r��getuidr��pw_dir�rstripr�getpwnamr�rr�r�rr�r�r)rrmr�Zpwdent�username�userhomeZ	othernameZ	otherhomeZfakename�p1�p2�p3�p4�p5�p6Zp7r�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/fdr7r�z.no file descriptors - issue was not reproducedz Bad file descriptor not handled.)r�rIrr5r#r�r�r�r�r�r�r�r�rr��EBADFZfail)rZfile_descriptorsrr�rrr�test_handling_bad_descriptor%
s(

�	
��z*PosixPathTest.test_handling_bad_descriptorN)r0r1r2rIr�rdrrrrrr�rrrr�r�r�r�r�r�r�r(r+rrrrr�	s*	
��5�rc@r�)�WindowsPathTestcCs�|j}|t�}|�t|�d��|td�h�|�t|�d��|td�h�|�ttt|�d���|�d�h�|�ttt|�d���|�d�h�dS)Nrr�zF*az\FILEaz\fileA)rdr�rrr'�maprsrlrrrrA
s$(zWindowsPathTest.test_globcCsV|j}|td�}|�t|�d��|td�h�|�ttt|�d���|�d�h�dS)Nr�rr4z\dirD\FILEd)rdr�rrr5r-rsrlrrrrI
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)Nr1zC:/Users/alice/My Documentsr0zC:/Users/bob/My Documents)r�rr�r�rr�	rmr�r"r#r$r%r&r'rrrr.f
s
�
�
�z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alicezC:\Users\eve)rdrr�r�r�rr�rr<rr2rr(O
s@
"�zWindowsPathTest.test_expanduserN)	r0r1r2rIr�rdrrr(rrrrr,=
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)rr4rrr�__init__�
s
z&CompatiblePathTest.CompatPath.__init__cCst|�|j�d|���Sr��rvr4�rrLrrr�__truediv__�
rz)CompatiblePathTest.CompatPath.__truediv__cCst|�|�d|j���Sr�r6r7rrr�__rtruediv__�
rz*CompatiblePathTest.CompatPath.__rtruediv__N)r0r1r2r�r5r8r9rrrr�
CompatPath�
s
r:cCsnt�d�|�d�}|�||j�|�|jd�|�t��t�d�dWd�dS1s0wYdS)N�test�rightz
test/rightr�)rIr�r:rkrr4r�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�rkrr4r�r�r=rrr�
test_rtruediv�
r@z CompatiblePathTest.test_rtruedivN)r0r1r2r�r:r?rBrrrrr3�
s
	r3�__main__)1�collections.abcr0r�r�r�r�rIrr�r�r_r�rZtest.supportrrZtest.support.os_helperrrr�r��ImportError�objectrZTestCaser4rKr]rr3r�r��realpathr�r�r�r�r�r�r�r�r�r�r�rr,r3r0�mainrrrr�<module>s��)$BL��+%G
)�
© 2025 GrazzMean