a
    "h                    @   s  d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlmZ d dlmZ d dlmZmZ zd dlZd dlZW n ey   d ZZY n0 G dd deZG dd deejZG d	d
 d
eejZG dd deZG dd deejZG dd deejZG dd deejZejeZ dd Z!dd Z"e#ej$dkdZ%e#ej$dkdZ&e&G dd deZ'e%G dd deZ(G dd deZ)G dd  d e)ejZ*e&G d!d" d"e)ejZ+e%G d#d$ d$e)ejZ,G d%d& d&ejZ-e.d'kre/  dS )(    N)mock)support)TESTFNFakePathc                   @   s   e Zd Zdd Zdd ZdS )_BaseFlavourTestc                    sd   | j j}| j j| j j |fdd|D }| ||  r`| fdd|D }| || d S )Nc                    s   g | ]}| d  qS /replace.0x)sep 9/opt/python-3.9.21/usr/lib/python3.9/test/test_pathlib.py
<listcomp>       z7_BaseFlavourTest._check_parse_parts.<locals>.<listcomp>c                    s   g | ]}| d  qS r   r	   r   )altsepr   r   r       r   )flavourparse_partsr   r   assertEqual)selfargexpectedfactualr   )r   r   r   _check_parse_parts   s    z#_BaseFlavourTest._check_parse_partsc                 C   s  | j }| jj}|g ddg f |dgdddgf |dgdddgf |ddgddddgf |dgddddgf |dgddddgf |g dddg df |g d	ddg df |g d
ddg df |dgddg f |g ddddgf |g dddddgf |g ddddgf |dgd||ddgf |ddgd||ddgf |ddgd||ddgf |g dd||ddgf |g dd||dgf d S )N aa/ba/ba/b/)r   zb/cd)r   r    cr#   )r   zb//cr#   )r   zb/c/r#   .)r%   r%   r    )r   r%   r    )r   r%   r%   /a/b/a/a/r   /br$   r$   )r   r*   /c)r   r   r   )r   checkr   r   r   r   test_parse_parts_common#   s(    z(_BaseFlavourTest.test_parse_parts_commonN)__name__
__module____qualname__r   r-   r   r   r   r   r      s   
r   c                   @   s"   e Zd ZejZdd Zdd ZdS )PosixFlavourTestc                 C   s   | j }|ddgddg df |ddgddg df |d	dgddg df |d
gddd
gf |dgdddgf |dgdddgf d S )N//ar    r   //)r3   r   r    ///ar   )r   r   r    z////ac:ac:\a\ar   r   r,   r   r   r   test_parse_partsC   s    z!PosixFlavourTest.test_parse_partsc                 C   s   | j 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 S )Nr   r   r   r   r   r   r   r   r!   )r   r   r!   r"   )r   r   r"   r'   )r   r   r   r&   )r   r   r!   /a/b/)r   r   r"   r2   )r   r3   r   r4   ///a/bc:/a/b)r   r   r?   \/a/b)r   r   r@   \a\b)r   r   rA   r   	splitrootr   r   r   r   r   r   test_splitrootO   s    zPosixFlavourTest.test_splitrootN)r.   r/   r0   pathlib_posix_flavourr   r:   rE   r   r   r   r   r1   @   s   r1   c                   @   s"   e Zd ZejZdd Zdd ZdS )NTFlavourTestc                 C   s  | j }|dgdddgf |dgdddgf |dgdddgf |dgddddgf |d	gddddgf |d
gddddgf |dgdddgf |dgdddgf |dgddddgf |g dddg df |g dddg df |g dddddgf |g dddg df |g dddddgf |dgdddgf |d gddddgf |d d!gdddd"gf |d#gd$dd%gf |d&gd$dd%dgf |g d'ddg d(f |g d)ddg df |g d*d+dg d,f d S )-Nc:r   c:/\c:\r   r5   r   c:/ar'   //a/b\\a\b\\a\b\//a/b///a/b/cr$   )r   zZ:br$   Z:)rS   r    r$   )r   zZ:/br$   )Z:\r    r$   )r   z//b/cr#   z\\b\cz\\b\c\r#   )r   z	Z://b//c/d/)rT   r    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)   )rK   r    r$   )zZ:/ar*   r$   )z//?/Z:/ar*   r$   z\\?\Z:)z\\?\Z:\r    r$   r8   r9   r   r   r   r:   g   s.    zNTFlavourTest.test_parse_partsc                 C   s  | j 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 S )Nr   r;   r   r<   a\b)r   r   rV   r7   )r   rK   r   rA   )r   rK   rV   zc:a\b)rI   r   rV   zc:\a\b)rI   rK   rV   z\\az\\\a/b)r   rK   r!   zc:\\a)rI   rK   r   zc:\\\a/b)rI   rK   r!   rO   )rO   rK   r   rP   	\\a\b\c\d)rO   rK   c\dz\\\a\brB   rD   r   r   r   rE      s"    zNTFlavourTest.test_splitrootN)r.   r/   r0   rF   _windows_flavourr   r:   rE   r   r   r   r   rH   d   s   "rH   c                   @   s&  e Zd Zg dg ddZdd Zdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Z d>d? Z!d@dA Z"dBdC Z#dDdE Z$dFS )G_BasePurePathTest)
r   r    )r   r    )r   b/)r   r\   )r"   )za//b)za//b//)r   r   r    )r   r   r    )r   r    r   ))r   /b/cr#   )r   z///b//crU   )r'   r]   r#   )r   r    r   c/d)r   r   zb/c/d)r   /b/c/d)r!   r_   c                 C   s*   |  d}|j| _| jj| _| jj| _d S Nr   )cls_flavourr   r   r   r   pr   r   r   setUp   s    

z_BasePurePathTest.setUpc                 C   s   | j }|d}| || |ddd |ddd |d |d |td | ||d|d | ||dd|d | ||d|d|d | ||d|d|d|td d S )Nr   r    r$   r'   a/b/c/a/b/cr!   )ra   assertIsInstancer   r   r   Prd   r   r   r   test_constructor_common   s    z)_BasePurePathTest.test_constructor_commonc                    s\   G dd dt  | j}| fdd|D  }| |||  |jD ]}| t|t  qBd S )Nc                   @   s   e Zd ZdS )z:_BasePurePathTest._check_str_subclass.<locals>.StrSubclassN)r.   r/   r0   r   r   r   r   StrSubclass   s   rl   c                 3   s   | ]} |V  qd S Nr   r   rl   r   r   	<genexpr>   r   z8_BasePurePathTest._check_str_subclass.<locals>.<genexpr>)strra   r   partsassertIstype)r   argsrj   rd   partr   rn   r   _check_str_subclass   s    
z%_BasePurePathTest._check_str_subclassc                 C   s6   |  d |  d |  d |  d |  d d S )Nr   r%   r   za/b.txtz/a/b.txtrv   r   r   r   r   test_str_subclass_common   s
    



z*_BasePurePathTest.test_str_subclass_commonc                 C   s   | j }|d}|d}| ||d | t|t| |dd}| ||d ||d}| ||d |d}| ||d d S )Nr!   r$   rf   r#   a/b/c/dr+   )ra   joinpathr   rr   rs   r   rj   rd   ppr   r   r   test_join_common   s    

z"_BasePurePathTest.test_join_commonc                 C   s   | j }|d}|d }| ||d | t|t| |d }| ||d |d d }| ||d d| d }| ||d ||d }| ||d |d }| ||d d S )	Nr!   r$   rf   r^   rz   r#   zc/a/b/dr+   )ra   r   rr   rs   r|   r   r   r   test_div_common   s    z!_BasePurePathTest.test_div_commonc                 C   s(   | j | }| t||d| j d S Nr   )ra   r   rp   r
   r   )r   r   rt   rd   r   r   r   
_check_str   s    
z_BasePurePathTest._check_strc                 C   s(   dD ]}|  ||f q|  dd d S )Nr   r!   rf   r   r&   rg   r%   )r   )r   )r   pathstrr   r   r   test_str_common  s    z!_BasePurePathTest.test_str_commonc                 C   s(   | j }dD ]}| || | q
d S )Nr   )ra   r   as_posix)r   rj   r   r   r   r   test_as_posix_common  s    z&_BasePurePathTest.test_as_posix_commonc                 C   s2   t | j}| j}| t|dd| d  d S )Nr!      a   b)osfsencoder   ra   r   bytes)r   r   rj   r   r   r   test_as_bytes_common  s    z&_BasePurePathTest.test_as_bytes_commonc                 C   st   | j }| t |d  W d    n1 s20    Y  | t |   W d    n1 sf0    Y  d S r`   )ra   assertRaises
ValueErroras_urir   rj   r   r   r   test_as_uri_common  s
    *z$_BasePurePathTest.test_as_uri_commonc                 C   s   dD ]}|  |}|jj}t|}| ||d | | |d| |t|d d }| t	||
  t	|tj}| |j|j | || | t|| qd S )Nr   ()   )ra   	__class__r.   repr
assertTrue
startswithendswithlenr   evalr   rF   __dict__rr   )r   r   rd   Zclsnamerinnerqr   r   r   test_repr_common  s    
z"_BasePurePathTest.test_repr_commonc                 C   s   | j }| |d|d | |d|dd | |d|d | |d|d | |d|  | |d|d | | |d | | d | | i  | | t d S )Nr!   r   r    r&   r   r   )ra   r   assertNotEqualintr   r   r   r   test_eq_common-  s    z _BasePurePathTest.test_eq_commonc                 C   sN  | j }| t|djd | t|d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d | |dd | |dd | |dd d S )Nr   r   r%   b.pya/b.py/a/b.pyza.pyzb/pyz/a.pyzb.py/cz*.pyzb.pyczb./pyzab/c.pyza*/*.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)ra   r   r   matchr   assertFalser   r   r   r   test_match_common:  s<    z#_BasePurePathTest.test_match_commonc                    s    fdd} j }|d}|d}|d}|d}||| ||| ||| ||| |||  j }|d}|d}|d	}|d
}||| ||| ||| ||| |||  t | i k  W d    n1 s0    Y  d S )Nc                    s     | |  ||  d S rm   )
assertLessZassertGreaterr[   rx   r   r   r   b  s    z:_BasePurePathTest.test_ordering_common.<locals>.assertLessr   r!   abcr    r'   r&   z/abcr*   )ra   r   	TypeError)r   r   rj   r   r    r$   r#   r   rx   r   test_ordering_common`  s.    









z&_BasePurePathTest.test_ordering_commonc                 C   sX   | j }| j}|d}|j}| |d | ||j |d}|j}| ||ddf d S )Nr!   r[   r&   r   r    )r   ra   rq   r   rr   )r   r   rj   rd   rq   r   r   r   test_parts_common|  s    z#_BasePurePathTest.test_parts_commonc                 C   s4   | j }|d}| | d | t|d d S )Nr!   )r!   )ra   r   
__fspath__r   fspathri   r   r   r   test_fspath_common  s    z$_BasePurePathTest.test_fspath_commonc              	      s    j  D ]\}}|d j}| jd}||krX| fdd|D  }||f  |}|D ]V} j| } ||d|  t|t|  t	||  |
 | qfq
d S )Nr   c                    s"   g | ]}t  fd d|D qS )c                 3   s   | ]}| d  jV  qdS )r   N)r
   r   )r   ru   rx   r   r   ro     r   zA_BasePurePathTest.test_equivalences.<locals>.<listcomp>.<genexpr>)tuple)r   trx   r   r   r     s   z7_BasePurePathTest.test_equivalences.<locals>.<listcomp>zfailed with args {})equivalencesitemsr
   r   appendra   r   formathashrp   r   )r   kZtuplesZcanonposixZpcanonr   rd   r   rx   r   test_equivalences  s    

z#_BasePurePathTest.test_equivalencesc                 C   s   | j }|d}| |j|d | |jj|d | |jjj|  | |jjjj|  |d}| |j|d | |jj|d | |jjj|d | |jjjj|d d S )Nrf   r!   r   rg   r&   r'   r   ra   r   parentri   r   r   r   test_parent_common  s    z$_BasePurePathTest.test_parent_commonc                 C   s  | j }|d}|j}| t|d | |d |d | |d |d | |d |d | t||d|d|dg | t |d	  W d    n1 s0    Y  | t |d  W d    n1 s0    Y  | t ||d< W d    n1 s0    Y  |d
}|j}| t|d | |d |d | |d |d | |d |d | t||d|d|dg | t |d  W d    n1 s0    Y  d S )Nrf      r   r!   r   r      r%   r   rg   r&   r'   r   )ra   parentsr   r   listr   
IndexErrorr   r   rj   rd   Zparr   r   r   test_parents_common  s.    "&&("z%_BasePurePathTest.test_parents_commonc                 C   s@   | j }| |djd | |djd | |djd d S )Nr!   r   r&   ra   r   driver   r   r   r   test_drive_common  s    z#_BasePurePathTest.test_drive_commonc                 C   sX   | j }| j}| |djd | |djd | |dj| | |dj| d S Nr   r!   r   r&   )ra   r   r   rootr   rj   r   r   r   r   test_root_common  s    z"_BasePurePathTest.test_root_commonc                 C   sX   | j }| j}| |djd | |djd | |dj| | |dj| d S r   )ra   r   r   anchorr   r   r   r   test_anchor_common  s    z$_BasePurePathTest.test_anchor_commonc                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |djd | |djd	 | |d
jd	 d S )Nr   r%   r   r!   r    r&   /a/b/.r   r   r   ra   r   namer   r   r   r   test_name_common  s    z"_BasePurePathTest.test_name_commonc                 C   s<  | j }| |djd | |djd | |djd | |djd | |djd | |djd | |djd | |djd	 | |d
jd	 | |djd | |djd | |djd | |djd | |djd | |djd | |djd | |djd d S )Nr   r%   ..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.ra   r   suffixr   r   r   r   test_suffix_common  s$    z$_BasePurePathTest.test_suffix_commonc                 C   s:  | j }| |djg  | |djg  | |djg  | |djg  | |djg  | |djg  | |djdg | |d	jdg | |d
jg  | |djg  | |djdg | |djdg | |djddg | |djddg | |djg  | |djg  d S )Nr   r%   r   r!   r&   r   r   r   r   r   r   r   r   r   r   .tarr   r   r   r   ra   r   suffixesr   r   r   r   test_suffixes_common  s"    z&_BasePurePathTest.test_suffixes_commonc                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |djd | |djd	 | |d
jd | |djd | |djd d S )Nr   r%   r   r   r!   r    r   r   .hgrcr   .hgr   b.tarr   Some name. Ending with a dot.ra   r   stemr   r   r   r   test_stem_common  s    z"_BasePurePathTest.test_stem_commonc                 C   s2  | j }| |dd|d | |dd|d | |dd|d | |dd|d | |dd|d | |d	d|d | t|d
jd | t|djd | t|djd | t|djd
 | t|djd | t|djd | t|djd d S )Nr!   d.xmlza/d.xmlr&   z/a/d.xmlr   r   a/Dot ending./a/Dot ending.r   r%   r   r+   c/r^   ra   r   	with_namer   r   r   r   r   r   test_with_name_common"  s    z'_BasePurePathTest.test_with_name_commonc                 C   sL  | j }| |dd|d | |dd|d | |dd|d | |dd|d	 | |d
d|d | |dd|d | |dd|d | t|djd | t|djd | t|djd | t|djd | t|djd | t|djd | t|djd d S )Nr!   r#   za/dr&   z/a/dr   za/d.pyr   z/a/d.pyr   z/a/d.gzr   r   r   r%   r   r+   r   r^   ra   r   	with_stemr   r   r   r   r   r   test_with_stem_common2  s    z'_BasePurePathTest.test_with_stem_commonc                 C   s  | j }| |dd|d | |dd|d | |dd|d | |dd|d | |dd|d | |dd|d | t|djd | t|d	jd | t|d
jd | t|djd | t|djd
 | t|djd	 | t|djd | t|djd | t|djd | t|djd | t|djd | t|dj| jjdf d S )Nr!   r   za/b.gzr&   z/a/b.gzr   r   r   r%   r   gz/.gzr^   z.c/.dz./.dz.d/.r#   )ra   r   with_suffixr   r   r   r   r   r   r   r   test_with_suffix_commonC  s*    
z)_BasePurePathTest.test_with_suffix_commonc                 C   sR  | j }|d}| t|j | 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|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|jd | t|j|d d S )Nr!   r   r   r   r    r   r$   rf   a/cr'   r&   r   r(   r+   rg   /a/c)ra   r   r   relative_tor   r   ri   r   r   r   test_relative_to_common\  s<    z)_BasePurePathTest.test_relative_to_commonc                 C   s  | j }|d}| t|j | t|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 S )Nr!   r   r   r   r   r    r$   rf   r   r'   r&   r   r(   r+   rg   r   )ra   r   r   is_relative_tor   r   ri   r   r   r   test_is_relative_to_common  s:    z,_BasePurePathTest.test_is_relative_to_commonc                 C   s   | j }|d}tdtjd D ]^}t||}t|}| |j|j | || | t	|t	| | t
|t
| qd S )Nr&   r   r   )ra   rangepickleHIGHEST_PROTOCOLdumpsloadsrr   r   r   r   rp   )r   rj   rd   protodumpedr}   r   r   r   test_pickling_common  s    
z&_BasePurePathTest.test_pickling_commonN)%r.   r/   r0   r   re   rk   rv   ry   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   r   r  r  r  r   r   r   r   rZ      sH   &#"rZ   c                   @   sZ   e Zd ZejZdd Zdd Zdd Zdd Z	d	d
 Z
dd Zdd Zdd Zdd ZdS )PurePosixPathTestc                 C   s@   | j }| |djd | |djd | |djd d S )Nr&   r   r>   rN   r3   ra   r   r   r   r   r   r   	test_root  s    zPurePosixPathTest.test_rootc                 C   sF   | j }| |d|d | |d|d | |d|d d S )Nr!   A/br'   r4   r2   )ra   r   r   r   r   r   r   test_eq  s    zPurePosixPathTest.test_eqc                 C   sF   | j }| |d d | |d d | |d d d S )Nr   zfile:///z/a/b.czfile:///a/b.cz/a/b%#czfile:///a/b%25%23c)ra   r   r   r   r   r   r   test_as_uri  s    zPurePosixPathTest.test_as_uric                 C   sd   ddl m} | j}ztd W n ty<   | d Y n0 | |d d|td  d S )Nr   )quote_from_bytes   éz1\xe9 cannot be encoded to the filesystem encodingu   /a/bézfile:///a/b)	urllib.parser  ra   r   r   UnicodeEncodeErrorskipTestr   r   )r   r  rj   r   r   r   test_as_uri_non_ascii  s    z'PurePosixPathTest.test_as_uri_non_asciic                 C   s   | j }| |dd d S )NzA.pyza.PY)ra   r   r   r   r   r   r   
test_match  s    zPurePosixPathTest.test_matchc                 C   s   | j }| |   | |d  | |d  | |d  | |d  | |d  | |d  | |d  d S )Nr   r"   r   r'   r=   r2   rN   ra   r   is_absoluter   r   r   r   r   test_is_absolute  s    z"PurePosixPathTest.test_is_absolutec                 C   sZ   | j }| d|d  | d|d  | d|d  | d|d  d S )NFr   r   /foo/barz/dev/con/PRN/NULra   rr   is_reservedr   r   r   r   test_is_reserved  s
    z"PurePosixPathTest.test_is_reservedc                 C   sh   | j }|d}|d}| ||d |dd}| ||d |dd}| ||d d S Nr2   r    rN   r'   z//cr+   ra   r{   r   r|   r   r   r   	test_join  s    
zPurePosixPathTest.test_joinc                 C   sb   | j }|d}|d }| ||d |dd }| ||d |dd }| ||d d S r   ra   r   r|   r   r   r   test_div  s    zPurePosixPathTest.test_divN)r.   r/   r0   rF   PurePosixPathra   r  r  r  r  r  r  r  r"  r$  r   r   r   r   r    s   

r  c                   @   s  e Zd ZejZej Ze	g dg ddgddgd dd Z
d	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Z d5d6 Z!d7d8 Z"d9S ):PureWindowsPathTest))rI   r   )rI   r   )r   rI   r   ))rJ   r   )rI   r   r   )rI   r'   )z/zrJ   r   )z//x/yrJ   r   )rN   )rN   r$   )rQ   r$   )r5   rM   rQ   rR   c                 C   s   |  d}| t|d |  d}| t|d |  d}| t|d |  d}| t|d |  d	}| t|d
 d S )Nrf   za\b\czc:/a/b/czc:\a\b\crN   rP   rR   z\\a\b\c	//a/b/c/drW   )ra   r   rp   rc   r   r   r   test_str	  s    




zPureWindowsPathTest.test_strc                 C   s^   |  d |  d |  d |  d |  d |  d |  d |  d |  d	 d S )
NrI   r5   z	c:a\b.txtrL   r6   z
c:\a\b.txtz\\some\sharez\\some\share\az\\some\share\a\b.txtrw   rx   r   r   r   test_str_subclass  s    







z%PureWindowsPathTest.test_str_subclassc                 C   s   | j }| |d|d | |d|ddd | |d|d | |d|d | |d|d | |d|d	 | |d
|d | |d|d d S )Nc:a/brI   r   r    zd:a/br?   r&   za/Br  C:a/Bc:A/b//Some/SHARE/a/Bz//somE/share/A/b)ra   r   r   r   r   r   r   r     s    zPureWindowsPathTest.test_eqc                 C   s  | j }| t |d  W d    n1 s20    Y  | t |d  W d    n1 sh0    Y  | |d d | |d d | |d d | |d	 d
 | |d d | |d d | |d d d S )Nr&   r*  rJ   zfile:///c:/zc:/a/b.czfile:///c:/a/b.cz	c:/a/b%#czfile:///c:/a/b%25%23cu   c:/a/bézfile:///c:/a/b%C3%A9z//some/share/zfile://some/share/z//some/share/a/b.czfile://some/share/a/b.cu   //some/share/a/b%#céz"file://some/share/a/b%25%23c%C3%A9)ra   r   r   r   r   r   r   r   r   r  ,  s     **zPureWindowsPathTest.test_as_uric                 C   sr  | 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 S )Nzc:/b.pyr   zc:*.pyzc:/*.pyzd:/b.pyr   zc:b.pyr   z//some/share/a.pyz//some/share/*.pyz//other/share/a.pyz//some/share/a/b.pyzB.pyzb.PYz	c:/a/B.Pyz	C:/A/*.pYz//Some/Share/B.Pyz//somE/sharE/*.pY)ra   r   r   r   r   r   r   r   r   <  s&    z%PureWindowsPathTest.test_match_commonc                    s    fdd} j }|d}|d}|||  ||k   ||k |d}|d}|||  ||k   ||k d S )Nc                    s     | |  ||  d S rm   )ZassertLessEqualassertGreaterEqualr[   rx   r   r   assertOrderedEqualV  s    zDPureWindowsPathTest.test_ordering_common.<locals>.assertOrderedEqualr,  r+  z//some/Share/A/br-  )ra   r   )r   r/  rj   rd   r   r   rx   r   r   T  s    

z(PureWindowsPathTest.test_ordering_commonc                 C   sX   | j }|d}|j}| |d |d}|j}| |d |d}|j}| |d d S )Nr*  )rI   r   r    r?   )rL   r   r    r'  )rP   r$   r#   )ra   rq   r   )r   rj   rd   rq   r   r   r   
test_partse  s    zPureWindowsPathTest.test_partsc                 C   s  | j }|d}| |j|d | |jj|d | |jjj|d | |jjjj|d |d}| |j|d | |jj|d | |jjj|d | |jjjj|d |d	}| |j|d
 | |jj|d | |jjj|d d S )Nzz:a/b/czz:a/bz:az:zz:/a/b/czz:/a/bz:/az:/r'  rR   rN   r   ri   r   r   r   test_parentq  s    zPureWindowsPathTest.test_parentc                 C   s  | j }|d}|j}| t|d | |d |d | |d |d | t||d|dg | t |d  W d    n1 s0    Y  |d}|j}| t|d | |d |d | |d |d	 | t||d|d	g | t |d  W d    n1 s&0    Y  |d
}|j}| t|d | |d |d | |d |d | t||d|dg | t |d  W d    n1 s0    Y  d S )Nzz:a/b/r   r   r1  r   r2  zz:/a/b/r3  r4  r'  rR   rN   )ra   r   r   r   r   r   r   r   r   r   r   test_parents  s2    &(z PureWindowsPathTest.test_parentsc                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |djd | |djd d S )	NrI   r*  rJ   c:/a/b/rN   rO   rQ   r'  r   r   r   r   r   
test_drive  s    zPureWindowsPathTest.test_drivec                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |djd | |d	jd d S )
NrI   r   r*  rJ   rK   r7  rN   rQ   r'  r  r   r   r   r   r    s    zPureWindowsPathTest.test_rootc                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |djd | |d	jd d S )
NrI   r*  rJ   rL   r7  rN   rP   rQ   r'  )ra   r   r   r   r   r   r   test_anchor  s    zPureWindowsPathTest.test_anchorc                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |d	jd | |d
jd | |djd d S )NrI   r   rJ   r*  r    r?   c:a/b.pyr   	c:/a/b.py//My.py/Share.php//My.py/Share.php/a/br   r   r   r   r   	test_name  s    zPureWindowsPathTest.test_namec                 C   s*  | j }| |djd | |djd | |djd | |djd | |djd | |djd | |d	jd | |d
jd | |djd | |djd | |djd | |djd | |djd | |djd | |djd | |djd d S )NrI   r   rJ   r*  r?   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   r   r   r   test_suffix  s"    zPureWindowsPathTest.test_suffixc                 C   s:  | j }| |djg  | |djg  | |djg  | |djg  | |djdg | |djdg | |djg  | |d	jg  | |d
jdg | |djdg | |djddg | |djddg | |djg  | |djg  | |djg  | |djg  d S )NrI   rJ   r*  r?   r:  r   r;  r?  r@  rA  r   rB  rC  r   r   rD  r<  r=  rE  rF  r   r   r   r   r   test_suffixes  s"    z!PureWindowsPathTest.test_suffixesc                 C   s   | j }| |djd | |djd | |djd | |djd | |djd | |d	jd | |d
jd | |djd | |djd | |djd d S )NrI   r   zc:.zc:..r   rJ   r*  r    r:  r?  r   rA  r   rC  r   rE  r   r   r   r   r   r   	test_stem  s    zPureWindowsPathTest.test_stemc                 C   s   | j }| |dd|d | |dd|d | |dd|d | |dd|d | t|djd | t|d	jd | t|d
jd | t|djd | t|djd | t|djd | t|djd
 d S )Nr*  r   z	c:a/d.xmlr?   z
c:/a/d.xmlc:a/Dot ending.c:/a/Dot ending.rI   rJ   
//My/Shared:d:ed:/er   r   r   r   r   test_with_name  s    z"PureWindowsPathTest.test_with_namec                 C   s   | j }| |dd|d | |dd|d | |dd|d | |dd|d | t|djd | t|d	jd | t|d
jd | t|djd | t|djd | t|djd | t|djd
 d S )Nr*  r#   zc:a/dr?   zc:/a/drJ  rK  rI   rJ   rL  rM  rN  rO  r   r   r   r   r   test_with_stem
  s    z"PureWindowsPathTest.test_with_stemc                 C   s  | j }| |dd|d | |dd|d | |dd|d | |dd|d | t|djd | t|d	jd | t|d
jd | t|djd | t|djd | t|djd
 | t|djd | t|djd | t|djd | t|djd | t|djd | t|djd | t|djd | t|djd | t|djd d S )Nr*  r   zc:a/b.gzr?   z	c:/a/b.gzr:  r;  r   r%   r   rL  r   rK   rI   r   z\.gzzc:.gzr^   rX   z.c/dz.c\d)ra   r   r   r   r   r   r   r   r   test_with_suffix  s(    z$PureWindowsPathTest.test_with_suffixc                 C   s0  | j }|d}| ||d|d | |d|d | ||d|d | |d|d | |d|d | ||d|  | |d|  | t|j|  | 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 | 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& d S )'N	C:Foo/BarrI   zFoo/Barc:foOZBarc:foO/	c:foO/baRr   rM  r   Foo/FooC:/FooC:Foo/Bar/Baz	C:Foo/Baz
C:/Foo/Barz/Foo/Barz\Foo\BarrJ   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)ra   r   r   r   r   rp   ri   r   r   r   test_relative_to0  sh    z$PureWindowsPathTest.test_relative_toc                 C   sH  | 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 S )#NrS  rI   rT  rU  rV  r   rM  r   rW  rX  rY  rZ  r[  r\  rJ   r]  r^  r_  r`  ra  rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  )ra   r   r  r   ri   r   r   r   test_is_relative_toj  s^    z'PureWindowsPathTest.test_is_relative_toc                 C   s(  | j }| |   | |d  | |d  | |d  | |d  | |d  | |d  | |d  | |d  | |d	  | |d
  | |d  | |d  | |d  | |d  | |d  d S )Nr   r"   r   r'   r=   rI   r5   zc:a/b/rJ   rM   r7  rN   rQ   rR   r'  r  r   r   r   r   r    s"    z$PureWindowsPathTest.test_is_absolutec                 C   s   | j }|d}|d}| ||d |d}| ||d |d}| ||d |d}| ||d |d}| ||d |d	}| ||d |d
}| ||d d S )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!  r|   r   r   r   r"    s     






zPureWindowsPathTest.test_joinc                 C   s   | 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 S )Nrr  rs  rt  r   yru  rv  z/xrw  zD:rx  ry  rz  r{  r#  ri   r   r   r   r$    s    zPureWindowsPathTest.test_divc                 C   s  | 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  d S )NFr   r   r  z//my/share/nul/con/auxTnulZauxZprnZconzconin$zconout$ZCOM1ZLPT9u   com¹u   com²u   lpt³zNUL.txtzPRN  z	AUX  .txtzCOM1:barzLPT9   :barzbar.com9zbar.lpt9zc:/baz/con/NULzc:/NUL/con/bazr  r   r   r   r   r    s2    z$PureWindowsPathTest.test_is_reservedN)#r.   r/   r0   rF   PureWindowsPathra   rZ   r   copyupdater(  r)  r  r  r   r   r0  r5  r6  r8  r  r9  r>  rG  rH  rI  rP  rQ  rR  rp  rq  r  r"  r$  r  r   r   r   r   r&    sD   



:5r&  c                   @   s*   e Zd ZejZdd Zdd Zdd ZdS )PurePathTestc                 C   s0   |  d}| t|tjdkr$tjntj d S Nr   nt)ra   rr   rs   r   r   rF   r~  r%  rc   r   r   r   test_concrete_class  s    

z PurePathTest.test_concrete_classc                 C   s$   t d}t d}| || d S r`   )rF   r%  r~  r   r   rd   r   r   r   r   test_different_flavours_unequal	  s    

z,PurePathTest.test_different_flavours_unequalc                 C   s   t d}t d}| t ||k  W d    n1 s<0    Y  | t ||k W d    n1 sn0    Y  | t ||k W d    n1 s0    Y  | t ||k W d    n1 s0    Y  d S r`   )rF   r%  r~  r   r   r  r   r   r   !test_different_flavours_unordered  s    

&&&z.PurePathTest.test_different_flavours_unorderedN)	r.   r/   r0   rF   PurePathra   r  r  r  r   r   r   r   r    s   r  c                  G   s   t jjtg| R  S rm   )r   pathjoinBASEr   r   r   r   <lambda>!  r   r  c                  G   s   t jjtg| R  S rm   )r   r  r  r   r  r   r   r   r  "  r   r  z)test requires a Windows-compatible systemz'test requires a POSIX-compatible systemc                   @   s   e Zd ZejZdS )PosixPathAsPureTestN)r.   r/   r0   rF   	PosixPathra   r   r   r   r   r  )  s   r  c                   @   s"   e Zd ZejZdd Zdd ZdS )WindowsPathAsPureTestc                 C   s@   | j }| t |d  W d    n1 s20    Y  d S NrJ   )ra   r   NotImplementedErrorownerr   r   r   r   
test_owner1  s    z WindowsPathAsPureTest.test_ownerc                 C   s@   | j }| t |d  W d    n1 s20    Y  d S r  )ra   r   r  groupr   r   r   r   
test_group6  s    z WindowsPathAsPureTest.test_groupN)r.   r/   r0   rF   WindowsPathra   r  r  r   r   r   r   r  -  s   r  c                   @   s  e Zd ZdZdd Zejdkr(dd Zndd Zdd	 Zd
d Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zejd&d' Zd(d) Zd*d+ Zd,d- Zejd.d/ Zd0d1 Zd2d3 Zejd4d5 Z dd7d8Z!e! Z"Z#ejd9d: Z$ejd;d< Z%d=d> Z&d?d@ Z'dAdB Z(ejdCdD Z)dEdF Z*e+,e-dGdHdI Z.e+,e/dJdKdL Z0dMdN Z1dOdP Z2dQdR Z3e+,e4edSdTdUdV Z5e+6e4edSdWdXdY Z7dZd[ Z8d\d] Z9ejd^d_ Z:d`da Z;dbdc Z<ddde Z=dfdg Z>dhdi Z?djdk Z@dldm ZAeBdndo ZCdpdq ZDdrds ZEdtdu ZFejdvdw ZGdxdy ZHdzd{ ZIeJd|d} ZKd~d ZLdd ZMe+,e4edddd ZNdd ZOe+,e4ePdddd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWejdd ZXejdd ZYejdd ZZdS )_BasePathTestz?Tests for the FS-accessing functionalities of the Path classes.c                 C   s  dd }|  | tt ttd ttd ttd ttdd ttd ttdd	}|d
 W d    n1 s0    Y  ttddd	}|d W d    n1 s0    Y  ttddd	}|d W d    n1 s0    Y  ttdddd	}|d W d    n1 sF0    Y  ttdd t	 rt
dtd t
dtd | dtd | tjddtdd | tjddtdd t
dtd d S )Nc                   S   s   t tdd tt d S )NdirE  )r   chmodr  r   rmtreer  r   r   r   r   cleanupS  s    z$_BasePathTest.setUp.<locals>.cleanupdirAdirBdirCZdirDr  fileAwbs   this is file A
fileBs   this is file B
ZfileCs   this is file C
ZfileDs   this is file D
r   linkAnon-existing
brokenLinklinkBr   linkClinkDbrokenLinkLoop)
addCleanupr   mkdirr  r  openwriter  r   can_symlinksymlinkdirlinkr  )r   r  r   r   r   r   re   R  s0    

((**
z_BasePathTest.setUpr  c                 C   s   t j||dd d S )NTtarget_is_directoryr   r  r   srcdestr   r   r   r  s  s    z_BasePathTest.dirlinkc                 C   s   t || d S rm   r  r  r   r   r   r  v  s    c                 C   s*   |  tjt|t|d||f  d S )Nz&%r and %r don't point to the same file)r   r   r  samefilerp   r   Zpath_aZpath_br   r   r   
assertSamey  s
    z_BasePathTest.assertSamec                 O   sN   |  t}||i | W d    n1 s.0    Y  | |jjtj d S rm   )r   FileNotFoundErrorr   	exceptionerrnoENOENT)r   funcrt   kwargscmr   r   r   assertFileNotFound~  s    ,z _BasePathTest.assertFileNotFoundc                 C   s    |  tj|tj| d S rm   )r   r   r  normcaser  r   r   r   assertEqualNormCase  s    z!_BasePathTest.assertEqualNormCasec                 C   sT   |  t }| || | t|t| | t|t| | |	  d S rm   )
ra   r   getcwdr   r  rp   rr   rs   r   r  r  r   r   r   	_test_cwd  s
    z_BasePathTest._test_cwdc                 C   s   | j  }| | d S rm   )ra   cwdr  rc   r   r   r   test_cwd  s    
z_BasePathTest.test_cwdc                 C   sX   |  tjd}| || | t|t| | t|t| | 	|
  d S )N~)ra   r   r  
expanduserr   r  rp   rr   rs   r   r  r  r   r   r   
_test_home  s
    z_BasePathTest._test_homec                 C   s   t  l}| | j  |  tjt	d|d< | | j  tjt	d|d< | | j  W d    n1 sz0    Y  d S )NZuserprofileUSERPROFILEhomeHOME)
r   EnvironmentVarGuardr  ra   r  clearr   r  r  r  )r   envr   r   r   	test_home  s    
z_BasePathTest.test_homec                 C   s   t jtd}t jtdd}| |}| |}| |}| || | || | || | || t jtd}| |}| t	|j| | t	|j| | t	|j| | t	|j| | t	|j| | t	|j| d S )Nr  r  r  foo)
r   r  r  r  ra   r   r  r   r   r  )r   Z
fileA_pathZ
fileB_pathrd   r}   r   Znon_existentr   r   r   r   test_samefile  s"    



z_BasePathTest.test_samefilec                 C   s$   |  d}| | td d S )Nr   r%   )ra   r   statr   rc   r   r   r   test_empty_path  s    
z_BasePathTest.test_empty_pathc                 C   s   | j }|d}| | |tjd |d}| | | |d}| | | |d}| | | ||d jd }| | | d S )Nr  r  /~../~r   )ra   r   r  r   r  absoluter   ri   r   r   r   test_expanduser_common  s    z$_BasePathTest.test_expanduser_commonc                 C   s  | j }|t}| d|  | d|d   | d|d   | d|d d   t r| d|d   | d|d   | d|d d   | d|d d   | d|d	   | d|d
  | d|td   | d|td   d S )NTr  r  Fbahr  r  r  r  z/xyzzyu    )ra   r  rr   existsr   r  ri   r   r   r   test_exists  s    z_BasePathTest.test_existsc                 C   s   |  t}|d d.}| |tj | | d W d    n1 sL0    Y  |d d2}| |tj | | 	 d W d    n1 s0    Y  |d jddd2}| |tj
 | | 	 d W d    n1 s0    Y  d S )Nr  r   zthis is file A
rb   this is file Ar   )	buffering)ra   r  r  rh   io
TextIOBaser   readBufferedIOBasestrip	RawIOBase)r   rd   r   r   r   r   test_open_common  s    
.2z_BasePathTest.test_open_commonc                 C   sX   |  t}|d d | |d  d | t|d jd | |d  d d S )Nr  s   abcdefgZsomestr)ra   r  write_bytesr   
read_bytesr   r   rc   r   r   r   test_read_write_bytes  s
    
z#_BasePathTest.test_read_write_bytesc                 C   sf   |  t}|d jddd | |d jdddd | t|d jd	 | |d jddd d S )
Nr  u   äbcdefgzlatin-1)encodingzutf-8ignore)r  errorsZbcdefgs	   somebytes)ra   r  
write_textr   	read_textr   r   rc   r   r   r   test_read_write_text  s    
z"_BasePathTest.test_read_write_textc                    sX   | j   t}| }t|}g d}t r:|g d7 }| | fdd|D  d S )N)r  r  r  r  r  )r  r  r  r  c                    s   h | ]} t |qS r   r  r   r   rj   r   r   	<setcomp>   r   z-_BasePathTest.test_iterdir.<locals>.<setcomp>)ra   r  iterdirsetr   r  r   )r   rd   itpathsr   r   r  r   test_iterdir  s    z_BasePathTest.test_iterdirc                    s>   | j   td}t| } fdddD }| || d S )Nr  c                    s   h | ]} t d |qS )r  r  r  r  r   r   r    r   z5_BasePathTest.test_iterdir_symlink.<locals>.<setcomp>)r  r  )ra   r  r  r  r   )r   rd   r  r   r   r  r   test_iterdir_symlink  s
    
z"_BasePathTest.test_iterdir_symlinkc                 C   sb   |  td}| t}t|  W d    n1 s80    Y  | |jjtj	tj
tjf d S Nr  )ra   r  r   OSErrornextr  assertInr  r  ENOTDIRr  EINVALr   rd   r  r   r   r   test_iterdir_nodir  s    *z _BasePathTest.test_iterdir_nodirc                    s    fdd}j   t}|d}|tjj ||dg ||dg  ||dddg t s||dd	dg n||dg d
 t s||ddg n||dg d t s||ddg n||dddg d S )Nc                    s"    t|  fdd|D  d S )Nc                    s   h | ]} t |qS r   r  r  r  r   r   r    r   zA_BasePathTest.test_glob_common.<locals>._check.<locals>.<setcomp>r   r  globr   rj   r   r   r   _check  s    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/fileBzlinkB/linkD*/fileBr  )	ra   r  r  rh   collectionsr   Iteratorr   r  r   r  rd   r  r   r  r   test_glob_common  s"    
z_BasePathTest.test_glob_commonc                    s    fdd}j   t}|d}|tjj ||dg ||ddg ||dg  t s||ddg n||dg d ||d	g d
  td}||d	ddg ||ddg d S )Nc                    s"    t|  fdd|D  d S )Nc                    s   h | ]} t |qS r   r  r  r  r   r   r  /  r   zB_BasePathTest.test_rglob_common.<locals>._check.<locals>.<setcomp>r  r  r  r   r   r  .  s    z/_BasePathTest.test_rglob_common.<locals>._checkr  r  r	  z*/fileAr  )r	  zdirB/linkD/fileBr  zdirA/linkC/fileBzfile*)r  r	  r
  dirC/dirD/fileDr  r
  r  z*/*)	ra   r  rglobrh   r  r   r  r   r  r  r   r  r   test_rglob_common-  s    

z_BasePathTest.test_rglob_commonc                    sB   | j }|t t d}h d}| | fdd|D  d S )N*>   r  r
  r  r  r  r  r  r	  r  r  z	dirC/dirDr  z
dirA/linkCr  r  c                    s   h | ]} | qS r   r   r   rd   r   r   r  R  r   z8_BasePathTest.test_rglob_symlink_loop.<locals>.<setcomp>)ra   r  r  r  r   )r   rj   givenexpectr   r  r   test_rglob_symlink_loopB  s
    
z%_BasePathTest.test_rglob_symlink_loopc                    s   d}| j }|td  | gdg| R  }|jdd ddg|  fdd	td
D }|D ]}| t|| qd fdd	td
D } }t|D ]&}|d }|D ]}| t|| qqd S )N   Zdeepr#   Tr   r   r  c                    s   g | ]}  qS r   )r  r   jbasepatternr   r   r   [  r   z;_BasePathTest.test_glob_many_open_files.<locals>.<listcomp>d   c                    s   g | ]}  d qS )r#   )r  r  )r  r   r   r   ^  r   )ra   r  r  r  r  r   r  )r   depthrj   rd   Zitersr  ir   r  r   test_glob_many_open_filesT  s    z'_BasePathTest.test_glob_many_open_filesc                 C   sf   | j }|t}| t|d|tdh | t|d|tdh | t|dt  d S )Nr   zdirA/../file*zdirA/../fileAz../xyzzy)ra   r  r   r  r  ri   r   r   r   test_glob_dotdote  s
    z_BasePathTest.test_glob_dotdotc                 C   sl  | j }|td }|  |d }|  |d }|  |d }|d }||d  td:}tt	||_
| tt|dd	 W d    n1 s0    Y  |  td:}tt	||_
| tt|dd
 W d    n1 s0    Y  |d td:}tt	||_
| tt|dd
 W d    n1 s^0    Y  d S )NZpermissionsfile1file2subdirfile3otherz
os.scandirr  r      r   )ra   r  r  touch
symlink_tor   patchsortedr   scandirZreturn_valuer   r   r  r  r  )r   rj   r  r&  r'  r(  r)  r0  r   r   r   test_glob_permissionsm  s*    88
z#_BasePathTest.test_glob_permissionsTc                 C   s   | |}| || d S rm   )resolver   )r   rd   r   strictr   r   r   r   _check_resolve  s    
z_BasePathTest._check_resolvec              
   C   s  | j }|td}| t}|jdd W d    n1 s<0    Y  | |jjtj | 	t
|jddtjtd |tddd}| 	t
|jddtjtddd |tdddd}| 	t
|jddtjtjddd |tdd	}| || |td
}| ||td |tddd	}| ||tdd	 |tddd	}| ||tdd	 |tddd	ddd}| ||tdd	dddd |tdddddd}tjdkr| ||tddddd n| ||tdddd ttjdt d}| tj| ttj|tdd ttdtj|d |tdddd	}| ||tdd	 |tdddddd}| ||tddddd |tddddddd}tjdkr| |||dddd n| ||tdddd d S )Nr  Tr3  Finspamr   r  r  r  r  r  r  r  r  z-dirD)r   dirlinkXlinkY)ra   r  r   r  r2  r   r  r  r  r  rp   r   r  r  abspath_check_resolve_relativer   r   Z	_longpathtempfilemkdtempr  r  r  r  _check_resolve_absolute)r   rj   rd   r  r#   r   r   r   test_resolve_common  sh    
*
z!_BasePathTest.test_resolve_commonc                 C   s   |  t}| dtd | tjddtd | tjddtd |d }| |jdd| |d d }| jt	|jdd | |jd	d|d d  d S )
Nr%   012Tr5  34F)
ra   r  r  r  r   r  r   r2  r   r  )r   rd   r   r   r   r   r   test_resolve_dot  s    
z_BasePathTest.test_resolve_dotc                 C   s   |  t}| }| }t| | W d    n1 s<0    Y  t| t| |  |  |  | W d    n1 s0    Y  d S rm   )ra   r  r  r  r  r2  r  )r   rd   r  Zit2r   r   r   	test_with  s    
z_BasePathTest.test_withc                 C   sd   |  td }| j}|d@ }|| | | j| |dB }|| | | j| d S )Nr  im   )ra   r  r  st_moder  r   )r   rd   modeZnew_moder   r   r   
test_chmod  s    


z_BasePathTest.test_chmodc                 C   sZ   |  td }| }| | | ||jdA  | |j|j | | | d S )Nr  rH  )ra   r  r  r   r  rI  r  r   r   rd   str   r   r   	test_stat  s    z_BasePathTest.test_statc                 C   s*   |  td }| }| ||  d S )Nr  )ra   r  r  r   lstatrL  r   r   r   
test_lstat  s    z_BasePathTest.test_lstatc                 C   s*   |  td }| }| ||  d S r  )ra   r  r  r   rO  rL  r   r   r   test_lstat_nosymlink  s    z"_BasePathTest.test_lstat_nosymlinkz&the pwd module is needed for this testc                 C   s^   |  td }| j}zt|j}W n  tyH   | d|  Y n0 | 	||
  d S )Nr  z4user %d doesn't have an entry in the system database)ra   r  r  st_uidpwdgetpwuidpw_nameKeyErrorr  r   r  )r   rd   uidr   r   r   r   r    s    

z_BasePathTest.test_ownerz&the grp module is needed for this testc                 C   s^   |  td }| j}zt|j}W n  tyH   | d|  Y n0 | 	||
  d S )Nr  z5group %d doesn't have an entry in the system database)ra   r  r  st_gidgrpgetgrgidgr_namerV  r  r   r  )r   rd   gidr   r   r   r   r  !  s    

z_BasePathTest.test_groupc                 C   s2   |  td }|  | |j | |j d S r  )ra   r  unlinkr  r  rc   r   r   r   test_unlink,  s    z_BasePathTest.test_unlinkc                 C   s*   |  td }| |j |jdd d S )NfileAAAT)
missing_ok)ra   r  r  r]  rc   r   r   r   test_unlink_missing_ok2  s    z$_BasePathTest.test_unlink_missing_okc                 C   sH   |  td }| D ]}|  q|  | |j | |j d S )Nr  )ra   r  r  r]  rmdirr  r  r  r   r   r   
test_rmdir7  s    
z_BasePathTest.test_rmdirlinkzos.link() is not presentc              
   C   s   |  t}|d }| j}|d d }z|| W n2 tyh } z| d|  W Y d }~n
d }~0 0 | | j| | tj	
||d | |j td}|| | t|j| | |j d S )Nr  r  fileAAzos.link(): %sTr_  )ra   r  r  st_sizelink_toPermissionErrorr  r   r   r  r  r   rel_join)r   rj   rd   sizer   er   r   r   r   test_link_to?  s    

$
z_BasePathTest.test_link_tozos.link() is presentc                 C   sV   |  t}|d }|d d }| t || W d    n1 sH0    Y  d S )Nr  r  re  )ra   r  r   r  rg  r   rj   rd   r   r   r   r   test_link_to_not_implementedS  s
    
z*_BasePathTest.test_link_to_not_implementedc                 C   s   |  t}|d }| j}|d d }||}| || | | j| | |j td}||}| ||  | | t|j| | |j d S )Nr  r  re  r_  )	ra   r  r  rf  renamer   r  ri  r   )r   rj   rd   rj  r   Z	renamed_pr   Z	renamed_qr   r   r   test_rename\  s    



z_BasePathTest.test_renamec                 C   s   |  t}|d }| j}|d d }||}| || | | j| | |j tdd}||}| ||  | | t|j| | |j d S )Nr  r  re  r  r  )	ra   r  r  rf  r
   r   r  ri  r   )r   rj   rd   rj  r   Z
replaced_pr   Z
replaced_qr   r   r   test_replacem  s    




z_BasePathTest.test_replacec                 C   s   |  t}| |d  |  d | |d  |  d | |d  |  d | t |d   W d    n1 s0    Y  d S )Nr  r  r  r  r  r  )ra   r  r   readlinkr   r  r   r   r   r   test_readlink~  s    
z_BasePathTest.test_readlinkc                 C   s   |  t}|d }| |  |  | |  | }|j}|j}t	
t||d |d f |  | }| |j| | |j| |d }| |  |jddd | |  | jt|jdd d S )NZnewfileA
   ZnewfileBi  F)rJ  exist_okru  )ra   r  r   r  r,  r   r  st_mtimest_mtime_nsr   utimerp   r.  r   r  )r   rj   rd   rM  Z	old_mtimeZold_mtime_nsr   r   r   test_touch_common  s$    
z_BasePathTest.test_touch_commonc                 C   s\   |  t}|d }|  |d$}| |  d W d    n1 sN0    Y  d S )Nr  r  r  )ra   r  r,  r  r   r  r  )r   rj   rd   r   r   r   r   test_touch_nochange  s
    
z!_BasePathTest.test_touch_nochangec                 C   s   |  t}|d }| |  |  | |  | |  | t}|  W d    n1 sl0    Y  | 	|j
jtj d S )NZnewdirA)ra   r  r   r  r  r   is_dirr   r  r   r  r  EEXIST)r   rj   rd   r  r   r   r   
test_mkdir  s    
&z_BasePathTest.test_mkdirc                 C   s^  |  tdd}| |  | t}|  W d    n1 sD0    Y  | |jj	t	j
 |jdd | |  | |  | t}|jdd W d    n1 s0    Y  | |jj	t	j t| j}|  tdd}|jddd | |  | |  tjdkr@| t| jd	|@  | t|j j| d S )
NZnewdirBnewdirCTr  ZnewdirDZnewdirEim  r  im  )ra   r  r   r  r   r  r  r   r  r  r  r   r|  r}  r  S_IMODErI  r   r   r   )r   rd   r  rJ  r   r   r   test_mkdir_parents  s&    &*z _BasePathTest.test_mkdir_parentsc                 C   s   |  td}| j}| |  | |  | t}|	  W d    n1 sZ0    Y  | 
|jjtj |j	dd | |  | 
| j| d S )Nr  Trv  )ra   r  r  st_ctimer   r  r|  r   FileExistsErrorr  r   r  r  r}  )r   rd   st_ctime_firstr  r   r   r   test_mkdir_exist_ok  s    
&z!_BasePathTest.test_mkdir_exist_okc                 C   s  |  td}| |  | t}|  W d    n1 sB0    Y  | |jj	t	j
 |d }|jdd | j}| |  | t}|jdd W d    n1 s0    Y  | |jj	t	j
 |jddd | |  | | j| d S )Nr  r  Tr  r   ru  )ra   r  r   r  r   r  r  r   r  r  r}  r  r  )r   rd   r  r  r   r   r   test_mkdir_exist_ok_with_parent  s    &
*z-_BasePathTest.test_mkdir_exist_ok_with_parentc                 C   s2   |  d jdd |  d jddd d S )Nr   Trv  r  )ra   r2  r  rx   r   r   r   test_mkdir_exist_ok_root  s    z&_BasePathTest.test_mkdir_exist_ok_rootc                 C   sp   dD ]}|  |d }| s q.q| d | t$ |d d jdd W d    n1 sb0    Y  d S )NZZYXWVUTSRQPONMLKJIHGFEDCBAz:\z&cannot find a drive that doesn't existchildr  Tr  )ra   r|  r  r   r  r  )r   r#   rd   r   r   r   test_mkdir_with_unknown_drive  s    
z+_BasePathTest.test_mkdir_with_unknown_drivec                 C   s   |  tdd}| |  | t}|jdd W d    n1 sH0    Y  | |jj	t	j
 | t}|jddd W d    n1 s0    Y  | |jj	t	j
 d S )Nr  r  Tr  r  ra   r  r   r  r   r  r  r   r  r  r}  r  r   r   r   test_mkdir_with_child_file  s    *,z(_BasePathTest.test_mkdir_with_child_filec                 C   s   |  td}| |  | t}|  W d    n1 sB0    Y  | |jj	t	j
 | t}|jdd W d    n1 s0    Y  | |jj	t	j
 d S )Nr  Trv  r  r  r   r   r   test_mkdir_no_parents_file  s    &*z(_BasePathTest.test_mkdir_no_parents_filec              	      s   t dD ]ډ| td }| |  d fdd	}fddt dD t  |d	 d
 }z>td| |jddd W d    n1 s0    Y  W n" t	y   | 
t|  Y n0 | t|  | |  qd S )N    zdirCPC%dr  c                    s6   t | }  r&t| |  |  t| | d S rm   )rp   popr   r  add)r  rJ  )concurrently_createdr   r   r   my_mkdir  s
    
zE_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.my_mkdirc                    s   g | ]}t  d |> @ qS )r   )bool)r   n)pattern_numr   r   r   !  r   zG_BasePathTest.test_mkdir_concurrent_parent_creation.<locals>.<listcomp>   Zdir1Zdir2zpathlib._normal_accessor.mkdirTFr  )r  )r  ra   r  r   r  r  r   r.  r  r  r  rp   ZassertNotInr   )r   rd   r  Zp12r   )r  r   r  r   %test_mkdir_concurrent_parent_creation  s    0z3_BasePathTest.test_mkdir_concurrent_parent_creationc                 C   s  |  t}|d }|d d }|| | | |  | | |  |d d }|t| | | |  | | |  | |	  |d }|d d }|j|dd | | |  | | |  | 
|	  | 
t|  d S )	Nr  r  ZlinkAAZlinkAAAr  ZlinkAAAATr  )ra   r  r-  r   r  r   rO  rp   r   r|  r   r   r  )r   rj   targetrd  r   r   r   test_symlink_to-  s$    

z_BasePathTest.test_symlink_toc                 C   s   |  t}| |d   | |d   | |d   | |d d   t r| |d   | |d   | |d  d | |d	  d | |d
  d d S )Nr  r  r  r  r  r  r  Fu   dirAzdirA )ra   r  r   r|  r   r   r  rr   r   r   r   r   test_is_dirE  s    
z_BasePathTest.test_is_dirc                 C   s   |  t}| |d   | |d   | |d   | |d d   t r| |d   | |d   | |d   | |d  d	 | |d
  d	 d S )Nr  r  r  r  r  r  r     fileAFfileA )ra   r  r   is_filer   r   r  rr   r   r   r   r   test_is_fileR  s    
z_BasePathTest.test_is_filec                 C   s   |  t}|  d}| |d   | |d   | |d   | |d d   | |  t r| |d   | |  d d | |  d	 d d S )
Nr   r  r  r  r  r  u   /Fz/ )ra   r  r   is_mountr   r   r  rr   )r   rj   Rr   r   r   test_is_mount_  s    

z_BasePathTest.test_is_mountc                 C   s   |  t}| |d   | |d   | |d   | |d d   t r| |d   | |d   | |d   | |d  d	 | |d
  d	 t r| |d  d	 | |d  d	 d S )Nr  r  r  r  r  r  r  r  Fr  u   linkAzlinkA )	ra   r  r   
is_symlinkr   r  r   rr   r  r   r   r   r   test_is_symlinkm  s    
z_BasePathTest.test_is_symlinkc                 C   s   |  t}| |d   | |d   | |d   | |d d   | |d  d | |d  d d S Nr  r  r  r  r  Fr  )ra   r  r   is_fiforr   r   r   r   r   test_is_fifo_false}  s    
z _BasePathTest.test_is_fifo_falsemkfifozos.mkfifo() requiredc              
   C   s   |  td}ztt| W n2 tyP } z| d|  W Y d }~n
d }~0 0 | |  | 	|
  | 	|  | |  td d | |  td d d S )NZmyfifozos.mkfifo(): %su	   myfifoFzmyfifo )ra   r  r   r  rp   rh  r  r   r  r   	is_socketr  rr   )r   rj   rk  r   r   r   test_is_fifo_true  s    $z_BasePathTest.test_is_fifo_truec                 C   s   |  t}| |d   | |d   | |d   | |d d   | |d  d | |d  d d S r  )ra   r  r   r  rr   r   r   r   r   test_is_socket_false  s    
z"_BasePathTest.test_is_socket_falseAF_UNIXzUnix sockets requiredc              
   C   s   |  td}ttjtj}| |j z|t| W nL t	y } z4t
|ts`dt|v rr| dt|  W Y d }~n
d }~0 0 | |  | |  | |  | |  td d | |  td d d S )NZmysockzAF_UNIX path too longzcannot bind Unix socket: u	   mysockFzmysock )ra   r  socketr  SOCK_STREAMr  closebindrp   r  
isinstancerh  r  r   r  r   r  r  rr   )r   rj   sockrk  r   r   r   test_is_socket_true  s    

(z!_BasePathTest.test_is_socket_truec                 C   s   |  t}| |d   | |d   | |d   | |d d   | |d  d | |d  d d S r  )ra   r  r   is_block_devicerr   r   r   r   r   test_is_block_device_false  s    
z(_BasePathTest.test_is_block_device_falsec                 C   s   |  t}| |d   | |d   | |d   | |d d   | |d  d | |d  d d S r  )ra   r  r   is_char_devicerr   r   r   r   r   test_is_char_device_false  s    
z'_BasePathTest.test_is_char_device_falsec                 C   sv   |  d}| s| d | |  | |  | |  | |  d d | |  d d d S )Nz	/dev/nullz/dev/null requiredu   /dev/nullFz
/dev/null )	ra   r  r  r   r  r   r  r  rr   r   r   r   r   test_is_char_device_true  s    

z&_BasePathTest.test_is_char_device_truec                 C   sP   |  td}tdtjd D ].}t||}t|}| | |  qd S )Nr  r   r   )	ra   r  r  r  r  r  r  r   r  )r   rd   r	  r
  r}   r   r   r   r    s
    
z"_BasePathTest.test_pickling_commonc                 C   sJ   | j }|d}|d}| |jd |jd  | |jd |jd  d S )Nz/usr/bin/fooz/usr/local/binr   r   r   )ra   rr   rq   rm  r   r   r   test_parts_interning  s
    z"_BasePathTest.test_parts_interningc              	   C   s  |  t}| tjddtd | tjddtd | tjddtd | |td |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 W t| nt| 0 d S )NZlink0Zlink1Zlink2Zlink3)ra   r  r  r   r  r  r2  r   r  rp   r  chdir)r   Zlink0_targetrj   rd   Zold_pathr   r   r   _check_complex_symlinks  sB    

z%_BasePathTest._check_complex_symlinksc                 C   s   |  t d S rm   )r  r  rx   r   r   r   test_complex_symlinks_absolute	  s    z,_BasePathTest.test_complex_symlinks_absolutec                 C   s   |  d d S )Nr%   )r  rx   r   r   r   test_complex_symlinks_relative	  s    z,_BasePathTest.test_complex_symlinks_relativec                 C   s   |  tjdd d S )Nr  r   )r  r   r  r  rx   r   r   r   &test_complex_symlinks_relative_dot_dot	  s    z4_BasePathTest.test_complex_symlinks_relative_dot_dotN)T)[r.   r/   r0   __doc__re   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   skip_unless_symlinkr  r  r  r  r  r$  r%  r1  r4  r<  r?  r@  rF  rG  rK  rN  rP  rQ  unittest
skipUnlessrS  r  rY  r  r^  ra  rc  hasattrrl  skipIfrn  rp  rq  rs  rz  r{  r~  r  r  r  r  only_ntr  r  r  r  r  r  r  
only_posixr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r  <  s   

	




$

;
	









	



	
	
			)

r  c                   @   s2   e Zd ZejZdd Zdd Zdd Zdd Z	d	S )
PathTestc                 C   s   |  | jt | j d S rm   )rr   ra   rp   rx   r   r   r   test_class_getitem	  s    zPathTest.test_class_getitemc                 C   s0   |  d}| t|tjdkr$tjntj d S r  )ra   rr   rs   r   r   rF   r  r  rc   r   r   r   r  	  s    

zPathTest.test_concrete_classc                 C   s,   t jdkr| ttj n| ttj d S )Nr  )r   r   r   r  rF   r  r  rx   r   r   r   test_unsupported_flavour	  s    
z!PathTest.test_unsupported_flavourc                 C   sF   |   }| td t|d W d    n1 s80    Y  d S )NzUnacceptable patternr   )ra   ZassertRaisesRegexr   r   r  rc   r   r   r   test_glob_empty_pattern!	  s    z PathTest.test_glob_empty_patternN)
r.   r/   r0   rF   Pathra   r  r  r  r  r   r   r   r   r  	  s
   r  c                   @   s   e Zd ZejZddddZdd Zdd Zd	d
 Z	e
jdd Zdd Zdd Zeeedddd Zeejdkddd ZdS )PosixPathTestTr5  c                G   sF   | j | }| t t|| W d    n1 s80    Y  d S rm   )ra   r   RuntimeErrorprintr2  )r   r3  rt   r  r   r   r   _check_symlink_loop+	  s    
z!PosixPathTest._check_symlink_loopc                 C   s   t d}| t j| | t}|d d W d    n1 sF0    Y  t td}| t	|j
d t d |d d W d    n1 s0    Y  t td}| t	|j
d d S )Nr   new_filer       other_new_file  )r   umaskr  ra   r  r  r  r  r   r  rI  r   Zold_maskrd   rM  r   r   r   test_open_mode0	  s    


zPosixPathTest.test_open_modec              	   C   sP   t  }z6t d | d}| t| d W t | nt | 0 d S )Nr   r7  z/spam)r   r  r  ra   r   rp   r2  )r   Zcurrent_directoryrd   r   r   r   test_resolve_root>	  s    

zPosixPathTest.test_resolve_rootc                 C   s   t d}| t j| | t}|d   t td}| t	|j
d t d |d   t td}| t	|j
d |d jdd	 t td}| t	|j
d d S )
Nr   r  r  r  r  r  Zmasked_new_filei  )rJ  )r   r  r  ra   r  r,  r  r  r   r  rI  r  r   r   r   test_touch_modeG	  s    


zPosixPathTest.test_touch_modec                 C   s   t dtd | td t dtd | td t dtd | td | jtdddd t td	td
 | td
 t tdtd | td t tdtd | td | jtdddd d S )NzlinkX/insider9  r:  zlinkZ/../linkZZlinkZr  Fr5  zlinkU/insideZlinkUZlinkVzlinkW/../linkWZlinkW)r   r  r  r  r  rx   r   r   r   test_resolve_loopV	  s    zPosixPathTest.test_resolve_loopc                 C   sX   | j }|t}t|d}tts,t n|}| || | t|dt  d S )NFILEazFILEa*)ra   r  r  r  r   fs_is_case_insensitiver   r   rj   rd   r  r  r   r   r   	test_globk	  s    zPosixPathTest.test_globc                 C   sZ   | j }|td}t|d}tts.t n|}| || | t|dt  d S )Nr  FILEdzFILEd*)ra   r  r  r  r   r  r   r  r   r   r   
test_rglobs	  s    
zPosixPathTest.test_rglobgetpwallz%pwd module does not expose getpwall()c                 C   sP  | j }td dd l}|t }|j}|j	dp:d}|
 D ]&}|j}|j	d}||krD|rD qtqD|}|}d}z||r|d7 }qzW n ty   Y n0 |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 W d    n1 sB0    Y  d S )NrS  r   r   ZfakeuserrB  z~/Documentsr  z
/Documentsr  r  r   r  Z	Documentsz/tmpz/tmp/Documents)ra   r   import_modulerS  rT  r   getuidrU  pw_dirrstripr  getpwnamrV  r  r  r   r  r   r  )r   rj   rS  ZpwdentusernameuserhomeZ	othernameZ	otherhomeZfakenamep1p2p3p4p5p6Zp7r  r   r   r   test_expanduser{	  sV    

zPosixPathTest.test_expanduserdarwinz1Bad file descriptor in /dev/fd affects only macOSc              
   C   s   zxt tdddd  }|s,| d |D ]D}|  |  |  |  |	  |
  |  |  q0W n< ty } z$|jtjkr| d  W Y d }~n
d }~0 0 d S )Nz/dev/fdr  r   z.no file descriptors - issue was not reproducedz Bad file descriptor not handled.)r   rF   r  r  r  r  r|  r  r  r  r  r  r  r  r  EBADFZfail)r   Zfile_descriptorsr   rk  r   r   r   test_handling_bad_descriptor	  s"    

z*PosixPathTest.test_handling_bad_descriptorN)r.   r/   r0   rF   r  ra   r  r  r  r  r   r  r  r  r  r  r  r  rS  r  r  sysplatformr  r   r   r   r   r  '	  s"   	

5r  c                   @   s*   e Zd ZejZdd Zdd Zdd ZdS )WindowsPathTestc                 C   s   | j }|t}| t|d|tdh | t|d|tdh | ttt|d| dh | ttt|d| dh d S )Nr  r  zF*az\FILEaz\fileA)ra   r  r   r  r  maprp   ri   r   r   r   r  	  s    $zWindowsPathTest.test_globc                 C   sV   | j }|td}| t|d|tdh | ttt|d| dh d S )Nr  r  r  z\dirD\FILEd)ra   r  r   r  r  r  rp   ri   r   r   r   r  	  s    
zWindowsPathTest.test_rglobc              
      sl  j  t Fdd  dd  dd  dd  dd<  d d d	 d
 d dtj tj tj        f	dd}dd< |  dd< dd< |  dd  dd  dd< |  dd< |  W d    n1 s^0    Y  d S )Nr  r  HOMEPATH	HOMEDRIVEaliceUSERNAMEz~/My Documentsz~alice/My Documentsz~bob/My Documentsz/~/My Documentszd:~/My Documentsr   c                      s    dd    d tj dd<   d   d       d S )Nr  zC:/Users/alice/My Documentsr  zC:/Users/bob/My Documents)r  r   r  r   rV  r   	rj   r  r  r  r  r  r  r  r   r   r   r,   	  s    


z.WindowsPathTest.test_expanduser.<locals>.checkzC:\Users\alicezC:\zUsers\alicezC:\Users\eve)ra   r   r  r  r   r  r  r   r9   r   r  r   r  	  s>    zWindowsPathTest.test_expanduserN)	r.   r/   r0   rF   r  ra   r  r  r  r   r   r   r   r  	  s   r  c                   @   s.   e Zd ZdZG dd dZdd Zdd ZdS )	CompatiblePathTestz|
    Test that a type can be made compatible with PurePath
    derivatives by implementing division operator overloads.
    c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	zCompatiblePathTest.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.
        c                 C   s
   || _ d S rm   )string)r   r  r   r   r   __init__
  s    z&CompatiblePathTest.CompatPath.__init__c                 C   s   t | | j d| S r   rs   r  r   r*  r   r   r   __truediv__"
  s    z)CompatiblePathTest.CompatPath.__truediv__c                 C   s   t | | d| j S r   r  r  r   r   r   __rtruediv__%
  s    z*CompatiblePathTest.CompatPath.__rtruediv__N)r.   r/   r0   r  r  r   r  r   r   r   r   
CompatPath
  s   r  c                 C   sl   t d| d }| || j | |jd | t t dd  W d    n1 s^0    Y  d S )Ntestrightz
test/rightrt  )rF   r  r  rh   r   r  r   r   r   resultr   r   r   test_truediv(
  s
    zCompatiblePathTest.test_truedivc                 C   sl   |  dtd }| || j  | |jd | t dtd  W d    n1 s^0    Y  d S )Nleftr  z	left/testrt  )r  rF   r  rh   r   r  r   r   r  r   r   r   test_rtruediv1
  s
    z CompatiblePathTest.test_rtruedivN)r.   r/   r0   r  r  r  r	  r   r   r   r   r  
  s   	r  __main__)0collections.abcr  r  r   r  r  rF   r  r  r  r=  r  r   r  r   Ztest.supportr   r   rY  rS  ImportErrorobjectr   ZTestCaser1   rH   rZ   r  r&  r  r  realpathr  r  ri  r  r   r  r  r  r  r  r  r  r  r  r.   mainr   r   r   r   <module>   s|   )$B    L           [ #G)
