Your IP : 216.73.217.129


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_pathlib.cpython-39.opt-1.pyc

a

XC?h��@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZddl
mZddlmZmZzddlZddlZWney�dZZYn0Gdd�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��6/opt/alt/python39/lib64/python3.9/test/test_pathlib.py�
<listcomp>�z7_BaseFlavourTest._check_parse_parts.<locals>.<listcomp>csg|]}|�d���qSrr	r)�altseprrr r)�flavourZparse_partsrr�assertEqual)�self�arg�expected�fZactualr)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/)rzb/c�d)rr�cr!)rzb//cr!)rzb/c/r!�.)r#r#r)rr#r)rr#r#�/a/b�/a�/a/�r�/br"r")rr(�/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}|ddgddgd�f�|ddgddgd�f�|d	dgddgd�f�|d
gddd
gf�|dgdddgf�|dgdddgf�dS)
N�//arr�//)r1rr�///ar)rrrz////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 r0)rr1rr2�///a/b�c:/a/b)rrr=�\/a/b)rrr>�\a\b)rrr?�rZ	splitrootr�rrrrr�test_splitrootOszPosixFlavourTest.test_splitrootN)r,r-r.�pathlibZ_posix_flavourrr8rBrrrrr/@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�|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:\rr3r�c:/ar%�//a/b�\\a\b�\\a\b\�//a/b/�//a/b/cr")rzZ:br"�Z:)rOrr")rzZ:/br")�Z:\rr")rz//b/cr!z\\b\cz\\b\c\r!)rz	Z://b//c/�d/)rPrr"r!)rz//b/c//r!z//?/c:/z\\?\c:z\\?\c:\z//?/c:/ar(rz//?/UNC/b/cz\\?\UNC\b\cz\\?\UNC\b\c\z
//?/UNC/b/c/dr')rGrr")zZ:/ar(r")z//?/Z:/ar(r"z\\?\Z:)z\\?\Z:\rr"r6r7rrrr8gs.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)Nrr9rr:�a\b)rrrRr5)rrGrr?)rrGrRzc:a\b)rErrRzc:\a\b)rErGrRz\\az\\\a/b)rrGrzc:\\a)rErGrzc:\\\a/b)rErGrrK)rKrGrrL�	\\a\b\c\d)rKrG�c\dz\\\a\br@rArrrrB�s"zNTFlavourTest.test_splitrootN)r,r-r.rCZ_windows_flavourrr8rBrrrrrDds"rDc@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)
�rr)rr)r�b/)rrW)r )za//b)za//b//)rrr)rrr)rrr))r�/b/cr!)rz///b//crQ)r%rXr!)rrr�c/d)rrzb/c/d)r�/b/c/d)rrZcCs*|�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)r\�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�srfc3s|]}�|�VqdS�Nrr�rfrr�	<genexpr>�rz8_BasePurePathTest._check_str_subclass.<locals>.<genexpr>)�strr\r�parts�assertIs�type)r�argsrdr^�partrrhr�_check_str_subclass�s
z%_BasePurePathTest._check_str_subclasscCs6|�d�|�d�|�d�|�d�|�d�dS)Nrr#rza/b.txtz/a/b.txt�rp�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))r\�joinpathrrlrm�rrdr^�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`rYrtr!zc/a/b/dr))r\rrlrmrvrrr�test_div_common�sz!_BasePurePathTest.test_div_commoncCs(|j|�}|�t|�|�d|j��dS�Nr)r\rrjr
r)rrrnr^rrr�
_check_str�s
z_BasePurePathTest._check_strcCs(dD]}|�||f�q|�dd�dS)N�rrr`rr$rar#)r)r{)r�pathstrrrr�test_str_commonsz!_BasePurePathTest.test_str_commoncCs(|j}dD]}|�||���|�q
dS)Nr|)r\r�as_posix)rrdr}rrr�test_as_posix_commonsz&_BasePurePathTest.test_as_posix_commoncCs2t�|j�}|j}|�t|d��d|d�dS)Nr�a�b)�os�fsencoderr\r�bytes)rrrdrrr�test_as_bytes_commonsz&_BasePurePathTest.test_as_bytes_commoncCst|j}|�t��|d���Wd�n1s20Y|�t��|���Wd�n1sf0YdSr[)r\�assertRaises�
ValueError�as_uri�rrdrrr�test_as_uri_commons
*z$_BasePurePathTest.test_as_uri_commoncCs�dD]�}|�|�}|jj}t|�}|�|�|d�|�|�|�d�|�|t|�dd�}|�t	|�|�
��t	|tj�}|�
|j|j�|�||�|�t|�|�qdS)Nr|�(�)����)r\�	__class__r,�repr�
assertTrue�
startswith�endswith�lenr�evalrrC�__dict__rl)rr}r^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)r\r�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)r\r�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�n1s�0YdS)Ncs��||���||�dSrg)�
assertLessZ
assertGreaterrVrrrrr�bsz:_BasePurePathTest.test_ordering_common.<locals>.assertLessrr�abcrr%r$z/abcr()r\r��	TypeError)rr�rdrrr"r!rrrr�test_ordering_common`s.









z&_BasePurePathTest.test_ordering_commoncCsX|j}|j}|d�}|j}|�|d�|�||j�|d�}|j}|�||ddf�dS)NrrVr$rr)rr\rkrrl)rrrdr^rkrrr�test_parts_common|sz#_BasePurePathTest.test_parts_commoncCs4|j}|d�}|�|��d�|�t�|�d�dS)Nr)r)r\r{�
__fspath__r��fspathrcrrr�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rorrrrri�rzA_BasePurePathTest.test_equivalences.<locals>.<listcomp>.<genexpr>)�tuple)r�trrrrr�s�z7_BasePurePathTest.test_equivalences.<locals>.<listcomp>zfailed with args {})�equivalences�itemsr
r�appendr\r�format�hashrjr)r�kZtuplesZcanon�posixZpcanonr�r^rrrr�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`rrrar$r%r�r\r�parentrcrrr�test_parent_common�sz$_BasePurePathTest.test_parent_commoncCs�|j}|d�}|j}|�t|�d�|�|d|d��|�|d|d��|�|d|d��|�t|�|d�|d�|d�g�|�t��|d	Wd�n1s�0Y|�t��|dWd�n1s�0Y|�t��||d<Wd�n1�s0Y|d
�}|j}|�t|�d�|�|d|d��|�|d|d��|�|d|d
��|�t|�|d�|d�|d
�g�|�t��|dWd�n1�s�0YdS)Nr`�rrr�r�r#r�rar$r%r)r\�parentsrr��listr��
IndexErrorr��rrdr^Zparrrr�test_parents_common�s."&&("z%_BasePurePathTest.test_parents_commoncCs@|j}|�|d�jd�|�|d�jd�|�|d�jd�dS)Nrrr$�r\rZdriver�rrr�test_drive_common�sz#_BasePurePathTest.test_drive_commoncCsX|j}|j}|�|d�jd�|�|d�jd�|�|d�j|�|�|d�j|�dS�Nrrrr$)r\rr�root�rrdrrrr�test_root_common�sz"_BasePurePathTest.test_root_commoncCsX|j}|j}|�|d�jd�|�|d�jd�|�|d�j|�|�|d�j|�dSr�)r\rr�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��r\r�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.�r\r�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��r\r�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.�r\rZstemr�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��
a/Dot ending.�/a/Dot ending.rr#rr)�c/rY�r\rZ	with_namer�r�r�rrr�test_with_name_common"sz'_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)Nrr!za/dr$z/a/dr�za/d.pyr�z/a/d.pyr�z/a/d.gzr�r�rr#rr)r�rY�r\rZ	with_stemr�r�r�rrr�test_with_stem_common2sz'_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)Nrr�za/b.gzr$z/a/b.gzr�r�rr#r�gz�/.gzrYz.c/.dz./.dz.d/.r!)r\r�with_suffixr�r�rrr�rrr�test_with_suffix_commonCs*
�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`�a/cr%r$rr&r)ra�/a/c)r\r�r��relative_torr�rcrrr�test_relative_to_common\s<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)Nrr�rrrrr"r`r�r%r$rr&r)rar�)r\r�r��is_relative_tor�r�rcrrr�test_is_relative_to_commons:z,_BasePurePathTest.test_is_relative_to_commoncCs�|j}|d�}tdtjd�D]^}t�||�}t�|�}|�|j|j�|�||�|�t	|�t	|��|�t
|�t
|��qdS)Nr$rr�)r\�range�pickle�HIGHEST_PROTOCOL�dumps�loadsrlr�rr�rj)rrdr^�proto�dumpedrwrrr�test_pickling_common�s
z&_BasePurePathTest.test_pickling_commonN)%r,r-r.r�r_rerprsrxryr{r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrU�sH�

&#"rUc@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<rJr1�r\rr�r�rrr�	test_root�szPurePosixPathTest.test_rootcCsF|j}|�|d�|d��|�|d�|d��|�|d�|d��dS)Nr�A/br%r2r0)r\r�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)r\rr�r�rrr�test_as_uri�szPurePosixPathTest.test_as_uricCsdddlm}|j}zt�d�Wnty<|�d�Yn0|�|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.parserr\r�r��UnicodeEncodeError�skipTestrr�)rrrdrrr�test_as_uri_non_ascii�s�z'PurePosixPathTest.test_as_uri_non_asciicCs|j}|�|d��d��dS)NzA.pyza.PY)r\r�r�r�rrr�
test_match�szPurePosixPathTest.test_matchcCs�|j}|�|����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����dS)Nrr rr%r;r0rJ�r\r��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�r\rlZis_reservedr�rrr�test_is_reserved�s
z"PurePosixPathTest.test_is_reservedcCsh|j}|d�}|�d�}|�||d��|d��d�}|�||d��|d��d�}|�||d��dS�Nr0rrJr%z//cr)�r\rurrvrrr�	test_join�s
zPurePosixPathTest.test_joincCsb|j}|d�}|d}|�||d��|d�d}|�||d��|d�d}|�||d��dSr�r\rrvrrr�test_div�szPurePosixPathTest.test_divN)r,r-r.rC�
PurePosixPathr\rrrrr
rrrrrrrrr�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))rEr)rEr)rrEr))rFr)rErr)rEr%)z/zrFr)z//x/yrFr)rJ)rJr")rMr")r3rIrMrNcCs�|�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\crJrLrNz\\a\b\c�	//a/b/c/drS)r\rrjr]rrr�test_str	s




zPureWindowsPathTest.test_strcCs^|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d�|�d	�dS)
NrEr3z	c:a\b.txtrHr4z
c:\a\b.txtz\\some\sharez\\some\share\az\\some\share\a\b.txtrqrrrrr�test_str_subclasss







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/brErrzd:a/br=r$za/Br�C:a/B�c:A/b�//Some/SHARE/a/Bz//somE/share/A/b)r\rr�r�rrrr szPureWindowsPathTest.test_eqcCs|j}|�t��|d���Wd�n1s20Y|�t��|d���Wd�n1sh0Y|�|d���d�|�|d���d�|�|d���d�|�|d	���d
�|�|d���d�|�|d
���d�|�|d���d�dS)Nr$rrFzfile:///c:/zc:/a/b.czfile:///c:/a/b.cz	c:/a/b%#czfile:///c:/a/b%25%23cuc:/a/bézfile:///c:/a/b%C3%A9z
//some/share/zfile://some/share/z//some/share/a/b.czfile://some/share/a/b.cu//some/share/a/b%#céz"file://some/share/a/b%25%23c%C3%A9)r\r�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)r\r�r�r�r�rrrr�<s&z%PureWindowsPathTest.test_match_commoncs��fdd�}�j}|d�}|d�}|||���||k���||k�|d�}|d�}|||���||k���||k�dS)Ncs��||���||�dSrg)ZassertLessEqual�assertGreaterEqualrVrrrr�assertOrderedEqualVszDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualr rz//some/Share/A/br!)r\r�)rr#rdr^r�rrrrr�Ts

z(PureWindowsPathTest.test_ordering_commoncCsX|j}|d�}|j}|�|d�|d�}|j}|�|d�|d�}|j}|�|d�dS)Nr)rErrr=)rHrrr)rLr"r!)r\rkr)rrdr^rkrrr�
test_partses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:/rrNrJr�rcrrr�test_parentqszPureWindowsPathTest.test_parentcCs�|j}|d�}|j}|�t|�d�|�|d|d��|�|d|d��|�t|�|d�|d�g�|�t��|dWd�n1s�0Y|d�}|j}|�t|�d�|�|d|d��|�|d|d	��|�t|�|d�|d	�g�|�t��|dWd�n1�s&0Y|d
�}|j}|�t|�d�|�|d|d��|�|d|d��|�t|�|d�|d�g�|�t��|dWd�n1�s�0YdS)
Nzz:a/b/r�rr%r�r&zz:/a/b/r'r(rrNrJ)r\r�rr�r�r�r�r�rrr�test_parents�s2&(z PureWindowsPathTest.test_parentscCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�dS)	NrErrF�c:/a/b/rJrKrMrr�r�rrr�
test_drive�szPureWindowsPathTest.test_drivecCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrErrrFrGr+rJrMrrr�rrrr�szPureWindowsPathTest.test_rootcCs�|j}|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d�jd�|�|d	�jd�dS)
NrErrFrHr+rJrLrMr)r\rr�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)NrErrFrrr=�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)NrErrFrr=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.r0r1r�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)NrErFrr=r.r�r/r3r4r5r�r6r7r�r�r8r0r1r9r: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)NrErzc:.zc:..r�rFrrr.r3r�r5r�r7r�r9r�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.xml�c:a/Dot ending.�c:/a/Dot ending.rErF�
//My/Share�d:�d:e�d:/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
�dS)Nrr!zc:a/dr=zc:/a/dr>r?rErFr@rArBrCr�r�rrr�test_with_stem
sz"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)Nrr�zc:a/b.gzr=z	c:/a/b.gzr.r/rr#rr@r�rGrEr�z\.gzzc:.gzrYrTz.c/dz.c\d)r\rr�r�r�r�rrr�test_with_suffixs(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/BarrEzFoo/Bar�c:foOZBar�c:foO/�	c:foO/baRrrAr�Foo�/Foo�C:/Foo�
C:Foo/Bar/Baz�	C:Foo/Baz�
C:/Foo/Barz/Foo/Barz\Foo\BarrF�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)r\rr�r�r�rjrcrrr�test_relative_to0shz$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)#NrGrErHrIrJrrArrKrLrMrNrOrPrFrQrRrSrTrUrVrWrXrYrZr[r\r]r^r_r`rarbrc)r\r�r�r�rcrrr�test_is_relative_tojs^z'PureWindowsPathTest.test_is_relative_tocCs(|j}|�|����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d����|�|d	����|�|d
����|�|d����|�|d����|�|d
����|�|d����|�|d����dS)Nrr rr%r;rEr3zc:a/b/rFrIr+rJrMrNrrr�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/yrrvrrrr�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)Nrfrgrhr
�yrirjz/xrkzD:rlrmrnrorrcrrrr�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)NFrrrz//my/share/nul/con/auxTZnulZauxZprnZconzconin$zconout$ZCOM1ZLPT9ucom¹ucom²ulpt³zNUL.txtzPRN  z	AUX  .txtzCOM1:barzLPT9   :barzbar.com9zbar.lpt9zc:/baz/con/NULzc:/NUL/con/bazrr�rrrr�s2z$PureWindowsPathTest.test_is_reservedN)#r,r-r.rC�PureWindowsPathr\rUr��copy�updaterrrrr�r�r$r)r*r,rr-r2r;r<r=rDrErFrdrerrrrrrrrr�sD
��


:5rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�PurePathTestcCs0|�d�}|�t|�tjdkr$tjntj�dS�Nr�nt)r\rlrmr�r�rCrqrr]rrr�test_concrete_classs

�z PurePathTest.test_concrete_classcCs$t�d�}t�d�}|�||�dSr[)rCrrqr��rr^r�rrr�test_different_flavours_unequal	s

z,PurePathTest.test_different_flavours_unequalcCs�t�d�}t�d�}|�t��||kWd�n1s<0Y|�t��||kWd�n1sn0Y|�t��||kWd�n1s�0Y|�t��||kWd�n1s�0YdSr[)rCrrqr�r�rxrrr�!test_different_flavours_unordereds

&&&z.PurePathTest.test_different_flavours_unorderedN)	r,r-r.rC�PurePathr\rwryrzrrrrrtsrtcGstjjtg|�R�Srg)r��path�join�BASE�r
rrr�<lambda>!rr�cGstjjtg|�R�Srg)r�r|r}rrrrrr�"rrvz)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc@seZdZejZdS)�PosixPathAsPureTestN)r,r-r.rC�	PosixPathr\rrrrr�)sr�c@s"eZdZejZdd�Zdd�ZdS)�WindowsPathAsPureTestcCs@|j}|�t��|d���Wd�n1s20YdS�NrF)r\r��NotImplementedError�ownerr�rrr�
test_owner1sz WindowsPathAsPureTest.test_ownercCs@|j}|�t��|d���Wd�n1s20YdSr�)r\r�r��groupr�rrr�
test_group6sz WindowsPathAsPureTest.test_groupN)r,r-r.rC�WindowsPathr\r�r�rrrrr�-sr�c@seZdZdZdd�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]�Z9ejd^d_��Z:d`da�Z;dbdc�Z<ddde�Z=dfdg�Z>dhdi�Z?djdk�Z@dldm�ZAeBdndo��ZCdpdq�ZDdrds�ZEdtdu�ZFejdvdw��ZGdxdy�ZHdzd{�ZIeJd|d}��ZKd~d�ZLd�d��ZMe+�,e4ed��d��d�d���ZNd�d��ZOe+�,e4ePd��d��d�d���ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWejd�d���ZXejd�d���ZYejd�d���ZZd�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�n1s�0Yttdd�d	��}|�d�Wd�n1s�0Yttdd
�d	��}|�d�Wd�n1�s0Yttddd�d	��}|�d�Wd�n1�sF0Yt�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��chmodr}r�rmtreer~rrrr�cleanupSsz$_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�rrrrr_Rs0

((**
z_BasePathTest.setUprvcCstj||dd�dS)NT�Ztarget_is_directory�r�r��r�src�destrrrr�ssz_BasePathTest.dirlinkcCst�||�dSrgr�r�rrrr�vscCs*|�tj�t|�t|��d||f�dS)Nz&%r and %r don't point to the same file)r�r�r|�samefilerj�rZpath_aZpath_brrr�
assertSameys
��z_BasePathTest.assertSamecOsN|�t��}||i|��Wd�n1s.0Y|�|jjtj�dSrg)r��FileNotFoundErrorr�	exception�errno�ENOENT)r�funcrn�kwargs�cmrrr�assertFileNotFound~s,z _BasePathTest.assertFileNotFoundcCs |�tj�|�tj�|��dSrg)rr�r|�normcaser�rrr�assertEqualNormCase�sz!_BasePathTest.assertEqualNormCasecCsT|�t���}|�||�|�t|�t|��|�t|�t|��|�|�	��dSrg)
r\r��getcwdrr�rjrlrmr�rrxrrr�	_test_cwd�s
z_BasePathTest._test_cwdcCs|j��}|�|�dSrg)r\�cwdr�r]rrr�test_cwd�s
z_BasePathTest.test_cwdcCsX|�tj�d��}|�||�|�t|�t|��|�t|�t|��|�	|�
��dS)N�~)r\r�r|�
expanduserrr�rjrlrmr�rrxrrr�
_test_home�s
z_BasePathTest._test_homecCs�t���l}|�|j���|��tj�t	d�|d<|�|j���tj�t	d�|d<|�|j���Wd�n1sz0YdS)NZuserprofile�USERPROFILE�home�HOME)
r�EnvironmentVarGuardr�r\r��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~r\r�r�r�r�r�)rZ
fileA_pathZ
fileB_pathr^rwr�Znon_existentr�rrr�
test_samefile�s"



z_BasePathTest.test_samefilecCs$|�d�}|�|��t�d��dS)Nrr#)r\r�statr�r]rrr�test_empty_path�s
z_BasePathTest.test_empty_pathcCs�|j}|d�}|�|��|tj�d���|d�}|�|��|�|d�}|�|��|�|d�}|�|��|�||d���j�d}|�|��|�dS)Nr�r��/~�../~r)r\rr�r�r|�absoluter�rcrrr�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��)r\r~rl�existsrr�rcrrr�test_exists�sz_BasePathTest.test_existscCs�|�t�}|d�d��.}|�|tj�|�|��d�Wd�n1sL0Y|d�d��2}|�|tj�|�|���	�d�Wd�n1s�0Y|djddd��2}|�|tj
�|�|���	�d�Wd�n1s�0YdS)Nr�r�zthis is file A
�rb�this is file Ar)�	buffering)r\r~r�rb�io�
TextIOBaser�read�BufferedIOBase�strip�	RawIOBase)rr^rrrr�test_open_common�s
.2z_BasePathTest.test_open_commoncCsX|�t�}|d�d�|�|d��d�|�t|djd�|�|d��d�dS)Nr�sabcdefgZsomestr)r\r~Zwrite_bytesr�
read_bytesr�r�r]rrr�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)r\r~Z
write_textr�	read_textr�r�r]rrr�test_read_write_text�s
��z"_BasePathTest.test_read_write_textcsX|j��t�}|��}t|�}gd�}t��r:|gd�7}|�|�fdd�|D��dS)N)r�r�r�r�r�)r�r�r�r�csh|]}�t|��qSr�r~�rr��rdrr�	<setcomp>rz-_BasePathTest.test_iterdir.<locals>.<setcomp>)r\r~�iterdir�setrr�r)rr^�it�pathsrrr�r�test_iterdir�sz_BasePathTest.test_iterdircs>|j��td�}t|���}�fdd�dD�}|�||�dS)Nr�csh|]}�td|��qS)r�r�r�r�rrr�rz5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>)r�r�)r\r~r�r�r)rr^r�rrr�r�test_iterdir_symlinks

z"_BasePathTest.test_iterdir_symlinkcCsb|�td�}|�t��}t|���Wd�n1s80Y|�|jjtj	tj
tjf�dS�Nr�)r\r~r��OSError�nextr��assertInr�r�ZENOTDIRr�ZEINVAL�rr^r�rrr�test_iterdir_nodirs*�z _BasePathTest.test_iterdir_nodircs���fdd�}�j��t�}|�d�}��|tjj�||dg�||�d�g�||�d�ddg�t��s�||�d�d	dg�n||�d�gd
��t��s�||�d�dg�n||�d�gd��t��s�||�d
�dg�n||�d
�ddg�dS)Ncs"��t|��fdd�|D��dS)Ncsh|]}�t|��qSrr�r�r�rrr�rzA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>�rr���globr�rdrrr�_checksz._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�)	r\r~r�rb�collectionsr��Iteratorrr��rr�r^r�rr�r�test_glob_commons"
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)Ncs"��t|��fdd�|D��dS)Ncsh|]}�t|��qSrr�r�r�rrr�/rzB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>r�r�r�rrr�.sz/_BasePathTest.test_rglob_common.<locals>._checkr�r�r�z*/fileAr�)r�zdirB/linkD/fileBr�zdirA/linkC/fileBzfile*)r�r�r��dirC/dirD/fileDr�r�rz*/*)	r\r~�rglobrbr�r�r�rr�r�rr�r�test_rglob_common-s

z_BasePathTest.test_rglob_commoncsB|j}|t��t��d��}hd�}|�|�fdd�|D��dS)N�*>r�r�r�r�z
dirA/linkCr�r�z	dirC/dirDr�r�r�r�rr�r�csh|]}�|�qSrrr�r^rrr�Rrz8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)r\r~r�rr)rrd�given�expectrrr�test_rglob_symlink_loopBs

z%_BasePathTest.test_rglob_symlink_loopcs�d}|j}|t�d�|�gdg|�R�}|jdd�d�dg|����fdd	�td
�D�}|D]}|�t|�|�qd�fdd	�td
�D�}�}t|�D]&}|d}|D]}|�t|�|�q�q�dS)N�Zdeepr!T�r�rrcsg|]}�����qSr)r��r�j��base�patternrrr[rz;_BasePathTest.test_glob_many_open_files.<locals>.<listcomp>�dcsg|]}��d��qS)r!)rr
)r
rrr^r)r\r~r�r}r�rr�)rZdepthrdr^Zitersr��irrr�test_glob_many_open_filesTs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)r\r~rr�r�rcrrr�test_glob_dotdotes
z_BasePathTest.test_glob_dotdotcCsl|j}|t�d}|��|d}|��|d}|��|d}|d}|�|d�t�d��:}tt�	|��|_
|�tt
|�d���d	�Wd�n1s�0Y|��t�d��:}tt�	|��|_
|�tt
|�d���d
�Wd�n1s�0Y|�d�t�d��:}tt�	|��|_
|�tt
|�d���d
�Wd�n1�s^0YdS)NZpermissions�file1�file2�subdir�file3�otherz
os.scandirrr��r)r\r~r��touch�
symlink_tor�patch�sortedr��scandirZreturn_valuerr�r�r�r�)rrdr
rrrrrrrr�test_glob_permissionsms*88
z#_BasePathTest.test_glob_permissionsTcCs|�|�}|�||�dSrg)�resolver)rr^r�strictr�rrr�_check_resolve�s
z_BasePathTest._check_resolvec
Cs�|j}|td�}|�t��}|jdd�Wd�n1s<0Y|�|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�r�r�r�r�r�r�r�rvz-dirD)r��dir�linkX�linkY)r\r~r�r�rrr�r�r�r�rjr�r|r}�abspath�_check_resolve_relativer�rZ	_longpath�tempfileZmkdtempr�r�r�r��_check_resolve_absolute)rrdr^r�r!rrr�test_resolve_common�sh
*���
�����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)
r\r~r�r}r�r|rrr�r�)rr^r�r�rrr�test_resolve_dot�s
z_BasePathTest.test_resolve_dotcCs�|�t�}|��}|��}t|�|�Wd�n1s<0Yt|�t|�|��|��|��|�Wd�n1s�0YdSrg)r\r~r�r�r�rr�)rr^r�Zit2rrr�	test_with�s
z_BasePathTest.test_withcCsd|�t�d}|��j}|d@}|�|�|�|��j|�|dB}|�|�|�|��j|�dS)Nr�im����)r\r~r��st_moder�r)rr^�modeZnew_moderrr�
test_chmod�s


z_BasePathTest.test_chmodcCsZ|�t�d}|��}|�|��|�|�|jdA�|�|j|j�|�|��|�dS)Nr�r4)r\r~r�rr�r5r�r��rr^�strrr�	test_statsz_BasePathTest.test_statcCs*|�t�d}|��}|�||���dS)Nr�)r\r~r�r��lstatr8rrr�
test_lstatsz_BasePathTest.test_lstatcCs*|�t�d}|��}|�||���dSr�)r\r~r�rr;r8rrr�test_lstat_nosymlinksz"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testcCs^|�t�d}|��j}zt�|�j}Wn tyH|�d|�Yn0|�	||�
��dS)Nr�z4user %d doesn't have an entry in the system database)r\r~r��st_uid�pwd�getpwuid�pw_name�KeyErrorrrr�)rr^Zuidr�rrrr�s
�
z_BasePathTest.test_ownerz&the grp module is needed for this testcCs^|�t�d}|��j}zt�|�j}Wn tyH|�d|�Yn0|�	||�
��dS)Nr�z5group %d doesn't have an entry in the system database)r\r~r��st_gid�grpZgetgrgidZgr_namerBrrr�)rr^�gidr�rrrr�!s
�
z_BasePathTest.test_groupcCs2|�t�d}|��|�|j�|�|j�dSr�)r\r~�unlinkr�r�r]rrr�test_unlink,sz_BasePathTest.test_unlinkcCs*|�t�d}|�|j�|jdd�dS)N�fileAAAT)Z
missing_ok)r\r~r�rFr]rrr�test_unlink_missing_ok2sz$_BasePathTest.test_unlink_missing_okcCsH|�t�d}|��D]}|��q|��|�|j�|�|j�dS)Nr�)r\r~r�rF�rmdirr�r�rxrrr�
test_rmdir7s
z_BasePathTest.test_rmdir�linkzos.link() is not presentc
Cs�|�t�}|d}|��j}|dd}z|�|�Wn2tyh}z|�d|�WYd}~n
d}~00|�|��j|�|�tj	�
||�d�|�|j�td�}|�|�|�t�|�j|�|�|j�dS)Nr�r��fileAAz
os.link(): %sTrH)
r\r~r��st_size�link_to�PermissionErrorrrr�r|r�r��rel_join)rrdr^�sizer��er�rrr�test_link_to?s

$
z_BasePathTest.test_link_tozos.link() is presentcCsV|�t�}|d}|dd}|�t��|�|�Wd�n1sH0YdS)Nr�r�rM)r\r~r�r�rO�rrdr^r�rrr�test_link_to_not_implementedSs

z*_BasePathTest.test_link_to_not_implementedcCs�|�t�}|d}|��j}|dd}|�|�}|�||�|�|��j|�|�|j�td�}|�|�}|�||�|��|�t�|�j|�|�|j�dS)Nr�r�rMrH)	r\r~r�rN�renamerr�rQr�)rrdr^rRr�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�rMr�r�)	r\r~r�rNr
rr�rQr�)rrdr^rRr�Z
replaced_pr�Z
replaced_qrrr�test_replacems




z_BasePathTest.test_replacecCs�|�t�}|�|d��|�d��|�|d��|�d��|�|d��|�d��|�t��|d��Wd�n1s�0YdS)Nr�r�r�r�r�r�)r\r~r�readlinkr�r�r�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)r6�exist_ok�r])r\r~r�r�rr�r��st_mtime�st_mtime_nsr��utimerjr"r�r�)rrdr^r9Z	old_mtimeZold_mtime_nsrrr�test_touch_common�s$
z_BasePathTest.test_touch_commoncCs\|�t�}|d}|��|�d��$}|�|����d�Wd�n1sN0YdS)Nr�r�r�)r\r~rr�rr�r�)rrdr^rrrr�test_touch_nochange�s

z!_BasePathTest.test_touch_nochangecCs�|�t�}|d}|�|���|��|�|���|�|���|�t��}|��Wd�n1sl0Y|�	|j
jtj�dS)NZnewdirA)
r\r~r�r�r�r��is_dirr�r�rr�r��EEXIST)rrdr^r�rrr�
test_mkdir�s
&z_BasePathTest.test_mkdircCs^|�tdd�}|�|���|�t��}|��Wd�n1sD0Y|�|jj	t	j
�|jdd�|�|���|�|���|�t��}|jdd�Wd�n1s�0Y|�|jj	t	j
�t�|��j�}|�tdd�}|jddd�|�|���|�|���tjdk�r@|�t�|��j�d	|@�|�t�|j��j�|�dS)
NZnewdirB�newdirCTr	ZnewdirDZnewdirEimrvim)r\r~r�r�r�r�r�rr�r�r�r�rdrer��S_IMODEr5r�r�r�)rr^r�r6rrr�test_mkdir_parents�s&&*z _BasePathTest.test_mkdir_parentscCs�|�td�}|��j}|�|���|�|���|�t��}|�	�Wd�n1sZ0Y|�
|jjtj
�|j	dd�|�|���|�
|��j|�dS)Nr�Tr^)r\r~r��st_ctimer�r�rdr��FileExistsErrorr�rr�r�re)rr^�st_ctime_firstr�rrr�test_mkdir_exist_ok�s
&z!_BasePathTest.test_mkdir_exist_okcCs|�td�}|�|���|�t��}|��Wd�n1sB0Y|�|jj	t	j
�|d}|jdd�|��j}|�|���|�t��}|jdd�Wd�n1s�0Y|�|jj	t	j
�|jddd�|�|���|�|��j|�dS)Nr�rgTr	�r�r])
r\r~r�r�r�rkr�rr�r�rer�rj)rr^r�rlrrr�test_mkdir_exist_ok_with_parent�s&
*z-_BasePathTest.test_mkdir_exist_ok_with_parentcCs2|�d���jdd�|�d���jddd�dS)NrTr^rn)r\rr�rrrrr�test_mkdir_exist_ok_root�sz&_BasePathTest.test_mkdir_exist_ok_rootcCspdD]}|�|d�}|��sq.q|�d�|�t��$|ddjdd�Wd�n1sb0YdS)NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't exist�childr|Tr	)r\rdrr�r�r�)rr!r^rrr�test_mkdir_with_unknown_drive�s
z+_BasePathTest.test_mkdir_with_unknown_drivecCs�|�tdd�}|�|���|�t��}|jdd�Wd�n1sH0Y|�|jj	t	j
�|�t��}|jddd�Wd�n1s�0Y|�|jj	t	j
�dS)Nr�r�Tr	rn�r\r~r�r�r�rkr�rr�r�rer�rrr�test_mkdir_with_child_file�s*,z(_BasePathTest.test_mkdir_with_child_filecCs�|�td�}|�|���|�t��}|��Wd�n1sB0Y|�|jj	t	j
�|�t��}|jdd�Wd�n1s�0Y|�|jj	t	j
�dS)Nr�Tr^rsr�rrr�test_mkdir_no_parents_files&*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�Wd�n1s�0YWn"t	y�|�
t|���Yn0|�t|���|�
|���qdS)N� zdirCPC%dr�cs6t|�}���r&t�||���|�t�||�dSrg)rj�popr�r��add)r|r6)�concurrently_createdrrr�my_mkdirs

zE_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.my_mkdircsg|]}t�d|>@��qS)r�)�bool)r�n)�pattern_numrrr!rzG_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.<listcomp>�Zdir1Zdir2zpathlib._normal_accessor.mkdirTFrn)r�)r�r\r~r�r�r�rrr�rkr�rjZassertNotInr�)rr^rzZp12r)ryrr}r�%test_mkdir_concurrent_parent_creations0z3_BasePathTest.test_mkdir_concurrent_parent_creationcCs|�t�}|d}|dd}|�|�|�|��|���|�|��|���|dd}|�t|��|�|��|���|�|��|���|�|�	��|d}|dd}|j|dd�|�|��|���|�|��|���|�
|�	��|�
t|����dS)	Nr�r�ZlinkAAZlinkAAAr�ZlinkAAAATr�)
r\r~rrr�r�r;rjr�rdr�r�r�)rrd�targetrLrrr�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)Nr�r�r�r�r�r�r�FudirA�zdirA)r\r~r�rdr�rr�rlr�rrr�test_is_dirEs
z_BasePathTest.test_is_dircCs�|�t�}|�|d���|�|d���|�|d���|�|dd���t��r�|�|d���|�|d���|�|d���|�|d��d	�|�|d
��d	�dS)Nr�r�r�r�r�r�r��fileA�F�fileA)r\r~r��is_filer�rr�rlr�rrr�test_is_fileRs
z_BasePathTest.test_is_filecCs�|�t�}|�d�}|�|d���|�|d���|�|d���|�|dd���|�|���t��r�|�|d���|�|�d���d�|�|�d	���d�dS)
Nrr�r�r�r�r�u/�Fz/)r\r~r�Zis_mountr�rr�rl)rrd�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)
Nr�r�r�r�r�r�r�r�Fr�ulinkA�zlinkA)	r\r~r��
is_symlinkrr�r�rlr�r�rrr�test_is_symlinkms
z_BasePathTest.test_is_symlinkcCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dS�Nr�r�r�r�r�Fr�)r\r~r��is_fiforlr�rrr�test_is_fifo_false}s
z _BasePathTest.test_is_fifo_false�mkfifozos.mkfifo() requiredc
Cs�|�td�}zt�t|��Wn2tyP}z|�d|�WYd}~n
d}~00|�|���|�	|�
��|�	|���|�|�td���d�|�|�td���d�dS)NZmyfifozos.mkfifo(): %su	myfifo�Fzmyfifo)
r\r~r�r�rjrPrr�r�r��	is_socketr�rl)rrdrSrrr�test_is_fifo_true�s$z_BasePathTest.test_is_fifo_truecCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dSr�)r\r~r�r�rlr�rrr�test_is_socket_false�s
z"_BasePathTest.test_is_socket_false�AF_UNIXzUnix sockets requiredc
Cs�|�td�}t�tjtj�}|�|j�z|�t|��WnLt	y�}z4t
|t�s`dt|�vrr|�dt|��WYd}~n
d}~00|�
|���|�|���|�|���|�|�td���d�|�|�td���d�dS)NZmysockzAF_UNIX path too longzcannot bind Unix socket: u	mysock�Fzmysock)r\r~�socketr�ZSOCK_STREAMr��closeZbindrjr��
isinstancerPrr�r�r�r�r�rl)rrdZsockrSrrr�test_is_socket_true�s

�(z!_BasePathTest.test_is_socket_truecCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dSr�)r\r~r��is_block_devicerlr�rrr�test_is_block_device_false�s
z(_BasePathTest.test_is_block_device_falsecCs�|�t�}|�|d���|�|d���|�|d���|�|dd���|�|d��d�|�|d��d�dSr�)r\r~r��is_char_devicerlr�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)	r\r�rr�r�r�r�r�rlr�rrr�test_is_char_device_true�s

z&_BasePathTest.test_is_char_device_truecCsP|�td�}tdtjd�D].}t�||�}t�|�}|�|��|���qdS)Nr�rr�)	r\r~r�r�r�r�r�rr�)rr^r�rrwrrrr�s

z"_BasePathTest.test_pickling_commoncCsJ|j}|d�}|d�}|�|jd|jd�|�|jd|jd�dS)Nz/usr/bin/fooz/usr/local/binr�r�r�)r\rlrkrUrrr�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�Wt�|�nt�|�0dS)NZlink0Zlink1Zlink2Zlink3)r\r~r�r�r|r}rrr�rjr��chdir)rZlink0_targetrdr^Zold_pathrrr�_check_complex_symlinks�sB

z%_BasePathTest._check_complex_symlinkscCs|�t�dSrg)r�r~rrrrr�test_complex_symlinks_absolute	sz,_BasePathTest.test_complex_symlinks_absolutecCs|�d�dS)Nr#)r�rrrrr�test_complex_symlinks_relative	sz,_BasePathTest.test_complex_symlinks_relativecCs|�tj�dd��dS)Nr�r�)r�r�r|r}rrrrr�&test_complex_symlinks_relative_dot_dot	sz4_BasePathTest.test_complex_symlinks_relative_dot_dotN)T)[r,r-r.�__doc__r_r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�skip_unless_symlinkr�r�r�rrrrrr!r)r+r,r2r3r7r:r<r=�unittest�
skipUnlessr?r�rDr�rGrIrK�hasattrrT�skipIfrVrXrYr[rbrcrfrirmrorp�only_ntrrrtrurr�r�r��
only_posixr�r�r�r�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�dSrg)rlr\rjrrrrr�test_class_getitem	szPathTest.test_class_getitemcCs0|�d�}|�t|�tjdkr$tjntj�dSru)r\rlrmr�r�rCr�r�r]rrrrw	s

�zPathTest.test_concrete_classcCs,tjdkr|�ttj�n|�ttj�dS)Nrv)r�r�r�r�rCr�r�rrrrr�test_unsupported_flavour	s
z!PathTest.test_unsupported_flavourcCsF|��}|�td��t|�d��Wd�n1s80YdS)NzUnacceptable patternr)r\ZassertRaisesRegexr�r�r�r]rrr�test_glob_empty_pattern!	sz PathTest.test_glob_empty_patternN)
r,r-r.rC�Pathr\r�rwr�r�rrrrr�	s
r�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"cGsF|j|�}|�t��t|�|��Wd�n1s80YdSrg)r\r��RuntimeError�printr)rr rnr|rrr�_check_symlink_loop+	s
z!PosixPathTest._check_symlink_loopcCs�t�d�}|�tj|�|�t�}|d�d��Wd�n1sF0Yt�td��}|�t�	|j
�d�t�d�|d�d��Wd�n1s�0Yt�td��}|�t�	|j
�d�dS)Nr�new_filer����other_new_file�)r��umaskr�r\r~r�r�r}rrhr5�rZold_maskr^r9rrr�test_open_mode0	s


zPosixPathTest.test_open_modec	CsPt��}z6t�d�|�d�}|�t|���d�Wt�|�nt�|�0dS)Nrr$z/spam)r�r�r�r\rrjr)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�)r6)r�r�r�r\r~rr�r}rrhr5r�rrr�test_touch_modeG	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�r�r}r�r~rrrrr�test_resolve_loopV	szPosixPathTest.test_resolve_loopcCsX|j}|t�}t|�d��}t�t�s,t�n|}|�||�|�t|�d��t��dS)N�FILEazFILEa*)r\r~r�r�r�fs_is_case_insensitiver�rrdr^rrrrr�	test_globk	szPosixPathTest.test_globcCsZ|j}|td�}t|�d��}t�t�s.t�n|}|�||�|�t|�d��t��dS)Nr��FILEdzFILEd*)r\r~r�rrr�rr�rrr�
test_rglobs	s
zPosixPathTest.test_rglob�getpwallz%pwd module does not expose getpwall()cCsP|j}t�d�ddl}|�t���}|j}|j�	d�p:d}|�
�D]&}|j}|j�	d�}||krD|rDqtqD|}|}d}z|�|�r�|d7}qzWnty�Yn0|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�n1�sB0YdS)Nr?rrZfakeuserr.z~/Documentsr�z
/Documentsr�r�rr�Z	Documentsz/tmpz/tmp/Documents)r\r�
import_moduler?r@r��getuidrA�pw_dir�rstripr��getpwnamrBr�rwrr�r�r�)rrdr?ZpwdentZusername�userhomeZ	othernameZ	otherhomeZfakename�p1�p2�p3�p4�p5�p6Zp7r�rrr�test_expanduser{	sV

zPosixPathTest.test_expanduser�darwinz1Bad file descriptor in /dev/fd affects only macOSc
Cs�zxtt�d��d��dd�}|s,|�d�|D]D}|��|��|��|��|�	�|�
�|��|��q0Wn<t
y�}z$|jtjkr�|�d��WYd}~n
d}~00dS)Nz/dev/fdrr�z.no file descriptors - issue was not reproducedz Bad file descriptor not handled.)r�rCr�rrr�rdr�r�r�r�r�r�r�r�ZEBADFZfail)rZfile_descriptorsrrSrrr�test_handling_bad_descriptor�	s"

z*PosixPathTest.test_handling_bad_descriptorN)r,r-r.rCr�r\r�r�r�r�rr�r�r�r�r�r�r�r?r�r��sys�platformr�rrrrr�'	s"	
�
5�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�r�zF*az\FILEaz\fileA)r\r~rr�r��maprjrcrrrr��	s$zWindowsPathTest.test_globcCsV|j}|td�}|�t|�d��|td�h�|�ttt|�d���|�d�h�dS)Nr�r�rz\dirD\FILEd)r\r~rr�rr�rjrcrrrr��	s
zWindowsPathTest.test_rglobc
sl�j�t����F���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�n1�s^0YdS)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)rwrr�r�rBr�	rdr�r�r�r�r�r�r�rrrr*�	s
�
�
�z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alicezC:\Users\eve)r\rr�rwr�r�r�rr7rr�rr��	s>zWindowsPathTest.test_expanduserN)	r,r-r.rCr�r\r�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
||_dSrg)�string)rr�rrr�__init__
sz&CompatiblePathTest.CompatPath.__init__cCst|�|j�d|���Srz�rmr��rrrrr�__truediv__"
sz)CompatiblePathTest.CompatPath.__truediv__cCst|�|�d|j���Srzr�r�rrr�__rtruediv__%
sz*CompatiblePathTest.CompatPath.__rtruediv__N)r,r-r.r�r�r�r�rrrr�
CompatPath
sr�cCslt�d�|�d�}|�||j�|�|jd�|�t��t�d�dWd�n1s^0YdS)N�test�rightz
test/rightr\)rCr{r�rbrr�r�r��r�resultrrr�test_truediv(
s
zCompatiblePathTest.test_truedivcCsl|�d�t�d�}|�||j�|�|jd�|�t��dt�d�Wd�n1s^0YdS)N�leftr�z	left/testr\)r�rCr{rbrr�r�r�r�rrr�
test_rtruediv1
s
z CompatiblePathTest.test_rtruedivN)r,r-r.r�r�r�r�rrrrr�
s	r��__main__)0�collections.abcr�r�r�r�r�rCr�r�r�r*r�rr�rZtest.supportrrrDr?�ImportError�objectrZTestCaser/rDrUrrrtr|�realpathr~r}rQr�r�r�r�r�r�r�r�r�r�r�r,�mainrrrr�<module>s|)$BL��[#G)