
    z%i                        d dl Z d dlZd dlZd dlZd dlmZmZmZmZ d dlm	Z	 d dl
mZ d dl
mZ d dlmZ d dlmZ 	 d dlZ eej$                        Zd Zd	 Z G d
 dej,                        Z G d de	j0                  ej,                        Z G d dej,                        Zedk(  r ej8                          yy# e$ r dZY w xY w)    N)realpathabspathdirnamebasename)test_genericpath)import_helper)	os_helper)FakePath)mockc                 V    dt         v }d}|  t        j                  |      |       g|   S )z
    On Windows, posixpath.abspath still returns paths with backslashes
    instead of posix forward slashes. If this is the case, several tests
    fail, so skip them.
    \z'ABSTFN is not a posix path - tests fail)ABSTFNunittestskip)testfound_backslashmsgs      G/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/test/test_posixpath.py!skip_if_ABSTFN_contains_backslashr      s3     fnO
3C$(--$T*+O<<    c                 N    	 t        j                  |        y # t        $ r Y y w xY wN)osrmdirOSError)r   s    r   
safe_rmdirr   !   s%    
 s    	$$c                   T   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zej"                  d        Z ej(                  edu d      d        Z ej(                  edu d      d        Zd Zd Zd Z ej(                  ej8                  dk(  d      d        Zg dZd Ze d        Z!e d        Z"ej"                  e d               Z#ej"                  e d               Z$ej"                  e d               Z%ej"                  e d                Z&ej"                  e d!               Z'ej"                  e d"               Z(ej"                  e d#               Z)ej"                  e d$               Z*ej"                  e d%               Z+ej"                  e d&               Z,d' Z-d( Z.d) Z/y)*PosixPathTestc                 $    | j                          y r   )tearDownselfs    r   setUpzPosixPathTest.setUp)   s    r   c                     dD ]D  }t        j                  t         j                  |z          t        t         j                  |z          F y )N) 12)r	   unlinkTESTFNr   )r"   suffixs     r   r    zPosixPathTest.tearDown,   s=    $ 	2FY--67y''&01	2r   c                    | j                  t        j                  dddd      d       | j                  t        j                  ddd      d       | j                  t        j                  ddd	      d
       | j                  t        j                  dddd      d       | j                  t        j                  ddd      d       | j                  t        j                  ddd      d       y )N/foobar/barbaz/bar/bazz/foo/bar/bazz/foo/zbar/zbaz/z/foo/bar/baz/   /foo   bars   /bars   bazs   /bar/bazs   /foo/bar/bazs   /foo/s   bar/s   baz/s   /foo/bar/baz/)assertEqual	posixpathjoinr!   s    r   	test_joinzPosixPathTest.test_join1   s    vuE#	%u=~N@(	* 	&I$	&@(	*'7C)	+r   c                    | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d	      d
       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y )N/foo/bar)r,   r-   /)r9   r%   foo)r%   r:   ////foo)////r:   
//foo//bar)//foor-      /foo/bar)r1   r2      /)r@   r      foo)r   rA      ////foo)   ////rA   
   //foo//bar)   //foor2   )r3   r4   splitr!   s    r   
test_splitzPosixPathTest.test_split?   s    4oF-y9/=3_E68HI57HI.<0-@46GH79KLr   c                 x   | j                  t        j                  |      ||f       | j                  t        j                  d|z         d|z   |f       | j                  t        j                  d|z         d|z   |f       | j                  t        j                  d|z         d|z   |f       | j                  t        j                  d|z         d|z   |f       | j                  t        j                  |dz         ||z   dz   df       t        |d      }t        |d      }t        |d      }| j                  t        j                  |      ||f       | j                  t        j                  d|z         d|z   |f       | j                  t        j                  d|z         d|z   |f       | j                  t        j                  d	|z         d	|z   |f       | j                  t        j                  d
|z         d
|z   |f       | j                  t        j                  |dz         ||z   dz   df       y )Nr9   zabc/zabc.def/z	/abc.def/r%   ASCIIr@   s   abc/s   abc.def/s	   /abc.def/r   )r3   r4   splitextbytes)r"   pathfilenameexts       r   splitextTestzPosixPathTest.splitextTestL   s%   ++D1Hc?C++C$J7#.#9NO++FTM: 8+S1	3++J,=>$x/5	7++K$,>?%0#6	8++D3J7"S.3.3	5 T7#7+C!++D1Hc?C++D4K8/3/	1++GdN;!H,c2	4++K$,>?%0#6	8++L4,?@&137	9++D4K8"S.4/5	7r   c                    | j                  ddd       | j                  ddd       | j                  ddd       | j                  dd	d
       | j                  ddd       | j                  ddd       | j                  ddd       | j                  ddd       | j                  ddd       | j                  ddd       | j                  ddd       | j                  ddd       y )Nzfoo.barr:   z.barzfoo.boo.barzfoo.boozfoo.boo.biff.barzfoo.boo.biffz.csh.rcz.cshz.rcnodotsr%   z.cshrcz...manydotsz...manydots.extz.ext...z........)rO   r!   s    r   test_splitextzPosixPathTest.test_splitexth   s    )UF3-F;,nfE)VU3(Hb1(Hb1-;+]FC#sB'$b)*j"5"b"%r   c                    t         j                  }| 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"       | j                   |d#      d$       y )%Nr%   )r%   r%   r%   a)r%   r%   rV   a/b)r%   r%   rW   a/b/)r%   r%   rX   /a)r%   r9   rV   /a/b)r%   r9   rW   z/a/b/)r%   r9   rX   //a)r%   //rV   z///a)r%   r9   r[   z///a/b)r%   r9   z//a/bc:/a/b)r%   r%   r]   \/a/b)r%   r%   r^   \a\b)r%   r%   r_   r   )r   r   r      a)r   r   r`      /a)r   r@   r`      //a)r   s   //r`   s   ///a)r   r@   rb   )r4   	splitrootr3   r"   fs     r   test_splitrootzPosixPathTest.test_splitrootv   s   2-3/5?36$454.16$457%67 	5?36$458&898&898&898&89314"235#456$677%89r   c                    | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d	      d       | j                  t        j                  d
      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y )Nr%   Fr9   Tr,   r8   zfoo/barr   r@   r1   r?   s   foo/bar)assertIsr4   isabsr!   s    r   
test_isabszPosixPathTest.test_isabs   s    ioob)51iooc*D1ioof-t4iooj148iooi0%8iooc*E2iood+T2ioog.5iook2D9iooj159r   c                    | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d	       | j                  t        j                  d
      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d	       y )Nr8   r-   r9   r%   r:   r;   r=   r?   r2   r@   r   rA   rB   rD   )r3   r4   r   r!   s    r   test_basenamezPosixPathTest.test_basename   s   ++J7?++C0"5++E2E:++I6>++L95A++K8&A++D137++F3V<++J7@++M:FCr   c                    | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d	       | j                  t        j                  d
      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y )Nr8   r,   r9   r:   r%   r;   r<   r=   r>   r?   r1   r@   rA   r   rB   rC   rD   rE   )r3   r4   r   r!   s    r   test_dirnamezPosixPathTest.test_dirname   s   **:6?**3/5**5126**95v>**<8'B**;7A**40$7**62C8**:6@**=98Dr   c                 b   | j                  t        j                  t        j                  dz         d       | j                  t        j
                  t        j                  dz         d       t        t        j                  dz   d      5 }|j                  d       d d d        | j                  t        j                  t        j                  dz         d       t        j                         r6t        j                  t        j                  dz   t        j                  dz          | j                  t        j                  t        j                  dz         d       t        j                  t        j                  dz          | j                  t        j                  t        j                  dz         d       | j                  t        j                  t        j                  dz         d       | j                  t        j
                  t        j                  dz         d       | j                  t        j                  t        j                  dz         d       | j                  t        j                  t        j                  t        j                        dz         d       | j                  t        j                  t        j                  d	z         d       | j                  t        j                  t        j                  t        j                        d
z         d       y # 1 sw Y   xY w)Nr&   Fr'   wbrA   Tu           )rh   r4   islinkr	   r)   lexistsopenwritecan_symlinkr   symlinkremoveexistsfsencoderd   s     r   test_islinkzPosixPathTest.test_islink   s    i&&y'7'7#'=>Fi''	(8(83(>?G)""S($/ 	1GGFO	i&&y'7'7#'=>F  "JJy''#-y/?/?#/EFMM)**9+;+;c+ABDIIIi&&,-MM)**9+;+;c+ABDIMM)**9+;+;c+ABEJMM)++I,<,<s,BCTJi&&y'7'7('BCUKi&&r{{93C3C'Dw'NOQVWi&&y'7'7&'@A5Ii&&r{{93C3C'Dw'NOQVW	 	s   
L$$L.c                 P   | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  t        d            d       | j                  t        j                  t        d            d       y )Nr9   Tr@   )rh   r4   ismountr
   r!   s    r   test_ismountzPosixPathTest.test_ismount   sn    i'',d3i''-t4i''6=i''7>r   c                 J   | j                  t        j                  t              d       	 t	        j
                  t               | j                  t        j                  t              d       t        t               | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y # t        t               w xY w)NFu   /s   /z/ s   / )rh   r4   r   r   r   mkdirr   r!   s    r   test_ismount_non_existentz'PosixPathTest.test_ismount_non_existent   s    i''/7	HHVMM)++F3U;vi''	2E:i''159i''0%8i''159 vs   AD D"c                     	 t        j                  dt               | j                  t	        j
                  t              d       t        j                  t               y # t        j                  t               w xY w)Nr9   F)r   ry   r   rh   r4   r   r(   r!   s    r   test_ismount_symlinksz#PosixPathTest.test_ismount_symlinks   sG    	JJsF#MM)++F3U;IIfBIIfs   AA A:NzTest requires posix modulec                     t         j                  }d }	 |t         _        | j                  t        j                  t
              d       |t         _        y # |t         _        w xY w)Nc                 b    d}d}| t         k(  rd}d}t        j                  d||dddddddf
      S )Nr      )r   posixstat_resultrL   st_inost_devs      r   
fake_lstatz?PosixPathTest.test_ismount_different_device.<locals>.fake_lstat   sC    FFv~$$aAq!Q1%MNNr   Tr   lstatrh   r4   r   r   r"   
save_lstatr   s      r   test_ismount_different_devicez+PosixPathTest.test_ismount_different_device   sG     XX
	O	"!BHMM)++F3T:!BHzBH   4A A"c                     t         j                  }d }	 |t         _        | j                  t        j                  t
              d       |t         _        y # |t         _        w xY w)Nc                     d}d}| j                  t              r| t        k7  rt        d      | t        k(  rd}d}t        j                  d||dddddddf
      S )Nr   z!Fake [Errno 13] Permission deniedr   )
startswithr   r   r   r   r   s      r   r   zEPosixPathTest.test_ismount_directory_not_readable.<locals>.fake_lstat   sc    FFv&46> ABBv~$$aAq!Q1%MNNr   Tr   r   s      r   #test_ismount_directory_not_readablez1PosixPathTest.test_ismount_directory_not_readable   sG     XX

	O	"!BHMM)++F3T:!BHzBHr   c                 T    | j                  t        j                  t                     y r   )assertFalser4   
isjunctionr   r!   s    r   test_isjunctionzPosixPathTest.test_isjunction  s    --f56r   c                     | j                  t        j                  d      d       | j                  t        j                  d      d       y )Nr:   rA   )r3   r4   
expanduserr!   s    r   test_expanduserzPosixPathTest.test_expanduser  s8    --e4e<--f5v>r   c                 D   t        j                         5 }d|d<   | j                  t        j                  d      d       d|d<   | j                  t        j                  d      d       dD ]  }| j                  |      5  ||d<   | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d	      d
       d d d         	 d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nz/home/victorHOME~z/home/victor/)r9   r%   r\   ///)homer9   ~/z~/foor,   )r	   EnvironmentVarGuardr3   r4   r   subTest)r"   envr   s      r   test_expanduser_home_envvarz)PosixPathTest.test_expanduser_home_envvar  s   **, 	L(CKY11#6G *CKY11#6G, L\\t\, L"&CK$$Y%9%9#%>D$$Y%9%9$%?E$$Y%9%9'%BFK	L LL	L 	LL L	L 	Ls%   A,DA5D
6
D
DDDvxworkszno home directory on VxWorksc           	         t        j                  d      }| j                  t        j                  d      t
               | j                  t        j                  d      t               t        j                  d      dk7  rv| j                  t        j                  d      dz   t        j                  d             | j                  t        j                  d      dz   t        j                  d             | j                  t        j                  d      t
               | j                  t        j                  d	      t
               | j                  t        j                  d
      t               | j                  t        j                  d      t               t        j                         5 }|d= |j                  t        j                               j                  }|j                  d      xs d}| j                  t        j                  d      |       t        j                   j#                  |dt$              5  t        j                   j#                  |dt$              5  dD ]'  }| j                  t        j                  |      |       ) 	 d d d        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Npwdr   s   ~/r   r9      ~r@   z~root/z~foo/s   ~root/s   ~foo/r   getpwuid)side_effectgetpwnam)r   z~/.localz
~vstinner/)r   import_moduleassertIsInstancer4   r   strrK   r3   r	   r   r   r   getuidpw_dirrstripr   patchobjectKeyError)r"   r   r   r   rL   s        r   test_expanduser_pwdz!PosixPathTest.test_expanduser_pwd(  s;    ))%0i2248#>i22595A $+$$S)C/$$T* $$T*T1$$U+ 	i228<cBi227;SAi229=uEi228<eD**, 	GF<<		,33D;;s#*sDY11#6= ""3
"I G""3
"IG; GD$$Y%9%9$%?FGG G	G 	GG G G G	G 	Gs=   .BK?'J9&-J-J9K-J62J99K	>KK)0)r%   rR   )r9   r9   )z/.r9   )z/./r9   )z/.//.r9   )r,   r,   )r8   r8   )r\   r\   )r   r9   )z///foo/.//bar//r8   )z///foo/.//bar//.//..//.//baz///z/foo/baz)z///..//./foo/.//barr8   )rR   rR   )z.//.rR   )rS   rS   )../rS   )../foor   )	../../foor   )z../foo/../barz../bar)z../../foo/../bar/./baz/boom/..../../bar/bazz/..r9   r   )z/../r9   )z/..//r9   )z//.r\   )z//..r\   )//...r   )z//../foor>   )z//../../foor>   )z/../foor,   )z
/../../foor,   )z/../foo/../r9   )z/../foo/../barr.   )z/../../foo/../bar/./baz/boom/..r0   )z/../../foo/../bar/./baz/boom/.z/bar/baz/boom)zfoo/../bar/bazzbar/baz)zfoo/../../bar/bazz
../bar/baz)zfoo/../../../bar/bazr   )zfoo///../bar/.././../baz/boomz../baz/boom)zfoo/bar/../..///../../baz/boomz../../baz/boom)z/foo/..r9   )z
/foo/../..r9   )z//foo/..r\   )z//foo/../..r\   )z	///foo/..r9   )z///foo/../..r9   )z
////foo/..r9   )z/////foo/..r9   c                    | j                   D ]  \  }}| j                  |      5  t        j                  |      }| j	                  ||       d d d        |j                  d      }|j                  d      }| j                  |t              5  t        j                  |      }| j	                  ||       d d d         y # 1 sw Y   uxY w# 1 sw Y   xY w)Nzutf-8)type)NORMPATH_CASESr   r4   normpathr3   encoderK   )r"   rL   expectedresults       r   test_normpathzPosixPathTest.test_normpath  s    "11 		3ND(d# 3"++D1  23 ;;w'Dw/Hd/ 3"++D1  23 3		33 33 3s   (C (C C		C	c                 l   | j                  t        d      t        j                                | j                  t        d      t        j                                | j                  t        dj	                  dgdz              t        j                                | j                  t        d      t        j
                                | j                  t        d      t        j
                                | j                  t        dj	                  dgdz              t        j
                                y )NrR   z./.r9   d      .s   ./.r@   )r3   r   r   getcwdr5   getcwdbr!   s    r   test_realpath_curdirz"PosixPathTest.test_realpath_curdir  s    #		4%"))+6#((C53;"78"))+F$6&)2::<8$))TFSL"9:BJJLIr   c           	         | j                  t        d      t        t        j                                      | j                  t        d      t        t        t        j                                            | j                  t        dj                  dgdz              d       | j                  t        d      t        t        j                                      | j                  t        d      t        t        t        j                                            | j                  t        dj                  dgdz              d       y )NrS   z../..r9   r   s   ..s   ../..r@   )r3   r   r   r   r   r5   r   r!   s    r   test_realpath_pardirz"PosixPathTest.test_realpath_pardir  s    $)=>'*GGBIIK4H,IJ#((D6C<"893?%'"**,*?@(+WWRZZ\5J-KL$))UGcM":;TBr   c                    	 t        j                  t        dz   t               | j                  t	        t              t        dz          t        j                  t               y # t        j                  t               w xY wNr&   )r   ry   r   r3   r   r	   r(   r!   s    r   test_realpath_basicz!PosixPathTest.test_realpath_basic  sO    	%JJvcz6*Xf-vcz:V$IV$s   AA# #A>c                 @   	 t        j                  t        dz   t               | j                  t        t
        t        d       | j                  t        t
        t        dz   d       t        j                  t               y # t        j                  t               w xY w)Nr&   Tstrictr'   )r   ry   r   assertRaisesFileNotFoundErrorr   r	   r(   r!   s    r   test_realpath_strictz"PosixPathTest.test_realpath_strict  sk    
	%JJvcz6*/6$O/6C<PTUV$IV$s   A&B Bc                 (   	 t        j                  t        j                  t        dz         t               | j                  t        t              t        dz          t        j                  t               y # t        j                  t               w xY wr   )	r   ry   r4   relpathr   r3   r   r	   r(   r!   s    r   test_realpath_relativez$PosixPathTest.test_realpath_relative  sZ    	%JJy((4f=Xf-vcz:V$IV$s   AA6 6Bc                 	   	 t        j                  t        t               | j                  t	        t              t               t        j                  t        dz   t        dz          t        j                  t        dz   t        dz          | j                  t	        t        dz         t        dz          | j                  t	        t        dz         t        dz          | j                  t	        t        dz         t        dz          | j                  t	        t        dz         t        t                     | j                  t	        t        dz         t        t              dz          t        j                  t        dz   t        dz          | j                  t	        t        d	z   t        t              z   dz         t        dz          | j                  t	        t        d	z   t        t              z   dz         t        dz          t        j                  t        t              d
z   t        dz          | j                  t	        t        dz         t        d
z          t        j                  dt        t        t                    z   dz   t        t              z   dz   t        dz          | j                  t	        t        dz         t        dz          t        j                  t        t                    5  | j                  t	        t        t                    t               d d d        t        j                  t               t        j                  t        dz          t        j                  t        dz          t        j                  t        dz          t        j                  t        dz          t        j                  t        dz          y # 1 sw Y   xY w# t        j                  t               t        j                  t        dz          t        j                  t        dz          t        j                  t        dz          t        j                  t        dz          t        j                  t        dz          w xY w)Nr&   r'   1/x1/..1/../x/xxy1/../rW   rV   r   r9   c)
r   ry   r   r3   r   r   r   r	   
change_cwdr(   r!   s    r   test_realpath_symlink_loopsz)PosixPathTest.test_realpath_symlink_loops  s   
"	)JJvv&Xf-v6JJvcz6#:.JJvcz6#:.XfSj16#:>XfSj16#:>XfUl3VE\BXfVm4gfoFXfXo6$8NOJJvcz6#:.XfWnx7G&G#&MN#c\+XfWnx7G&G#&MN#c\+ JJx'%/<XfSj16%<@JJux883>'(*-./5cz;XfSj16#:> %%gfo6 E  (6*:!;VDE V$VCZ(VCZ(VCZ(VCZ(VCZ(E E V$VCZ(VCZ(VCZ(VCZ(VCZ(s%   K.O 0-OO OO B'Q>c                    	 t        j                  t        t               | j                  t        t
        t        d       t        j                  t        dz   t        dz          t        j                  t        dz   t        dz          | j                  t        t
        t        dz   d       | j                  t        t
        t        dz   d       | j                  t        t
        t        dz   d       | j                  t        t
        t        dz   d       | j                  t        t
        t        dz   d       t        j                  t        dz   t        d	z          | j                  t        t
        t        d
z   t        t              z   d	z   d       | j                  t        t
        t        d
z   t        t              z   dz   d       t        j                  t        t              dz   t        dz          | j                  t        t
        t        dz   d       t        j                  dt        t        t                    z   dz   t        t              z   dz   t        dz          | j                  t        t
        t        dz   d       t        j                  t        t                    5  | j                  t        t
        t        t              d       d d d        t        j                  t               t        j                  t        dz          t        j                  t        dz          t        j                  t        d	z          t        j                  t        dz          t        j                  t        dz          y # 1 sw Y   xY w# t        j                  t               t        j                  t        dz          t        j                  t        dz          t        j                  t        d	z          t        j                  t        dz          t        j                  t        dz          w xY w)NTr   r&   r'   r   r   r   r   r   r   rW   rV   r   r9   r   )r   ry   r   r   r   r   r   r   r	   r   r(   r!   s    r   "test_realpath_symlink_loops_strictz0PosixPathTest.test_realpath_symlink_loops_strict  s   
"	)JJvv&gxEJJvcz6#:.JJvcz6#:.gxDIgxDIgxdKgxtLgxNJJvcz6#:.gx$Wnx/??#Ed  Tgx$Wnx/??#Ed  T JJx'%/<gxDIJJux883>'(*-./5cz;gxDI %%gfo6 T!!'8Xf5Ed!ST V$VCZ(VCZ(VCZ(VCZ(VCZ(T T V$VCZ(VCZ(VCZ(VCZ(VCZ(s%   J0N 2+NN NN B'P>c                 >   	 t        j                  t               t        j                  dt	        t              z   t        dz          t        j                  dt        dz          | j                  t        t        dz         t               t        j                  t        dz          t        j                  t        dz          t        t               y # t        j                  t        dz          t        j                  t        dz          t        t               w xY w)Nr   z/selfzself/self/selfz/link)
r   r   r   ry   r   r3   r   r	   r(   r   r!   s    r   (test_realpath_repeated_indirect_symlinksz6PosixPathTest.test_realpath_repeated_indirect_symlinks  s    	HHVJJux//'1ABJJ'')9:Xfw&67@Vg-.Vg-.v Vg-.Vg-.vs   B	C A	Dc                    d}	 t        j                  t               t        |      D ];  }t        j                  dj                  d|z  gdz        t        d|dz   z  z          = t        j                  dt        dz          | j                  t        t        d|z  z         t               t        j                  t              5  | j                  t        d|z        t               d d d        t        |dz         D ]!  }t        j                  t        d|z  z          # t        t               y # 1 sw Y   KxY w# t        |dz         D ]!  }t        j                  t        d|z  z          # t        t               w xY w)N
   r9   z%dz/%dr   rR   z/0)r   r   r   rangery   r5   r3   r   r	   r   r(   r   )r"   depthis      r   test_realpath_deep_recursionz*PosixPathTest.test_realpath_deep_recursion#  sB    	HHV5\ P

388TAXJO4fuA6NOPJJsFTM*Xfuu}&<=vF %%f- A  $,!7@A 519% 5  %!)!345vA A 519% 5  %!)!345vs%   CD> #D2(D> 2D;7D> >AFc                 \   	 t        j                  t               t        j                  t        dz          t        j                  t        dz   t        dz          t	        j
                  t        dz         5  | j                  t        d      t        dz          d d d        t	        j                  t        dz          t        t        dz          t        t               y # 1 sw Y   GxY w# t	        j                  t        dz          t        t        dz          t        t               w xY w)Nz/y/krV   z/y/a)
r   r   r   ry   r	   r   r3   r   r(   r   r!   s    r   test_realpath_resolve_parentsz+PosixPathTest.test_realpath_resolve_parents6  s    
	HHVHHVd]#JJv}ftm4%%ftm4 A  #@A Vd]+v}%vA A Vd]+v}%vs$   A5C, 7#C C,  C)%C, ,?D+c                 Z   	 t        j                  t               t        j                  t        dz          t        j                  t        dz          t        j                  t        dz   t        dz          | j	                  t        t        dz         t        dz          t        j                  t        t                    5  | j	                  t        t        t              dz         t        dz          d d d        t        j                  t        dz          t        t        dz          t        t        dz          t        t               y # 1 sw Y   YxY w# t        j                  t        dz          t        t        dz          t        t        dz          t        t               w xY w)Nr   z/k/yz/link-yz
/link-y/..)r   r   r   ry   r3   r   r	   r   r   r   r(   r   r!   s    r   (test_realpath_resolve_before_normalizingz6PosixPathTest.test_realpath_resolve_before_normalizingI  s"   	HHVHHVd]#HHVf_%JJv(:; Xf|&;<ftmL%%gfo6 0  (6*:\*I!J!'$00 Vi/0v'v}%v0 0 Vi/0v'v}%vs%   C E 3E5E EE AF*c                    	 t        j                  t               t        j                  t        dz          t        j                  t        t        dz          t	        j
                  t        t                    5  t        t              }| j                  t        |dz         t               | j                  t        |dz         t        dz          d d d        t	        j                  t        dz          t        t        dz          t        t               y # 1 sw Y   GxY w# t	        j                  t        dz          t        t        dz          t        t               w xY w)Nr   linkzlink/k)r   r   r   ry   r	   r   r   r   r3   r   r(   r   )r"   bases     r   test_realpath_resolve_firstz)PosixPathTest.test_realpath_resolve_firste  s    	HHVHHVd]#JJvv/%%gfo6 K'  $-!8&A  $/!:FTMJK
 Vf_-v}%vK K
 Vf_-v}%vs%   A8D# :ADD# D D# #?E"c                 j   t         j                  d c}t         _        	 t         j                  j                  t        j                               d   }| j	                  t
        t        j                  d       | j                  t        j                  d      d       | j                  t        j                  t        j                  d            d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  dd      d|z   d	z          | j                  t        j                  dd
      d|z   dz          | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  d	d	      d       | j                  t        j                  dd      d       |t         _        y # |t         _        w xY w)Nc                       y)Nz/home/user/bar r   r   r   <lambda>z,PosixPathTest.test_relpath.<locals>.<lambda>y      r   r%   rV   rW   z../a/bz../br   rY   z../crZ   zb/cz../../arR   z/foo/bar/batz/x/y/zz../../../foo/bar/batr8   batr9   zfoo/bar/batz../../..r   z../foo/bar/batz
../../../x)
r   r   rL   rF   r   
ValueErrorr4   r   r3   r   )r"   real_getcwdcurdirs      r   test_relpathzPosixPathTest.test_relpathx  se   $&II/H bi	$WW]]299;/3Fj)*;*;R@Y..s3S9Y..y/@/@/EFLY..u5u=Y..x8(CY..sF;U6\$=NOY..uf="6\&02Y..sE:IFY..sC8#>Y..~xHJ`aY..~zJERY..~sC]SY..sNCZPY..~tDFVWY..t^DlSY..sC8#>Y..tT:C@Y..vv>D#BIBIs   K:L% %L2c                    t         j                  d c}t         _        	 t         j                  j                  t        j                               d   }| j	                  t
        t        j                  d       | j                  t        j                  d      d       | j                  t        j                  t        j                  d            d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  dd      d|z   d	z          | j                  t        j                  dd
      d|z   dz          | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  dd      d       | j                  t        j                  d	d	      d       | j                  t        j                  dd      d       | j	                  t        t        j                  dd       | j	                  t        t        j                  dd       |t         _        y # |t         _        w xY w)Nc                       y)Ns   /home/user/barr   r   r   r   r   z2PosixPathTest.test_relpath_bytes.<locals>.<lambda>  r   r   r   r   r`   s   a/bs   ../a/bs   ../bs   ../ra   s   ../cs   /a/bs   b/cs   ../../ar   s   /foo/bar/bats   /x/y/zs   ../../../foo/bar/batr?   s   batr@   s   foo/bar/bats   ../../..s   /xs   ../foo/bar/bats
   ../../../xs   bytesr   )r   r   rL   rF   r   r  r4   r   r3   r   	TypeError)r"   real_getcwdbr  s      r   test_relpath_bytesz PosixPathTest.test_relpath_bytes  s   &(jj2L"rz	&WW]]2::<04Fj)*;*;SAY..t4d;Y..y/@/@/FGNY..v6?Y..y99EY..tW=#F]502Y..vw?#F]724Y..tV<jIY..tT:DAY..	JLcdY..LfUY..E~VY..t_E{SY..FHYZY..uoFVY..tT:DAY..ue<dCY..w@$Gi):):HeLi):):E8L%BJBJs   MM1 1M>c                 p     fd} fd} j                  t        t        j                  g         |t        ddg        |t        ddg        |dgd        |ddgd        |ddgd        |ddgd        |ddgd        |d	d
gd        |ddgd        |ddgd        |ddgd        |ddgd        |ddgd        |ddgd        |dgd        |ddgd        |ddgd        |ddgd        |ddgd        |ddgd        |g dd        |g dd        |dgd        |ddgd        |t        ddg        j                  t        t        j                  d dg        j                  t        t        j                  d d!g        j                  t        t        j                  d"dg        j                  t        t        j                  dd#g        j                  t        t        j                  dd$g        j                  t        t        j                  d%d#g       y )&Nc           
         j                  t        j                  |       |       j                  t        j                  | D cg c]  }t        j                  |       c}      t        j                  |             y c c}w r   )r3   r4   
commonpathr   r|   )pathsr   pr"   s      r   checkz,PosixPathTest.test_commonpath.<locals>.check  s[    Y11%8(CY1152Qa2;;q>2QR[[242Qs   Bc           
          j                  | t        j                  |       j                  | t        j                  |D cg c]  }t        j                  |       c}       y c c}w r   )r   r4   r  r   r|   )excr  r  r"   s      r   check_errorz2PosixPathTest.test_commonpath.<locals>.check_error  sL    c9#7#7?c9#7#77<=!r{{1~=?=s   A&z/usrusrz
/usr/localz/usr/local/z/usr//localz//usr/localz/usr/./localz/./usr/localr9   z/devz	/usr/lib/z/usr/lib/python3z/usr/libz/usr/lib64/z
/usr/lib64spamalotr%   and/jamand/spamandzand//jamz
and/spam//z	and/./jamz
./and/spam)r  r  r  )r  r  r  z	spam/alotz
/spam/alots	   /usr/lib/zusr/lib/python3s   usr/lib/s   /usr/lib/python3s   usr/lib/python3zusr/lib/)r   r  r4   r  r  )r"   r  r  s   `  r   test_commonpathzPosixPathTest.test_commonpath  sP   	4	?
 	*i&:&:B?J0J0|nl+|\*L9}l+\:}m,l;}m,l;~~.=sFmS!vv${./<{M*F3z<(&1{L)62vhvv'vv#y*%u-z<(%0{L)51-r2,e4rdBr;$J\ 23)Y%9%9');<	>)Y%9%9'):;	=)Y%9%9&(:;	=)Y%9%9&(;<	>)Y%9%9&(:;	=)Y%9%9%':;	=r   )0__name__
__module____qualname__r#   r    r6   rG   rO   rT   rf   rj   rl   rn   r}   r   r   r	   skip_unless_symlinkr   r   skipIfr   r   r   r   r   r   sysplatformr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r   r   r   r   r   '   s   2
+M78&:4:DEX*?: "" # X__Ud]$@A" B"" X__Ud]$@A" B"*7?L  X__S\\Y.35%G5%GN1Nf
3 'J 'J 'C 'C ""&% ' #% ""&% ' #% ""&% ' #% ""&%) ' #%)N ""&%) ' #%)N ""&
 ' #
 ""& ' #" ""& ' #" ""& ' #4 ""& ' #"$4&<4=r   r   c                       e Zd ZeZg dZy)PosixCommonTest)r   samefilesameopenfilesamestatN)r  r  r  r4   
pathmodule
attributesr   r   r   r#  r#    s    JDJr   r#  c                       e Zd ZeZd Zd Zd Zd Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)PathLikeTestsc                 8   t         j                  | _        t        t         j                        | _        | j                  t         j                  | j                         t        | j                  dd      5 }|j                  d       d d d        y # 1 sw Y   y xY w)Nxbr   s   test_posixpath.PathLikeTests)	r	   r)   	file_namer
   	file_path
addCleanupr(   rv   rw   )r"   files     r   r#   zPathLikeTests.setUp  sm    "))!)"2"23	(($..9$..$* 	8dJJ67	8 	8 	8s   5BBc                 h    | j                   || j                         || j                               y r   )r3   r.  r-  )r"   funcs     r   assertPathEqualzPathLikeTests.assertPathEqual  s$    dnn-tDNN/CDr   c                 N    | j                  | j                  j                         y r   )r3  rL   normcaser!   s    r   test_path_normcasez PathLikeTests.test_path_normcase      TYY//0r   c                 N    | j                  | j                  j                         y r   )r3  rL   ri   r!   s    r   test_path_isabszPathLikeTests.test_path_isabs      TYY__-r   c                     | j                  | j                  j                  dt        d      d      | j                  j                  ddd             y )NrV   br   )r3   rL   r5   r
   r!   s    r   test_path_joinzPathLikeTests.test_path_join   s;    Xc]C@S#6	8r   c                 N    | j                  | j                  j                         y r   )r3  rL   rF   r!   s    r   test_path_splitzPathLikeTests.test_path_split  r:  r   c                 N    | j                  | j                  j                         y r   )r3  rL   rJ   r!   s    r   test_path_splitextz PathLikeTests.test_path_splitext  r7  r   c                 N    | j                  | j                  j                         y r   )r3  rL   
splitdriver!   s    r   test_path_splitdrivez"PathLikeTests.test_path_splitdrive
      TYY112r   c                 N    | j                  | j                  j                         y r   )r3  rL   rc   r!   s    r   test_path_splitrootz!PathLikeTests.test_path_splitroot  s    TYY001r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_basenamez PathLikeTests.test_path_basename  r7  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_dirnamezPathLikeTests.test_path_dirname      TYY../r   c                 N    | j                  | j                  j                         y r   )r3  rL   rt   r!   s    r   test_path_islinkzPathLikeTests.test_path_islink  s    TYY--.r   c                 N    | j                  | j                  j                         y r   )r3  rL   ru   r!   s    r   test_path_lexistszPathLikeTests.test_path_lexists  rL  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_ismountzPathLikeTests.test_path_ismount  rL  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_expanduserz"PathLikeTests.test_path_expanduser  rE  r   c                 N    | j                  | j                  j                         y r   )r3  rL   
expandvarsr!   s    r   test_path_expandvarsz"PathLikeTests.test_path_expandvars"  rE  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_normpathz PathLikeTests.test_path_normpath%  r7  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_abspathzPathLikeTests.test_path_abspath(  rL  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_realpathz PathLikeTests.test_path_realpath+  r7  r   c                 N    | j                  | j                  j                         y r   )r3  rL   r   r!   s    r   test_path_relpathzPathLikeTests.test_path_relpath.  rL  r   c                     | j                   j                  | j                  | j                  g      }| j	                  || j                         y r   )rL   r  r.  r-  r3   )r"   common_paths     r   test_path_commonpathz"PathLikeTests.test_path_commonpath1  s7    ii**DNNDNN+KLdnn5r   N)r  r  r  r4   rL   r#   r3  r6  r9  r=  r?  rA  rD  rG  rI  rK  rN  rP  rR  rT  rW  rY  r[  r]  r_  rb  r   r   r   r*  r*    sq    D8E1.8.13210/003310106r   r*  __main__)r   r4   r   r   r   r   r   r   r   r   test.supportr   r	   test.support.os_helperr
   r   r   ImportErrorr)   r   r   r   TestCaser   
CommonTestr#  r*  r  mainr   r   r   <module>rj     s    	  
  : : ! & " +  
!!	"=}
=H%% }
=@E&1183D3D E
G6H%% G6T ZHMMO Q  Es   B: :CC