Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_pathlib.cpython-38.pyc
U

>��g{��@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZddl
mZddlmZmZzddlZddlZWnek
r�dZZYnXGdd�de�ZGdd�deej�ZGd	d
�d
eej�ZGdd�de�ZGd
d�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)Gdd �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�/�dS)(�N)�mock)�support)�TESTFN�FakePathc@seZdZdd�Zdd�ZdS)�_BaseFlavourTestcsd|jj}|jj�|jj�|�fdd�|D��}|�||��r`|�fdd�|D��}|�||�dS)Ncsg|]}|�d���qS��/��replace��.0�x)�sep��0/opt/cppython/lib/python3.8/test/test_pathlib.py�
<listcomp>sz7_BaseFlavourTest._check_parse_parts.<locals>.<listcomp>csg|]}|�d���qSrr	r)�altseprrr s)�flavourZparse_partsrr�assertEqual)�self�arg�expected�f�actualr)rrr�_check_parse_partssz#_BaseFlavourTest._check_parse_partscCs�|j}|jj}|gddgf�|dgdddgf�|dgdddgf�|ddgddddgf�|dgddddgf�|dgddddgf�|dddgddddd	dgf�|dd
dgddddd	dgf�|dddgddddd	dgf�|dgddgf�|dddgdddgf�|dddgddddgf�|dddgdddgf�|d
gd||ddgf�|ddgd||ddgf�|ddgd||ddgf�|ddd	gd||dd	gf�|dddgd||d	gf�dS)N��a�a/�b�a/b�a/b/zb/c�d�czb//czb/c/�.�/a/b�/a�/a/�/b�/c)rrr)r�checkrrrr�test_parse_parts_common#s(z(_BaseFlavourTest.test_parse_parts_commonN)�__name__�
__module__�__qualname__rr*rrrrrs
rc@s"eZdZejZdd�Zdd�ZdS)�PosixFlavourTestcCs�|j}|ddgdddddgf�|ddgdddddgf�|ddgdddddgf�|d	gddd	gf�|d
gddd
gf�|dgdddgf�dS)N�//arr�//r�///arz////a�c:a�c:\a�\a�r�rr)rrr�test_parse_partsCsz!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�rrrr)rrrr )rrr r%)rrrr$)rrr�/a/b/)rrr r/)rr0rr1�///a/b�c:/a/b)rrr<�\/a/b)rrr=�\a\b)rrr>�rZ	splitrootr�rrrrr�test_splitrootOszPosixFlavourTest.test_splitrootN)r+r,r-�pathlibZ_posix_flavourrr7rArrrrr.@sr.c@s"eZdZejZdd�Zdd�ZdS)�
NTFlavourTestcCs|j}|dgdddgf�|dgdddgf�|dgdddgf�|dgddddgf�|d	gddddgf�|d
gddddgf�|dgddd
gf�|dgddd
gf�|dgddd
dgf�|dddgdddddgf�|dddgdddddgf�|dddgddddgf�|dddgddddddgf�|dddgddddgf�|dgdddgf�|d gddddgf�|d d!gddddgf�|d"gd#dd$gf�|d%gd#dd$dgf�|dd!dgdddddgf�|d&d!dgdddddgf�|d'd!dgd(dd)ddgf�dS)*N�c:r�c:/�\�c:\rr2r�c:/ar%�//a/b�\\a\b�\\a\b\�//a/b/�//a/b/cr"zZ:bzZ:rzZ:/bzZ:\z//b/cr!z\\b\cz\\b\c\z	Z://b//c/�d/z//b/c//z//?/c:/z\\?\c:z\\?\c:\z//?/c:/ar'z//?/UNC/b/cz\\?\UNC\b\cz\\?\UNC\b\c\z
//?/UNC/b/c/dzZ:/az//?/Z:/az\\?\Z:z\\?\Z:\r5r6rrrr7gs.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)Nrr8rr9�a\b)rrrOr4)rrFrr>)rrFrOzc:a\b)rDrrOzc:\a\b)rDrFrOz\\az\\\a/b)rrFrzc:\\a)rDrFrzc:\\\a/b)rDrFrrJ)rJrFrrK�	\\a\b\c\d)rJrF�c\dz\\\a\br?r@rrrrA�s"zNTFlavourTest.test_splitrootN)r+r,r-rBZ_windows_flavourrr7rArrrrrCds"rCc
@s.eZdZddddddddd	d
g
ddd
dddgd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z	dd�Z
d d!�Zd"d#�Zd$d%�Z
d&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zd@dA�ZdBdC�ZdDdE�ZdFdG�ZdHdI�ZdJdK�Z dLdM�Z!dNdO�Z"dPS)Q�_BasePurePathTest�rr)rr)r�b/)rrT)r )za//b)za//b//)rrr)rrr)rrr)r�/b/cr!)rz///b//crN)r%rUr!)rrr�c/d)rrzb/c/d)r�/b/c/d)rrWcCs*|�d�}|j|_|jj|_|jj|_dS�Nr)�clsZ_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)Nrrr"r%�a/b/c�/a/b/cr)rY�assertIsInstancerr�r�Pr[rrr�test_constructor_common�sz)_BasePurePathTest.test_constructor_commoncs\Gdd�dt��|j}|�fdd�|D��}|�|||��|jD]}|�t|�t�qBdS)Nc@seZdZdS)z:_BasePurePathTest._check_str_subclass.<locals>.StrSubclassN)r+r,r-rrrr�StrSubclass�srcc3s|]}�|�VqdS�Nrr�rcrr�	<genexpr>�sz8_BasePurePathTest._check_str_subclass.<locals>.<genexpr>)�strrYr�parts�assertIs�type)r�argsrar[�partrrer�_check_str_subclass�s
z%_BasePurePathTest._check_str_subclasscCs6|�d�|�d�|�d�|�d�|�d�dS)Nrr#rza/b.txtz/a/b.txt�rm�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)Nrr"r]r!�a/b/c/dr()rY�joinpathrrirj�rrar[�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)	Nrr"r]rVrqr!zc/a/b/dr()rYrrirjrsrrr�test_div_common�sz!_BasePurePathTest.test_div_commoncCs(|j|�}|�t|�|�d|j��dS�Nr)rYrrgr
r)rrrkr[rrr�
_check_str�s
z_BasePurePathTest._check_strcCs(dD]}|�||f�q|�dd�dS)N�rrr]rr$r^r#)r)rx)r�pathstrrrr�test_str_commonsz!_BasePurePathTest.test_str_commoncCs(|j}dD]}|�||���|�q
dS)Nry)rYr�as_posix)rrarzrrr�test_as_posix_commonsz&_BasePurePathTest.test_as_posix_commoncCs2t�|j�}|j}|�t|d��d|d�dS)Nr�a�b)�os�fsencoderrYr�bytes)rrrarrr�test_as_bytes_commonsz&_BasePurePathTest.test_as_bytes_commonc	CsL|j}|�t��|d���W5QRX|�t��|���W5QRXdSrX)rY�assertRaises�
ValueError�as_uri�rrarrr�test_as_uri_commons
z$_BasePurePathTest.test_as_uri_commoncCs�dD]�}|�|�}|jj}t|�}|�|�|d�|�|�|�d�|�|t|�dd�}|�t	|�|�
��t	|tj�}|�
|j|j�|�||�|�t|�|�qdS)Nry�(�)����)rY�	__class__r+�repr�
assertTrue�
startswith�endswith�lenr�evalr|rB�__dict__ri)rrzr[Zclsname�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)Nrrrr$rr)rYr�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)Nrrr#�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)rYr�r��matchr��assertFalser�rrr�test_match_common:s<z#_BasePurePathTest.test_match_commonc	s��fdd�}�j}|d�}|d�}|d�}|d�}|||�|||�|||�|||�|||��j}|d�}|d�}|d	�}|d
�}|||�|||�|||�|||�|||���t��|�ikW5QRXdS)Ncs��||���||�dSrd)�
assertLessZ
assertGreaterrSrorrr�bsz:_BasePurePathTest.test_ordering_common.<locals>.assertLessrr�abcrr%r$z/abcr')rYr��	TypeError)rr�rarrr"r!rror�test_ordering_common`s.









z&_BasePurePathTest.test_ordering_commoncCsX|j}|j}|d�}|j}|�|d�|�||j�|d�}|j}|�||ddf�dS)NrrSr$rr)rrYrhrri)rrrar[rhrrr�test_parts_common|sz#_BasePurePathTest.test_parts_commoncCs4|j}|d�}|�|��d�|�t�|�d�dS)Nr)r)rYrx�
__fspath__r��fspathr`rrr�test_fspath_common�sz$_BasePurePathTest.test_fspath_commonc	s��j��D]�\}}|�d�j�}|��jd�}||krX|�fdd�|D�}|�|f���|�}|D]V}�j|�}��||d�|����t|�t|����t	|�|���|�
�|�qfq
dS)Nrcs"g|]}t�fdd�|D���qS)c3s|]}|�d�j�VqdS)rN)r
r)rrlrorrrf�szA_BasePurePathTest.test_equivalences.<locals>.<listcomp>.<genexpr>)�tuple)r�trorrr�s�z7_BasePurePathTest.test_equivalences.<locals>.<listcomp>zfailed with args {})�equivalences�itemsr
r�appendrYr�format�hashrgr|)r�kZtuplesZcanon�posixZpcanonr�r[rror�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)Nr]rrr^r$r%r�rYr�parentr`rrr�test_parent_common�sz$_BasePurePathTest.test_parent_commonc	Csz|j}|d�}|j}|�t|�d�|�|d|d��|�|d|d��|�|d|d��|�t|�|d�|d�|d�g�|�t��|d	W5QRX|�t��|dW5QRX|�t��||d<W5QRX|d
�}|j}|�t|�d�|�|d|d��|�|d|d��|�|d|d
��|�t|�|d�|d�|d
�g�|�t��|dW5QRXdS)Nr]�rrr�r�r#r�r^r$r%r)rY�parentsrr��listr��
IndexErrorr��rrar[Zparrrr�test_parents_common�s.""z%_BasePurePathTest.test_parents_commoncCs@|j}|�|d�jd�|�|d�jd�|�|d�jd�dS)Nrrr$�rYrZdriver�rrr�test_drive_common�sz#_BasePurePathTest.test_drive_commoncCsX|j}|j}|�|d�jd�|�|d�jd�|�|d�j|�|�|d�j|�dS�Nrrrr$)rYrr�root�rrarrrr�test_root_common�sz"_BasePurePathTest.test_root_commoncCsX|j}|j}|�|d�jd�|�|d�jd�|�|d�j|�|�|d�j|�dSr�)rYrr�anchorr�rrr�test_anchor_common�sz$_BasePurePathTest.test_anchor_commoncCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd	�|�|d
�jd	�dS)Nrr#rrrr$�/a/b/.r�r�r��rYr�namer�rrr�test_name_common�sz"_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#�..rrr$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.�rYr�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#rrr$r�r�r�r�r�r�r�r�r�r��.tarr�r�r�r��rYr�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�rrrr�r��.hgrcr��.hgr��b.tarr��Some name. Ending with a dot.�rYrZstemr�rrr�test_stem_commons�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�z
a/Dot ending.z/a/Dot ending.rr#rr(zc/rV�rYrZ	with_namer�r�r�rrr�test_with_name_common"sz'_BasePurePathTest.test_with_name_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)Nrr�za/b.gzr$z/a/b.gzr�r�rr#r�gz�/.gzrVz.c/.dz./.dz.d/.r!)rYr�with_suffixr�r�rrr�rrr�test_with_suffix_common2s*
�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)Nrr~rrrrr"r]za/cr%r$rr&r(r^z/a/c)rYr�r��relative_torr�r`rrr�test_relative_to_commonKs<z)_BasePurePathTest.test_relative_to_commoncCs�|j}|d�}tdtjd�D]^}t�||�}t�|�}|�|j|j�|�||�|�t	|�t	|��|�t
|�t
|��qdS)Nr$rr�)rY�range�pickle�HIGHEST_PROTOCOL�dumps�loadsrir�rr�rg)rrar[�proto�dumpedrtrrr�test_pickling_commonns
z&_BasePurePathTest.test_pickling_commonN)#r+r,r-r�r\rbrmrprurvrxr{r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrR�sd���

&#rRc@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$rr;rIr0�rYrr�r�rrr�	test_root}szPurePosixPathTest.test_rootcCsF|j}|�|d�|d��|�|d�|d��|�|d�|d��dS)Nr�A/br%r1r/)rYr�rr�rrr�test_eq�szPurePosixPathTest.test_eqcCsF|j}|�|d���d�|�|d���d�|�|d���d�dS)Nrzfile:///z/a/b.cz
file:///a/b.cz/a/b%#czfile:///a/b%25%23c)rYrr�r�rrr�test_as_uri�szPurePosixPathTest.test_as_uricCsfddlm}|j}zt�d�Wntk
r>|�d�YnX|�|d���d|t�d���dS)Nr)�quote_from_bytes�éz1\xe9 cannot be encoded to the filesystem encodingu/a/bézfile:///a/b)	Zurllib.parser�rYr�r��UnicodeEncodeError�skipTestrr�)rr�rarrr�test_as_uri_non_ascii�s�z'PurePosixPathTest.test_as_uri_non_asciicCs|j}|�|d��d��dS)NzA.pyza.PY)rYr�r�r�rrr�
test_match�szPurePosixPathTest.test_matchcCs�|j}|�|����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����dS)Nrr rr%r:r/rI�rYr��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�rYriZis_reservedr�rrr�test_is_reserved�s
z"PurePosixPathTest.test_is_reservedcCsh|j}|d�}|�d�}|�||d��|d��d�}|�||d��|d��d�}|�||d��dS�Nr/rrIr%z//cr(�rYrrrrsrrr�	test_join�s
zPurePosixPathTest.test_joincCsb|j}|d�}|d}|�||d��|d�d}|�||d��|d�d}|�||d��dSr�rYrrsrrr�test_div�szPurePosixPathTest.test_divN)r+r,r-rB�
PurePosixPathrYr�r�r�rrrrr
rrrrrr�zs

r�c@s�eZdZejZej��Ze�	dddgdddddgd	gd
dgd��d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;S)<�PureWindowsPathTest)rDr)rDr)rrDr)rEr)rDrr)rDr%)z/zrEr)z//x/yrEr)rI)rIr")rLr")r2rHrLrMcCs�|�d�}|�t|�d�|�d�}|�t|�d�|�d�}|�t|�d�|�d�}|�t|�d�|�d	�}|�t|�d
�dS)Nr]za\b\czc:/a/b/czc:\a\b\crIrKrMz\\a\b\c�	//a/b/c/drP)rYrrgrZrrr�test_str�s




zPureWindowsPathTest.test_strcCs^|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�dS)
NrDr2z	c:a\b.txtrGr3z
c:\a\b.txtz\\some\sharez\\some\share\az\\some\share\a\b.txtrnrorrr�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/brDrrzd:a/br<r$za/Br��C:a/B�c:A/b�//Some/SHARE/a/Bz//somE/share/A/b)rYrr�r�rrrr��szPureWindowsPathTest.test_eqc	Cs�|j}|�t��|d���W5QRX|�t��|d���W5QRX|�|d���d�|�|d���d�|�|d���d�|�|d	���d
�|�|d���d�|�|d
���d�|�|d���d�dS)Nr$rrEzfile:///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)rYr�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)rYr�r�r�r�rrrr�	s&z%PureWindowsPathTest.test_match_commoncs��fdd�}�j}|d�}|d�}|||���||k���||k�|d�}|d�}|||���||k���||k�dS)Ncs��||���||�dSrd)ZassertLessEqual�assertGreaterEqualrSrorr�assertOrderedEqual#szDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualrrz//some/Share/A/br)rYr�)rrrar[r�rrorr�!s

z(PureWindowsPathTest.test_ordering_commoncCsX|j}|d�}|j}|�|d�|d�}|j}|�|d�|d�}|j}|�|d�dS)Nr)rDrrr<)rGrrr)rKr"r!)rYrhr)rrar[rhrrr�
test_parts2s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:/rrMrIr�r`rrr�test_parent>szPureWindowsPathTest.test_parentc	Cs�|j}|d�}|j}|�t|�d�|�|d|d��|�|d|d��|�t|�|d�|d�g�|�t��|dW5QRX|d�}|j}|�t|�d�|�|d|d��|�|d|d	��|�t|�|d�|d	�g�|�t��|dW5QRX|d
�}|j}|�t|�d�|�|d|d��|�|d|d��|�t|�|d�|d�g�|�t��|dW5QRXdS)
Nzz:a/b/r�rrr�rzz:/a/b/rrrrMrI)rYr�rr�r�r�r�r�rrr�test_parentsPs2z PureWindowsPathTest.test_parentscCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�dS)	NrDrrE�c:/a/b/rIrJrLrr�r�rrr�
test_drivelszPureWindowsPathTest.test_drivecCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrDrrrErFrrIrLrr�r�rrrr�vszPureWindowsPathTest.test_rootcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrDrrErGrrIrKrLr)rYrr�r�rrr�test_anchor�szPureWindowsPathTest.test_anchorcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�|�|d
�jd�|�|d�jd�dS)NrDrrErrr<�c:a/b.pyr��	c:/a/b.py�//My.py/Share.php�//My.py/Share.php/a/br�r�rrr�	test_name�szPureWindowsPathTest.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)NrDrrErr<r"r�r#�	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.r$r%r�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)NrDrErr<r"r�r#r'r(r)r�r*r+r�r�r,r$r%r-r.r�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)NrDrzc:.zc:..r�rErrr"r'r�r)r�r+r�r-r�r�r�rrr�	test_stem�s�zPureWindowsPathTest.test_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
�dS)Nrr�z	c:a/d.xmlr<z
c:/a/d.xmlzc:a/Dot ending.zc:/a/Dot ending.rDrE�
//My/Share�d:zd:ezd:/er�r�rrr�test_with_name�sz"PureWindowsPathTest.test_with_namecCs�|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)Nrr�zc:a/b.gzr<z	c:/a/b.gzr"r#rr#rr2r�rFrDr�z\.gzzc:.gzrVrQz.c/dz.c\d)rYrr�r�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)'Nz	C:Foo/BarrDzFoo/Barzc:foOZBarzc:foO/z	c:foO/baRrr3rZFooz/FoozC:/Fooz
C:Foo/Bar/Bazz	C:Foo/Bazz
C:/Foo/Barz/Foo/Barz\Foo\BarrEzc:/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)rYrr�r�r�rgr`rrr�test_relative_to�shz$PureWindowsPathTest.test_relative_tocCs(|j}|�|����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d	����|�|d
����|�|d����|�|d����|�|d
����|�|d����|�|d����dS)Nrr rr%r:rDr2zc:a/b/rErHrrIrLrMrrr�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	rsrrrr
>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)Nr7r8r9r
�yr:r;z/xr<zD:r=r>r?r@rr`rrrrTszPureWindowsPathTest.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����dS)NFrrrTZconZNULzNUL.txtZcom1zcom9.barzbar.com9Zlpt1zlpt9.barzbar.lpt9zc:/NUL/con/bazz//my/share/nul/con/auxrr�rrrrhsz$PureWindowsPathTest.test_is_reservedN)!r+r,r-rB�PureWindowsPathrYrRr��copy�updaterrr�r�r�r�rrrr r�r!r&r/r0r1r4r5r6rr
rrrrrrr�sL
���


:rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�PurePathTestcCs0|�d�}|�t|�tjdkr$tjntj�dS�Nr�nt)rYrirjr�r�rBrBr
rZrrr�test_concrete_class~s

�z PurePathTest.test_concrete_classcCs$t�d�}t�d�}|�||�dSrX)rBr
rBr��rr[r�rrr�test_different_flavours_unequal�s

z,PurePathTest.test_different_flavours_unequalc	Cs�t�d�}t�d�}|�t��||kW5QRX|�t��||kW5QRX|�t��||kW5QRX|�t��||kW5QRXdSrX)rBr
rBr�r�rIrrr�!test_different_flavours_unordered�s

z.PurePathTest.test_different_flavours_unorderedN)	r+r,r-rB�PurePathrYrHrJrKrrrrrE{srEcGstjjtf|��Srd)r��path�join�BASE�r
rrr�<lambda>��rQcGstjjtf|��Srd)r�rMrNrrPrrrrQ�rRrGz)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc@seZdZejZdS)�PosixPathAsPureTestN)r+r,r-rB�	PosixPathrYrrrrrS�srSc@s"eZdZejZdd�Zdd�ZdS)�WindowsPathAsPureTestc	Cs,|j}|�t��|d���W5QRXdS�NrE)rYr��NotImplementedError�ownerr�rrr�
test_owner�sz WindowsPathAsPureTest.test_ownerc	Cs,|j}|�t��|d���W5QRXdSrV)rYr�rW�groupr�rrr�
test_group�sz WindowsPathAsPureTest.test_groupN)r+r,r-rB�WindowsPathrYrYr[rrrrrU�srUc@s
eZdZdZdd�Zejdkr(dd�Zndd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zejd&d'��Zd(d)�Zd*d+�Zd,d-�Zejd.d/��Zd0d1�Zd2d3�Zejd4d5��Z d�d7d8�Z!e!Z"Z#ejd9d:��Z$ejd;d<��Z%d=d>�Z&d?d@�Z'dAdB�Z(ejdCdD��Z)dEdF�Z*e+�,e-dG�dHdI��Z.e+�,e/dJ�dKdL��Z0dMdN�Z1dOdP�Z2dQdR�Z3e+�,e4edS�dT�dUdV��Z5e+�6e4edS�dW�dXdY��Z7dZd[�Z8d\d]�Z9d^d_�Z:d`da�Z;dbdc�Z<ddde�Z=dfdg�Z>dhdi�Z?djdk�Z@eAdldm��ZBdndo�ZCdpdq�ZDdrds�ZEejdtdu��ZFdvdw�ZGdxdy�ZHeIdzd{��ZJd|d}�ZKd~d�ZLe+�,e4ed��d��d�d���ZMd�d��ZNe+�,e4eOd��d��d�d���ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVejd�d���ZWejd�d���ZXejd�d���ZYd�S)��
_BasePathTestz?Tests for the FS-accessing functionalities of the Path classes.c	Cs�dd�}|�|�t�t�t�td��t�td��t�td��t�tdd��t�td��ttd�d	��}|�d
�W5QRXttdd�d	��}|�d�W5QRXttdd
�d	��}|�d�W5QRXttddd�d	��}|�d�W5QRXt�td�d�t�	��r�t�
dtd��t�
dtd��|�dtd��|�tj�dd�tdd��|�tj�dd�tdd��t�
dtd��dS)NcSst�td�d�t�t�dS)N�dirE�)r��chmodrNr�rmtreerOrrrr�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�linkA�non-existing�
brokenLink�linkBr��linkC�linkD�brokenLinkLoop)
�
addCleanupr��mkdirrOrN�open�writer`r�can_symlink�symlink�dirlinkrM)rrbrrrrr\�s0


z_BasePathTest.setUprGcCstj||dd�dS)NT�Ztarget_is_directory�r�ru�r�src�destrrrrv�sz_BasePathTest.dirlinkcCst�||�dSrdrxryrrrrv�scCs*|�tj�t|�t|��d||f�dS)Nz&%r and %r don't point to the same file)r�r�rM�samefilerg�rZpath_aZpath_brrr�
assertSame�s
��z_BasePathTest.assertSamec	Os6|�t��}|||�W5QRX|�|jjtj�dSrd)r��FileNotFoundErrorr�	exception�errno�ENOENT)r�funcrk�kwargs�cmrrr�assertFileNotFound�sz _BasePathTest.assertFileNotFoundcCs |�tj�|�tj�|��dSrd)rr�rM�normcaser}rrr�assertEqualNormCase�sz!_BasePathTest.assertEqualNormCasecCsT|�t���}|�||�|�t|�t|��|�t|�t|��|�|�	��dSrd)
rYr��getcwdrr�rgrirjr�rrIrrr�	_test_cwds
z_BasePathTest._test_cwdcCs|j��}|�|�dSrd)rY�cwdr�rZrrr�test_cwds
z_BasePathTest.test_cwdcCsX|�tj�d��}|�||�|�t|�t|��|�t|�t|��|�	|�
��dS)N�~)rYr�rM�
expanduserrr�rgrirjr�rrIrrr�
_test_homes
z_BasePathTest._test_homec	Cstt���b}|�|j���|��tj�t	d�|d<|�|j���tj�t	d�|d<|�|j���W5QRXdS)NZuserprofile�USERPROFILE�home�HOME)
r�EnvironmentVarGuardr�rYr��clearr�rMrNrO)r�envrrr�	test_homes
z_BasePathTest.test_homecCs�tj�td�}tj�tdd�}|�|�}|�|�}|�|�}|�|�|��|�|�|��|�|�|��|�|�|��tj�td�}|�|�}|�t	|j|�|�t	|j|�|�t	|j|�|�t	|j|�|�t	|j|�|�t	|j|�dS)Nrfrdrh�foo)
r�rMrNrOrYr�r|r�r�r)rZ
fileA_pathZ
fileB_pathr[rtr�Znon_existentr�rrr�
test_samefiles"



z_BasePathTest.test_samefilecCs$|�d�}|�|��t�d��dS)Nrr#)rYr�statr�rZrrr�test_empty_path2s
z_BasePathTest.test_empty_pathcCs�|j}|d�}|�|��|tj�d���|d�}|�|��|�|d�}|�|��|�|d�}|�|��|�||d���j�d}|�|��|�dS)Nr�r��/~�../~r)rYrr�r�rM�absoluter�r`rrr�test_expanduser_common7sz$_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)
NTrcrfF�bahrirlrhr�z/xyzzyu��)rYrOri�existsrrtr`rrr�test_existsDsz_BasePathTest.test_existsc	Cs�|�t�}|d�d��$}|�|tj�|�|��d�W5QRX|d�d��(}|�|tj�|�|���	�d�W5QRX|djddd��(}|�|tj
�|�|���	�d�W5QRXdS)Nrfr�zthis is file A
�rb�this is file Ar)�	buffering)rYrOrrr_�io�
TextIOBaser�read�BufferedIOBase�strip�	RawIOBase)rr[rrrr�test_open_commonUs
z_BasePathTest.test_open_commoncCsX|�t�}|d�d�|�|d��d�|�t|djd�|�|d��d�dS)NrfsabcdefgZsomestr)rYrOZwrite_bytesrZ
read_bytesr�r�rZrrr�test_read_write_bytesas

z#_BasePathTest.test_read_write_bytescCsf|�t�}|djddd�|�|djddd�d�|�t|djd	�|�|djdd�d�dS)
Nrfuäbcdefgzlatin-1)�encodingzutf-8�ignore)r��errorsZbcdefgs	somebytes)rYrOZ
write_textrZ	read_textr�r�rZrrr�test_read_write_textis
��z"_BasePathTest.test_read_write_textcsb|j��t�}|��}t|�}dddddg}t��rD|dddd	g7}|�|�fd
d�|D��dS)Nrcrdrer^rfrirlrkrocsh|]}�t|��qSr�rO�rr��rarr�	<setcomp>zsz-_BasePathTest.test_iterdir.<locals>.<setcomp>)rYrO�iterdir�setrrtr)rr[�it�pathsrrr�r�test_iterdirrsz_BasePathTest.test_iterdircs>|j��td�}t|���}�fdd�dD�}|�||�dS)Nrlcsh|]}�td|��qS)rlr�r�r�rrr��sz5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>)rhrn)rYrOr�r�r)rr[r�rrr�r�test_iterdir_symlink|s

z"_BasePathTest.test_iterdir_symlinkc	CsN|�td�}|�t��}t|���W5QRX|�|jjtj	tj
tjf�dS�Nrf)rYrOr��OSError�nextr��assertInr�r�ZENOTDIRr��EINVAL�rr[r�rrr�test_iterdir_nodir�s�z _BasePathTest.test_iterdir_nodircs��fdd�}�j��t�}|�d�}��|tjj�||dg�||�d�g�||�d�ddg�t��s�||�d�d	dg�n||�d�d	dd
g�t��s�||�d�dg�n||�d�ddd
dg�t��s�||�d�dg�n||�d�dd
g�dS)Ncs"��t|��fdd�|D��dS)Ncsh|]}�t|��qSrr�r�r�rrr��szA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>�rr���globr�rarrr�_check�sz._BasePathTest.test_glob_common.<locals>._checkrfrhz
dir*/file*�
dirB/fileB�
dirC/fileCz*Arcriz*B/*�
dirB/linkD�linkB/fileBzlinkB/linkD�*/fileB)	rYrOr�r_�collectionsr��Iteratorrrt�rr�r[r�rr�r�test_glob_common�s(
�z_BasePathTest.test_glob_commoncs���fdd�}�j��t�}|�d�}��|tjj�||dg�||�d�dg�||�d�g�t��s�||�d�dg�n||�d�ddd	d
g�||�d�dddd
g��td�}||�d�dd
g�||�d�d
g�dS)Ncs"��t|��fdd�|D��dS)Ncsh|]}�t|��qSrr�r�r�rrr��szB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>r�r�r�rrr��sz/_BasePathTest.test_rglob_common.<locals>._checkrfrhr�z*/fileAr�zdirB/linkD/fileBr�zdirA/linkC/fileBzfile*r��dirC/dirD/fileDrez*/*)	rYrO�rglobr_r�r�r�rrtr�rr�r�test_rglob_common�s*
��
z_BasePathTest.test_rglob_commoncs\|j}|t��t��d��}dddddddd	d
ddd
dddh}|�|�fdd�|D��dS)N�*rkrcz
dirA/linkCrdr�r�rez	dirC/dirDr�r�r^rfrirlrocsh|]}�|�qSrrr�r[rrr��sz8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)rYrOr�r�r)rra�given�expectrr�r�test_rglob_symlink_loop�s(�
z%_BasePathTest.test_rglob_symlink_loopcs�d}|j}|t�d�|�fdg|��}|jdd�d�dg|����fdd	�td
�D�}|D]}|�t|�|�qb�fdd	�td
�D�}�}t|�D]&}|d}|D]}|�t|�|�q�q�dS)N�Zdeepr!T�r�rr�csg|]}�����qSr)r��r�j��base�patternrrr�sz;_BasePathTest.test_glob_many_open_files.<locals>.<listcomp>�dcsg|]}��d��qS)r!)r�r�)r�rrr�s)rYrOrqrNr�rr�)r�depthrar[Zitersr��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)rYrOrr�r�r`rrr�test_glob_dotdot�s
z_BasePathTest.test_glob_dotdotc	Cs.|j}|t�d}|��|d}|��|d}|��|d}|d}|�|d�t�d��0}tt�	|��|_
|�tt
|�d���d	�W5QRX|��t�d��0}tt�	|��|_
|�tt
|�d���d
�W5QRX|�d�t�d��0}tt�	|��|_
|�tt
|�d���d
�W5QRXdS)NZpermissions�file1�file2�subdir�file3�otherz
os.scandirr�r��r)rYrOrq�touch�
symlink_tor�patch�sortedr��scandirZreturn_valuerr�r�r�r`)rrar�r�r�r�r�r�rrr�test_glob_permissions�s*$$
z#_BasePathTest.test_glob_permissionsTcCs|�|�}|�||�dSrd)�resolver)rr[r�strictr�rrr�_check_resolves
z_BasePathTest._check_resolvec
Cs�|j}|td�}|�t��}|jdd�W5QRX|�|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�}tjdk�r�|�||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�r�|�|||ddd�d�n|�||tddd�d�dS)Nr�T�r�F�in�spamr�rdrhrirfrcrmrnrGz-dirD)r��dir�linkX�linkY)rYrOr�r�r�rr�r�r�r�rgr�rMrN�abspath�_check_resolve_relativer�rZ	_longpath�tempfile�mkdtempr�rpraru�_check_resolve_absolute)rrar[r�r!rrr�test_resolve_commonsh
���
�����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�2Tr��3�4F)
rYrOrvrNr�rMrr�r�r)rr[r�r�rrr�test_resolve_dotOs
z_BasePathTest.test_resolve_dotc	Cs�|�t�}|��}|��}t|�|�W5QRX|�tt|�|�tt|�|�t|j�|�t|j�|�t|j�|�t|j	�dSrd)
rYrOr�r�r�r�rrr�r��	__enter__)rr[r�Zit2rrr�	test_with]s

z_BasePathTest.test_withcCsd|�t�d}|��j}|d@}|�|�|�|��j|�|dB}|�|�|�|��j|�dS)Nrfim����)rYrOr��st_moder`r)rr[�modeZnew_moderrr�
test_chmodls


z_BasePathTest.test_chmodcCsZ|�t�d}|��}|�|��|�|�|jdA�|�|j|j�|�|��|�dS)Nrfr)rYrOr�rr`r	rpr��rr[�strrr�	test_statzsz_BasePathTest.test_statcCs*|�t�d}|��}|�||���dS)Nri)rYrOr�r��lstatrrrr�
test_lstat�sz_BasePathTest.test_lstatcCs*|�t�d}|��}|�||���dSr�)rYrOr�rrrrrr�test_lstat_nosymlink�sz"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testcCs`|�t�d}|��j}zt�|�j}Wn"tk
rJ|�d|�YnX|�	||�
��dS)Nrfz4user %d doesn't have an entry in the system database)rYrOr��st_uid�pwd�getpwuid�pw_name�KeyErrorr�rrX)rr[�uidr�rrrrY�s
�
z_BasePathTest.test_ownerz&the grp module is needed for this testcCs`|�t�d}|��j}zt�|�j}Wn"tk
rJ|�d|�YnX|�	||�
��dS)Nrfz5group %d doesn't have an entry in the system database)rYrOr��st_gid�grp�getgrgid�gr_namerr�rrZ)rr[�gidr�rrrr[�s
�
z_BasePathTest.test_groupcCs2|�t�d}|��|�|j�|�|j�dSr�)rYrO�unlinkr�r�rZrrr�test_unlink�sz_BasePathTest.test_unlinkcCs*|�t�d}|�|j�|jdd�dS)N�fileAAAT)Z
missing_ok)rYrOr�rrZrrr�test_unlink_missing_ok�sz$_BasePathTest.test_unlink_missing_okcCsH|�t�d}|��D]}|��q|��|�|j�|�|j�dS)Nrc)rYrOr�r�rmdirr�r�rIrrr�
test_rmdir�s
z_BasePathTest.test_rmdir�linkzos.link() is not presentc
Cs�|�t�}|d}|��j}|dd}z|�|�Wn0tk
rf}z|�d|�W5d}~XYnX|�|��j|�|�tj	�
||�d�|�|j�td�}|�|�|�t�|�j|�|�|j�dS)Nrfrc�fileAAz
os.link(): %sTr)
rYrOr��st_size�link_to�PermissionErrorr�rr�rMr|r��rel_join)rrar[�sizer��er�rrr�test_link_to�s

 
z_BasePathTest.test_link_tozos.link() is presentc	CsB|�t�}|d}|dd}|�t��|�|�W5QRXdS)Nrfrcr$)rYrOr�rWr&�rrar[r�rrr�test_link_to_not_implemented�s

z*_BasePathTest.test_link_to_not_implementedcCs�|�t�}|d}|��j}|dd}|�|�}|�||�|�|��j|�|�|j�td�}|�|�}|�||�|��|�t�|�j|�|�|j�dS)Nrfrcr$r)	rYrOr�r%�renamerr�r(r�)rrar[r)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)Nrfrcr$rdrh)	rYrOr�r%r
rr�r(r�)rrar[r)r�Z
replaced_pr�Z
replaced_qrrr�test_replace�s




z_BasePathTest.test_replacecCs�|�t�}|d}|�|���|��|�|���|��}|j}|j}t	�
t|�|d|df�|��|��}|�|j|�|�|j|�|d}|�|���|jddd�|�|���|j
t|jdd�dS)NZnewfileA�
ZnewfileBi�F)r
�exist_ok�r2)rYrOr�r�r�r�r��st_mtime�st_mtime_nsr��utimergrr�r�)rrar[r
Z	old_mtimeZold_mtime_nsrrr�test_touch_common�s$
z_BasePathTest.test_touch_commonc	CsH|�t�}|d}|��|�d��}|�|����d�W5QRXdS)Nrfr�r�)rYrOr�rrrr�r�)rrar[rrrr�test_touch_nochanges

z!_BasePathTest.test_touch_nochangec	Csx|�t�}|d}|�|���|��|�|���|�|���|�t��}|��W5QRX|�	|j
jtj�dS)NZnewdirA)
rYrOr�r�rqr��is_dirr�r�rr�r��EEXIST)rrar[r�rrr�
test_mkdirs
z_BasePathTest.test_mkdirc	Cs6|�tdd�}|�|���|�t��}|��W5QRX|�|jj	t	j
�|jdd�|�|���|�|���|�t��}|jdd�W5QRX|�|jj	t	j
�t�|��j�}|�tdd�}|jddd�|�|���|�|���tjdk�r|�t�|��j�d	|@�|�t�|j��j�|�dS)
NZnewdirB�newdirCTr�ZnewdirDZnewdirEimrGim)rYrOr�r�r�r�rqrr�r�r�r�r9r:r��S_IMODEr	r�r�r�)rr[r�r
rrr�test_mkdir_parents s&z _BasePathTest.test_mkdir_parentsc	Cs�|�td�}|��j}|�|���|�|���|�t��}|�	�W5QRX|�
|jjtj
�|j	dd�|�|���|�
|��j|�dS)NrdTr3)rYrOr��st_ctimer�r�r9r��FileExistsErrorrqrr�r�r:)rr[�st_ctime_firstr�rrr�test_mkdir_exist_ok9s
z!_BasePathTest.test_mkdir_exist_okc	Cs�|�td�}|�|���|�t��}|��W5QRX|�|jj	t	j
�|d}|jdd�|��j}|�|���|�t��}|jdd�W5QRX|�|jj	t	j
�|jddd�|�|���|�|��j|�dS)Nrer<Tr��r�r2)
rYrOr�r�r�r@rqrr�r�r:r�r?)rr[r�rArrr�test_mkdir_exist_ok_with_parentEs
z-_BasePathTest.test_mkdir_exist_ok_with_parentcCs2|�d���jdd�|�d���jddd�dS)NrTr3rC)rYr�rqrorrr�test_mkdir_exist_ok_rootVsz&_BasePathTest.test_mkdir_exist_ok_rootc	Cs\dD]}|�|d�}|��sq.q|�d�|�t��|ddjdd�W5QRXdS)NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't existZchildrMTr�)rYr9r�r�r�rq)rr!r[rrr�test_mkdir_with_unknown_drive[s
z+_BasePathTest.test_mkdir_with_unknown_drivec	Cs�|�tdd�}|�|���|�t��}|jdd�W5QRX|�|jj	t	j
�|�t��}|jddd�W5QRX|�|jj	t	j
�dS)NrdrhTr�rC�rYrOr�r�r�r@rqrr�r�r:r�rrr�test_mkdir_with_child_filefsz(_BasePathTest.test_mkdir_with_child_filec	Cs�|�td�}|�|���|�t��}|��W5QRX|�|jj	t	j
�|�t��}|jdd�W5QRX|�|jj	t	j
�dS)NrfTr3rGr�rrr�test_mkdir_no_parents_filersz(_BasePathTest.test_mkdir_no_parents_filec
s�td�D]ȉ|�td��}|�|���d��fdd�	}�fdd�td�D��t��|d	d
}z*t�d|��|jdd
d�W5QRXWn$t	k
r�|�
t|���YnX|�t|���|�
|���qdS)N� zdirCPC%dr_cs6t|�}���r&t�||���|�t�||�dSrd)rg�popr�rq�add)rMr
)�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>�Zdir1Zdir2zpathlib._normal_accessor.mkdirTFrC)r_)r�rYrOr�r�r�rr�rqr@r�rgZassertNotInr�)rr[rNZp12r)rMr�rQr�%test_mkdir_concurrent_parent_creation~sz3_BasePathTest.test_mkdir_concurrent_parent_creationcCs|�t�}|d}|dd}|�|�|�|��|���|�|��|���|dd}|�t|��|�|��|���|�|��|���|�|�	��|d}|dd}|j|dd�|�|��|���|�|��|���|�
|�	��|�
t|����dS)	NrfrcZlinkAAZlinkAAArdZlinkAAAATrw)
rYrOr�rr�r�rrgr�r9r�r�r�)rra�targetr#rrr�test_symlink_to�s$

z_BasePathTest.test_symlink_tocCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��r�|�|d���|�|d���|�|d��d�|�|d	��d�|�|d
��d�dS)Nrcrfrjr�rirlrkFudirA�zdirA)rYrOr�r9r�rrtrir�rrr�test_is_dir�s
z_BasePathTest.test_is_dircCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��r�|�|d���|�|d���|�|d���|�|d��d	�|�|d
��d	�dS)Nrfrcrjr�rirlrk�fileA�F�fileA)rYrOr��is_filer�rrtrir�rrr�test_is_file�s
z_BasePathTest.test_is_filecCs�|�t�}|�d�}|�|d���|�|d���|�|d���|�|dd���|�|���t��r�|�|d���|�|�d���d�|�|�d	���d�dS)
Nrrfrcrjr�riu/�Fz/)rYrOr�Zis_mountr�rrtri)rra�Rrrr�
test_is_mount�s

z_BasePathTest.test_is_mountcCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��r�|�|d���|�|d���|�|d���|�|d��d	�|�|d
��d	�t��r�|�|d��d	�|�|d��d	�dS)
Nrfrcrjr�rirlrkrWFrXulinkA�zlinkA)	rYrOr��
is_symlinkrrtr�rirYr�rrr�test_is_symlink�s
z_BasePathTest.test_is_symlinkcCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dS�Nrfrcrjr�rWFrX)rYrOr��is_fiforir�rrr�test_is_fifo_false�s
z _BasePathTest.test_is_fifo_false�mkfifozos.mkfifo() requiredc
Cs�|�td�}zt�t|��Wn0tk
rN}z|�d|�W5d}~XYnX|�|���|�	|�
��|�	|���|�|�td���d�|�|�td���d�dS)NZmyfifozos.mkfifo(): %su	myfifo�Fzmyfifo)
rYrOr�rbrgr'r�r�r`r��	is_socketrYri)rrar*rrr�test_is_fifo_true�s z_BasePathTest.test_is_fifo_truecCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dSr_)rYrOr�rcrir�rrr�test_is_socket_falses
z"_BasePathTest.test_is_socket_false�AF_UNIXzUnix sockets requiredc
Cs�|�td�}t�tjtj�}|�|j�z|�t|��WnJt	k
r�}z,t
|t�sbdt|�krt|�dt|��W5d}~XYnX|�
|���|�|���|�|���|�|�td���d�|�|�td���d�dS)NZmysockzAF_UNIX path too longzcannot bind Unix socket: u	mysock�Fzmysock)rYrO�socketrf�SOCK_STREAMrp�close�bindrgr��
isinstancer'r�r�rcr�r`rYri)rra�sockr*rrr�test_is_socket_true
s

�$z!_BasePathTest.test_is_socket_truecCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dSr_)rYrOr��is_block_devicerir�rrr�test_is_block_device_falses
z(_BasePathTest.test_is_block_device_falsecCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dSr_)rYrOr��is_char_devicerir�rrr�test_is_char_device_false$s
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)	rYr�r�r�rpr�rnrYrir�rrr�test_is_char_device_true-s

z&_BasePathTest.test_is_char_device_truecCsP|�td�}tdtjd�D].}t�||�}t�|�}|�|��|���qdS)Nrfrr�)	rYrOr�r�r�r�r�rr�)rr[r�r�rtrrrr�8s

z"_BasePathTest.test_pickling_commoncCsJ|j}|d�}|d�}|�|jd|jd�|�|jd|jd�dS)Nz/usr/bin/fooz/usr/local/binr�r�r�)rYrirhr,rrr�test_parts_interning?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�W5t�|�XdS)NZlink0Zlink1Zlink2Zlink3)rYrOrvr�rMrNr�rr�rgr��chdir)rZlink0_targetrar[Zold_pathrrr�_check_complex_symlinksHsB

z%_BasePathTest._check_complex_symlinkscCs|�t�dSrd)rurOrorrr�test_complex_symlinks_absoluteqsz,_BasePathTest.test_complex_symlinks_absolutecCs|�d�dS)Nr#)rurorrr�test_complex_symlinks_relativeusz,_BasePathTest.test_complex_symlinks_relativecCs|�tj�dd��dS)Nrcr�)rur�rMrNrorrr�&test_complex_symlinks_relative_dot_dotysz4_BasePathTest.test_complex_symlinks_relative_dot_dotN)T)Zr+r,r-�__doc__r\r�r�rvr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�skip_unless_symlinkr�r�r�r�r�r�r�r�r�r�r�r�rrrrrr�unittest�
skipUnlessrrYrr[rr r"�hasattrr+�skipIfr-r/r0r7r8r;r>rBrDrE�only_ntrFrHrIrSrUrVrZ�
only_posixr\r^rardrergrmrorqrrr�rsrurvrwrxrrrrr]�s�


	




$

;

	















	
	
			)

r]c@s*eZdZejZdd�Zdd�Zdd�ZdS)�PathTestcCs0|�d�}|�t|�tjdkr$tjntj�dSrF)rYrirjr�r�rBr\rTrZrrrrH�s

�zPathTest.test_concrete_classcCs,tjdkr|�ttj�n|�ttj�dS)NrG)r�r�r�rWrBrTr\rorrr�test_unsupported_flavour�s
z!PathTest.test_unsupported_flavourc	Cs2|��}|�td��t|�d��W5QRXdS)NzUnacceptable patternr)rYZassertRaisesRegexr�r�r�rZrrr�test_glob_empty_pattern�sz PathTest.test_glob_empty_patternN)	r+r,r-rB�PathrYrHr�r�rrrrr�~sr�c@s�eZdZejZdd�dd�Zdd�Zdd�Zd	d
�Z	e
jdd��Zd
d�Z
dd�Ze�eed�d�dd��Ze�ejdkd�dd��ZdS)�
PosixPathTestTr�c	Gs2|j|�}|�t��t|�|��W5QRXdSrd)rYr��RuntimeError�printr�)rr�rkrMrrr�_check_symlink_loop�s
z!PosixPathTest._check_symlink_loopc	Cs�t�d�}|�tj|�|�t�}|d�d��W5QRXt�td��}|�t�	|j
�d�t�d�|d�d��W5QRXt�td��}|�t�	|j
�d�dS)Nr�new_filerg���other_new_file�)r��umaskrprYrOrrr�rNrr=r	�rZold_maskr[r
rrr�test_open_mode�s




zPosixPathTest.test_open_modec	CsFt��}z,t�d�|�d�}|�t|���d�W5t�|�XdS)Nrr�z/spam)r�r�rtrYrrgr�)rZcurrent_directoryr[rrr�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�r�r�r�Zmasked_new_filei�)r
)r�r�rprYrOr�r�rNrr=r	r�rrr�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�Fr�zlinkU/insideZlinkUZlinkVzlinkW/../linkWZlinkW)r�rurNr�rOrorrr�test_resolve_loop�szPosixPathTest.test_resolve_loopcCsX|j}|t�}t|�d��}t�t�s,t�n|}|�||�|�t|�d��t��dS)N�FILEazFILEa*)rYrOr�r�r�fs_is_case_insensitiver�rrar[r�r�rrr�	test_glob�szPosixPathTest.test_globcCsZ|j}|td�}t|�d��}t�t�s.t�n|}|�||�|�t|�d��t��dS)Nre�FILEdzFILEd*)rYrOr�r�rr�rr�rrr�
test_rglob�s
zPosixPathTest.test_rglob�getpwallz%pwd module does not expose getpwall()c	Cs|j}t�d�ddl}|�t���}|j}|j�	d�p:d}|�
�D]&}|j}|j�	d�}||krD|rDqtqD|}|}|d�}|d|d�}	|d|d�}
|d|d�}|d|d�}|d	�}
|d
�}t����"}|�dd�|�
|��||�d�|�
|	��||�d�|�
|
��||�d�|�
|��|�|�
|��|�|�
|
��|
�|�t|j�d
|d<|�
|��|d��|�
|	��||�d�|�
|
��||�d�|�
|��|�|�
|��|�|�
|
��|
�|�t|j�W5QRXdS)Nrrrz~/Documentsr�z
/Documentsr�r�rz~fakeuser/Documentsr�Z	Documentsz/tmpz/tmp/Documents)rYr�
import_modulerrr��getuidr�pw_dir�rstripr�r�rKrr�r�r�)rrarZpwdentZusername�userhomeZ	othernameZ	otherhome�p1�p2�p3�p4�p5�p6Zp7r�rrr�test_expanduser�sJ
zPosixPathTest.test_expanduser�darwinz1Bad file descriptor in /dev/fd affects only macOSc
Cs�zxtt�d��d��dd�}|s,|�d�|D]D}|��|��|��|��|�	�|�
�|��|��q0Wn:t
k
r�}z|jtjkr�|�d��W5d}~XYnXdS)Nz/dev/fdr�r�z.no file descriptors - issue was not reproducedz Bad file descriptor not handled.)r�rBr�r�r�r�r9rYr]rnrpr`rcr�r��EBADFZfail)rZfile_descriptorsrr*rrr�test_handling_bad_descriptor	s"

z*PosixPathTest.test_handling_bad_descriptorN)r+r,r-rBrTrYr�r�r�r�rrzr�r�r�r{r|r}rr�r~�sys�platformr�rrrrr��s"	
�
-�r�c@s*eZdZejZdd�Zdd�Zdd�ZdS)�WindowsPathTestcCs�|j}|t�}|�t|�d��|td�h�|�t|�d��|td�h�|�ttt|�d���|�d�h�|�ttt|�d���|�d�h�dS)Nr�rfzF*az\FILEaz\fileA)rYrOrr�r��maprgr`rrrr�1	s$zWindowsPathTest.test_globcCsV|j}|td�}|�t|�d��|td�h�|�ttt|�d���|�d�h�dS)Nrer�r�z\dirD\FILEd)rYrOrr�r�r�rgr`rrrr�9	s
zWindowsPathTest.test_rglobc
sV�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<|�W5QRXdS)Nr�r�ZHOMEPATHZ	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)rKrr�r�rr�	rar�r�r�r�r�r�r�rrrr)V	s
�
�
�z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alicezC:\Users\eve)rYrr�rKr�r�r�rr6rr�rr�?	s>zWindowsPathTest.test_expanduserN)	r+r,r-rBr\rYr�r�r�rrrrr�-	sr�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
||_dSrd)�string)rr�rrr�__init__�	sz&CompatiblePathTest.CompatPath.__init__cCst|�|j�d|���Srw�rjr��rr�rrr�__truediv__�	sz)CompatiblePathTest.CompatPath.__truediv__cCst|�|�d|j���Srwr�r�rrr�__rtruediv__�	sz*CompatiblePathTest.CompatPath.__rtruediv__N)r+r,r-ryr�r�r�rrrr�
CompatPath{	sr�c	CsXt�d�|�d�}|�||j�|�|jd�|�t��t�d�dW5QRXdS)N�test�rightz
test/rightr1)rBrLr�r_rr�r�r��r�resultrrr�test_truediv�	s
zCompatiblePathTest.test_truedivc	CsX|�d�t�d�}|�||j�|�|jd�|�t��dt�d�W5QRXdS)N�leftr�z	left/testr1)r�rBrLr_rr�r�r�r�rrr�
test_rtruediv�	s
z CompatiblePathTest.test_rtruedivN)r+r,r-ryr�r�r�rrrrr�u	s	r��__main__)0�collections.abcr�r�r�r�r�rBr�rgr�r�r{rr�rZtest.supportrrrr�ImportError�objectrZTestCaser.rCrRr�rrErM�realpathrOrNr(r~r�rr�rSrUr]r�r�r�r�r+�mainrrrr�<module>sx)$BWL8��OG)


F1le Man4ger