
    daf                        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mZmZmZ d dl	m
Z
 d dlmZ d dlmZ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j0                        Z G d de
j4                  ej0                        Z G d dej0                        Zedk(  r ej<                          yy# e$ r dZY w xY w)    N)realpathabspathdirnamebasename)test_genericpath)import_helper)cpython_only	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      ./root/Python-3.12.4/Lib/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                      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 ej(                  ej4                  dk(  d      ed               Zd Zd Z ej(                  ej4                  dk(  d      d        Z ej(                  ej4                  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+ Z0d, Z1d- Z2y).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_join2   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.   /)r:   r&   foo)r&   r;   ////foo)////r;   
//foo//bar)//foor.      /foo/bar)r2   r3      /)rA   r      foo)r   rB      ////foo)   ////rB   
   //foo//bar)   //foor3   )r4   r5   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 )Nr:   zabc/zabc.def/z	/abc.def/r&   ASCIIrA   s   abc/s   abc.def/s	   /abc.def/r   )r4   r5   splitextbytes)r#   pathfilenameexts       r   splitextTestzPosixPathTest.splitextTestM   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........)rP   r"   s    r   test_splitextzPosixPathTest.test_splitexti   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&   rW   a/b)r&   r&   rX   a/b/)r&   r&   rY   /a)r&   r:   rW   /a/b)r&   r:   rX   z/a/b/)r&   r:   rY   //a)r&   //rW   z///a)r&   r:   r\   z///a/b)r&   r:   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   ra      /a)r   rA   ra      //a)r   s   //ra   s   ///a)r   rA   rc   )r5   	splitrootr4   r#   fs     r   test_splitrootzPosixPathTest.test_splitrootw   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&   Fr:   Tr-   r9   zfoo/barr   rA   r2   r@   s   foo/bar)assertIsr5   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 )Nr9   r.   r:   r&   r;   r<   r>   r@   r3   rA   r   rB   rC   rE   )r4   r5   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 )Nr9   r-   r:   r;   r&   r<   r=   r>   r?   r@   r2   rA   rB   r   rC   rD   rE   rF   )r4   r5   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(   wbrB   Tu           )ri   r5   islinkr
   r*   lexistsopenwritecan_symlinkr   symlinkremoveexistsfsencodere   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 )Nr:   TrA   )ri   r5   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   / )ri   r5   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)Nr:   F)r   rz   r   ri   r5   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rM   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   lstatri   r5   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   )assertFalser5   
isjunctionr   r"   s    r   test_isjunctionzPosixPathTest.test_isjunction  s    --f56r   win32zFast paths are not for win32c                     | j                  t        j                  j                  t        j
                  u        | j                  t        j                  t        j                  j                               y r   )	
assertTruer   rM   normpathr   _path_normpathr   inspect
isfunctionr"   s    r   test_fast_paths_in_usez$PosixPathTest.test_fast_paths_in_use  sH    
 	((E,@,@@A++BGG,<,<=>r   c                     | j                  t        j                  d      d       | j                  t        j                  d      d       y )Nr;   rB   )r4   r5   
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/)r:   r&   r]   ///)homer:   ~/z~/foor-   )r
   EnvironmentVarGuardr4   r5   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   r:      ~rA   z~root/z~foo/s   ~root/s   ~foo/r   getpwuid)side_effectgetpwnam)r   z~/.localz
~vstinner/)r   import_moduleassertIsInstancer5   r   strrL   r4   r
   r   r   r   getuidpw_dirrstripr   patchobjectKeyError)r#   r   r   r   rM   s        r   test_expanduser_pwdz!PosixPathTest.test_expanduser_pwd1  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c           	         t        j                  d      }|j                         D ]  }|j                  }|j                  }|j                  d      xs d}| j                  t        j                  d|z         |       | j                  t        j                  t        j                  d|z               t        j                  |              y )Nr   r:   r   )r   r   getpwallpw_namer   r   r4   r5   r   r   r}   )r#   r   enamer   s        r   test_expanduser_pwd2z"PosixPathTest.test_expanduser_pwd2Z  s     ))%0 	0A99D88D;;s#*sDY11#*=tDY11"++cDj2IJ[[.0	0r   )0)r&   rS   )r:   r:   )z/.r:   )z/./r:   )z/.//.r:   )r-   r-   )r9   r9   )r]   r]   )r   r:   )z///foo/.//bar//r9   )z///foo/.//bar//.//..//.//baz///z/foo/baz)z///..//./foo/.//barr9   )rS   rS   )z.//.rS   )rT   rT   )../rT   )../foor   )	../../foor   )z../foo/../barz../bar)z../../foo/../bar/./baz/boom/..../../bar/bazz/..r:   r   )z/../r:   )z/..//r:   )z//.r]   )z//..r]   )//...r   )z//../foor?   )z//../../foor?   )z/../foor-   )z
/../../foor-   )z/../foo/../r:   )z/../foo/../barr/   )z/../../foo/../bar/./baz/boom/..r1   )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/..r:   )z
/foo/../..r:   )z//foo/..r]   )z//foo/../..r]   )z	///foo/..r:   )z///foo/../..r:   )z
////foo/..r:   )z/////foo/..r:   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   r5   r   r4   encoderL   )r#   rM   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 )NrS   z./.r:   d      .s   ./.rA   )r4   r   r   getcwdr6   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 )NrT   z../..r:   r   s   ..s   ../..rA   )r4   r   r   r   r   r6   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   rz   r   r4   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   rz   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   rz   r5   relpathr   r4   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/../rX   rW   r   r:   c)
r   rz   r   r4   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   rX   rW   r   r:   r   )r   rz   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   rz   r   r4   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
   r:   z%dz/%dr   rS   z/0)r   r   r   rangerz   r6   r4   r   r
   r   r)   r   )r#   depthis      r   test_realpath_deep_recursionz*PosixPathTest.test_realpath_deep_recursion8  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/krW   z/y/a)
r   r   r   rz   r
   r   r4   r   r)   r   r"   s    r   test_realpath_resolve_parentsz+PosixPathTest.test_realpath_resolve_parentsK  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   rz   r4   r   r
   r   r   r   r)   r   r"   s    r   (test_realpath_resolve_before_normalizingz6PosixPathTest.test_realpath_resolve_before_normalizing^  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   rz   r
   r   r   r   r4   r   r)   r   )r#   bases     r   test_realpath_resolve_firstz)PosixPathTest.test_realpath_resolve_firstz  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>      r   r&   rW   rX   z../a/bz../br   rZ   z../cr[   zb/cz../../arS   z/foo/bar/batz/x/y/zz../../../foo/bar/batr9   batr:   zfoo/bar/batz../../..r   z../foo/bar/batz
../../../x)
r   r   rM   rG   r   
ValueErrorr5   r   r4   r   )r#   real_getcwdcurdirs      r   test_relpathzPosixPathTest.test_relpath  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   ra   s   a/bs   ../a/bs   ../bs   ../rb   s   ../cs   /a/bs   b/cs   ../../ar   s   /foo/bar/bats   /x/y/zs   ../../../foo/bar/batr@   s   batrA   s   foo/bar/bats   ../../..s   /xs   ../foo/bar/bats
   ../../../xs   bytesr   )r   r   rM   rG   r   r  r5   r   r4   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   )r4   r5   
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   r5   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/localr:   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  r5   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   )3__name__
__module____qualname__r$   r!   r7   rH   rP   rU   rg   rk   rm   ro   r~   r   r   r
   skip_unless_symlinkr   r   skipIfr   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(  r  r   r   r   r   (   s   2
+M78&:4:DEX*?: "" # X__Ud]$@A" B"" X__Ud]$@A" B"*7 X__S\\W,.LM?  N??L  X__S\\Y.35%G5%GN X__S\\Y.35050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+  r5   
pathmodule
attributesr  r   r   r1  r1    s    JDJr   r1  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)   rw   rx   )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   )r4   r<  r;  )r#   funcs     r   assertPathEqualzPathLikeTests.assertPathEqual  s$    dnn-tDNN/CDr   c                 N    | j                  | j                  j                         y r   )rA  rM   normcaser"   s    r   test_path_normcasez PathLikeTests.test_path_normcase      TYY//0r   c                 N    | j                  | j                  j                         y r   )rA  rM   rj   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 )NrW   br   )r4   rM   r6   r   r"   s    r   test_path_joinzPathLikeTests.test_path_join  s;    Xc]C@S#6	8r   c                 N    | j                  | j                  j                         y r   )rA  rM   rG   r"   s    r   test_path_splitzPathLikeTests.test_path_split  rH  r   c                 N    | j                  | j                  j                         y r   )rA  rM   rK   r"   s    r   test_path_splitextz PathLikeTests.test_path_splitext  rE  r   c                 N    | j                  | j                  j                         y r   )rA  rM   
splitdriver"   s    r   test_path_splitdrivez"PathLikeTests.test_path_splitdrive      TYY112r   c                 N    | j                  | j                  j                         y r   )rA  rM   rd   r"   s    r   test_path_splitrootz!PathLikeTests.test_path_splitroot"  s    TYY001r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_basenamez PathLikeTests.test_path_basename%  rE  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_dirnamezPathLikeTests.test_path_dirname(      TYY../r   c                 N    | j                  | j                  j                         y r   )rA  rM   ru   r"   s    r   test_path_islinkzPathLikeTests.test_path_islink+  s    TYY--.r   c                 N    | j                  | j                  j                         y r   )rA  rM   rv   r"   s    r   test_path_lexistszPathLikeTests.test_path_lexists.  rZ  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_ismountzPathLikeTests.test_path_ismount1  rZ  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_expanduserz"PathLikeTests.test_path_expanduser4  rS  r   c                 N    | j                  | j                  j                         y r   )rA  rM   
expandvarsr"   s    r   test_path_expandvarsz"PathLikeTests.test_path_expandvars7  rS  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_normpathz PathLikeTests.test_path_normpath:  rE  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_abspathzPathLikeTests.test_path_abspath=  rZ  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_realpathz PathLikeTests.test_path_realpath@  rE  r   c                 N    | j                  | j                  j                         y r   )rA  rM   r   r"   s    r   test_path_relpathzPathLikeTests.test_path_relpathC  rZ  r   c                     | j                   j                  | j                  | j                  g      }| j	                  || j                         y r   )rM   r  r<  r;  r4   )r#   common_paths     r   test_path_commonpathz"PathLikeTests.test_path_commonpathF  s7    ii**DNNDNN+KLdnn5r   N)r)  r*  r+  r5   rM   r$   rA  rD  rG  rK  rM  rO  rR  rU  rW  rY  r\  r^  r`  rb  re  rg  ri  rk  rm  rp  r  r   r   r8  r8    sq    D8E1.8.13210/003310106r   r8  __main__)r   r   r5   r.  r   r   r   r   r   r   r   test.supportr   r	   r
   test.support.os_helperr   r   r   ImportErrorr*   r   r   r   TestCaser   
CommonTestr1  r8  r)  mainr  r   r   <module>rx     s     	  
  : : ! & 0 +  
!!	"=Q=H%% Q=hE&1183D3D E
G6H%% G6T ZHMMO y  Es   C   C
	C
