
    dafR                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZm	Z	 d dlm
Z
mZ d dlmZ d dlmZ d dlmZ 	 d dlZ	 ej(                   dZ	 d dlZdZd	 Zd
 Zd Z G d dej8                        Z G d de      Z G d dej>                  ej8                        Z  G d de      Z!e"dk(  r ejF                          yy# e$ r dZY w xY w# e$ r dZY w xY w# e$ r dZY w xY w)    N)cpython_only	os_helper)
TestFailedis_emscripten)FakePath)test_genericpath)TemporaryFileTFc                    t        j                  dd      j                  }t         j                  t         j                  t         j                  g|_        t         j                  |_         || d d      }|s,t        dj                  t        j                                     t        j                  |      } || ||      }|d | S )Nkernel32T)use_last_errorr   z&failed to get short path name 0x{:08X})ctypesWinDLLGetShortPathNameW	c_wchar_pc_uint32argtypesrestypeOSErrorformatget_last_errorcreate_unicode_buffer)pathGSPN
result_lenresults       +/root/Python-3.12.4/Lib/test/test_ntpath.py_getshortpathnamer   #   s    }}Z=OO))6+;+;V__M$a(
B!6&"7"7"9:< <--j9$
3
kz""    c                     t        | t        t        t        j                  f      r(t        j                  t        j                  |             S t        | d      rt        d | D              S | S )N__iter__c              3   l   K   | ],  }t        j                  t        j                  |             . y wN)ntpathnormcaseosfsdecode).0ps     r   	<genexpr>z_norm.<locals>.<genexpr>3   s!     CV__R[[^4Cs   24)

isinstancebytesstrr%   PathLiker#   r$   r&   hasattrtuple)r   s    r   _normr0   /   sO    $R[[12r{{4011	z	"CdCCCKr   c           	      Z   | j                  dd      } t        |       }||k7  rEt        |      t        |      k7  r.t        t	        |       dt	        |      dt	        |            | j                  dd      } | j                  dd      } | j                  d	d
      } | j                  dd      } | j                  dd      } | j                  dd      } t        j                  |       j                  d      } | j                  dd      j                  d      } t        j                         5  t        j                  dt               t        |       }d d d        t        |      t        |      k7  r.t        t	        |       dt	        |      dt        |            y # 1 sw Y   OxY w)N\\\z should return: z but returned: z('z(b'z("z(b"z['z[b'z["z[b"z, 'z, b'z, "z, b"latin1asciibackslashreplaceignore)replaceevalr0   r   r,   r%   fsencodedecodeencodewarningscatch_warningssimplefilterDeprecationWarningrepr)fn
wantResult	gotResults      r   testerrE   7   sh   	D&	!BRIY5#4i8H#HBZ#i.: ; 	; 
D%	 B	D%	 B	D%	 B	D%	 B	E6	"B	E6	"B	R			)B	7.	/	6	6w	?B		 	 	" h(:;H	 ZE),,BZ$y/; < 	< - s   -&F!!F*c                       e Zd Zd Zd Zy)NtpathTestCasec                 b    ||k(  st        |      t        |      k(  ry | j                  ||       y r"   )r0   assertEqual)selfpath1path2s      r   assertPathEqualzNtpathTestCase.assertPathEqualP   s+    E>U5\U5\9&r   c                 L    | j                  t        |      t        |             y r"   )assertInr0   )rJ   r   pathsets      r   assertPathInzNtpathTestCase.assertPathInU   s    eDk5>2r   N)__name__
__module____qualname__rM   rQ    r   r   rG   rG   O   s    '
3r   rG   c                   f   e 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                   ej                   ed      d               Zej                   ej                   ed      d               Zej                   ej                   ed      d               Zej                   ej                   ed      d               Zej                   ej                   ed      d               Zej                   ej                   ed      d               Zej                   ej                   ed      d               Z ej                   ed      d        Z ej                   ed       ej                   ed      d               Zd Z ej                   ej:                  d      d        Zd Z ej                   e d      d        Z!d Z"d Z# ejH                  e%d      d        Z&d  Z'd! Z( ej                   e d"      d#        Z) ejH                  e*jV                  d$k7  d%      d&        Z, ejH                  e*jV                  d$k7  d'      d(        Z- ej                    e.e/d)      d*      d+        Z0 ejH                  e*jV                  d$k7  d,      d-        Z1 ejH                  e*jV                  d$k7  d,      d.        Z2 ejH                  e*jV                  d$k7  d/      e3d0               Z4 ejH                  e/jj                  d1k7  d2      d3        Z6 ejH                  e/jj                  d1k(  d4      d5        Z7y6)7
TestNtpathc                     t        dd       t        dd       t        dd       t        dd       t        d	d
       t        dd       t        dd       t        dd       t        dd       t        dd       y )Nzntpath.splitext("foo.ext"))foo.extzntpath.splitext("/foo/foo.ext"))z/foo/foorZ   zntpath.splitext(".ext"))rZ    zntpath.splitext("\foo.ext\foo"))z\foo.ext\foor[   zntpath.splitext("foo.ext\"))zfoo.ext\r[   zntpath.splitext("")r[   r[   zntpath.splitext("foo.bar.ext"))zfoo.barrZ   z!ntpath.splitext("xx/foo.bar.ext"))z
xx/foo.barrZ   z!ntpath.splitext("xx\foo.bar.ext"))z
xx\foo.barrZ   zntpath.splitext("c:a/b\c.d"))zc:a/b\cz.drE   rJ   s    r   test_splitextzTestNtpath.test_splitextZ   sw    +_=02FG(,724JK-/@A$h//1DE24JK35LM.0BCr   c                    t        dd       t        dd       t        dd       t        dd       t        d	d
       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd        t        d!d"       t        d#d$       y )%Nzntpath.splitdrive('')r\   zntpath.splitdrive('foo'))r[   rY   zntpath.splitdrive('foo\bar'))r[   foo\barzntpath.splitdrive('foo/bar'))r[   foo/barzntpath.splitdrive('\'))r[   r2   zntpath.splitdrive('/'))r[   /zntpath.splitdrive('\foo\bar'))r[   \foo\barzntpath.splitdrive('/foo/bar'))r[   /foo/barzntpath.splitdrive("c:foo\bar"))c:ra   zntpath.splitdrive("c:foo/bar"))rf   rb   zntpath.splitdrive("c:\foo\bar"))rf   rd   zntpath.splitdrive("c:/foo/bar"))rf   re   zntpath.splitdrive('\\'))r3   r[   zntpath.splitdrive('//'))//r[   z/ntpath.splitdrive("\\conky\mountpoint\foo\bar"))\\conky\mountpointrd   z/ntpath.splitdrive("//conky/mountpoint/foo/bar"))//conky/mountpointre   z-ntpath.splitdrive("\\?\UNC\server\share\dir"))\\?\UNC\server\sharez\dirz-ntpath.splitdrive("//?/UNC/server/share/dir"))//?/UNC/server/sharez/dirr]   r^   s    r   test_splitdrivezTestNtpath.test_splitdrivef   s    &1);7.0@A-?(*5'302DE.0@A02DE/1BC24HI02DE*L9(*5E6	8@1	3D5	7>/	1r   c                    t        dd       t        dd       t        dd       t        dd       t        d	d
       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd        t        d!d"       t        d#d$       t        d%d&       t        d'd(       t        d)d*       t        d+d,       t        d-d.       t        d/d0       t        d1d2       t        d3d4       | j                  t        j                  d5      d6       t        d7d8       t        d9d:       t        d;d<       t        d=d>       t        d?d@       t        dAdB       t        dCdD       t        dEdF       t        dGdH       t        dIdJ       t        dKdL       t        dMdN       t        dOdP       t        dQdR       t        dSdT       t        dUdV       t        dWdX       t        dYdZ       t        d[d\       t        d]d^       t        d_d`       t        dadb       t        dcdd       t        dedf       t        dgdh       t        didj       t        dkdl       t        dmdn       t        dod(       t        dpdq       t        drds       t        dtdu       t        dvdw       t        dxdy       t        dzd{       y )|Nzntpath.splitroot(''))r[   r[   r[   zntpath.splitroot('foo'))r[   r[   rY   zntpath.splitroot('foo\bar'))r[   r[   ra   zntpath.splitroot('foo/bar'))r[   r[   rb   zntpath.splitroot('\'))r[   r2   r[   zntpath.splitroot('/'))r[   rc   r[   zntpath.splitroot('\foo\bar'))r[   r2   ra   zntpath.splitroot('/foo/bar'))r[   rc   rb   zntpath.splitroot("c:foo\bar"))rf   r[   ra   zntpath.splitroot("c:foo/bar"))rf   r[   rb   zntpath.splitroot("c:\foo\bar"))rf   r2   ra   zntpath.splitroot("c:/foo/bar"))rf   rc   rb   zntpath.splitroot('c:\\a'))rf   r2   \azntpath.splitroot('c:\\\a/b'))rf   r2   z\\a/bzntpath.splitroot('c:/\'))rf   rc   r2   zntpath.splitroot('c:\/'))rf   r2   rc   zntpath.splitroot('/\a/b\/\'))z/\a/br2   z/\zntpath.splitroot('\/a\b/\/'))z\/a\brc   z\/zntpath.splitroot('\\'))r3   r[   r[   zntpath.splitroot('//'))rg   r[   r[   z.ntpath.splitroot("\\conky\mountpoint\foo\bar"))rh   r2   ra   z.ntpath.splitroot("//conky/mountpoint/foo/bar"))ri   rc   rb   z/ntpath.splitroot("\\\conky\mountpoint\foo\bar"))z\\\conkyr2   mountpoint\foo\barz/ntpath.splitroot("///conky/mountpoint/foo/bar"))z///conkyrc   mountpoint/foo/barz/ntpath.splitroot("\\conky\\mountpoint\foo\bar"))z\\conky\r2   ro   z/ntpath.splitroot("//conky//mountpoint/foo/bar"))z//conky/rc   rp   u   //conky/MOUNTPOİNT/foo/bar)u   //conky/MOUNTPOİNTrc   rb   zntpath.splitroot("//?/c:"))//?/c:r[   r[   zntpath.splitroot("//./c:"))z//./c:r[   r[   zntpath.splitroot("//?/c:/"))rq   rc   r[   zntpath.splitroot("//?/c:/dir"))rq   rc   dirzntpath.splitroot("//?/UNC"))z//?/UNCr[   r[   zntpath.splitroot("//?/UNC/"))z//?/UNC/r[   r[   z#ntpath.splitroot("//?/UNC/server/"))z//?/UNC/server/r[   r[   z(ntpath.splitroot("//?/UNC/server/share"))rk   r[   r[   z,ntpath.splitroot("//?/UNC/server/share/dir"))rk   rc   rr   zIntpath.splitroot("//?/VOLUME{00000000-0000-0000-0000-000000000000}/spam"))z0//?/VOLUME{00000000-0000-0000-0000-000000000000}rc   spamz&ntpath.splitroot("//?/BootPartition/"))z//?/BootPartitionrc   r[   z&ntpath.splitroot("//./BootPartition/"))z//./BootPartitionrc   r[   z&ntpath.splitroot("//./PhysicalDrive0"))z//./PhysicalDrive0r[   r[   zntpath.splitroot("//./nul"))z//./nulr[   r[   zntpath.splitroot("\\?\c:"))\\?\c:r[   r[   zntpath.splitroot("\\.\c:"))z\\.\c:r[   r[   zntpath.splitroot("\\?\c:\"))rt   r2   r[   zntpath.splitroot("\\?\c:\dir"))rt   r2   rr   zntpath.splitroot("\\?\UNC"))z\\?\UNCr[   r[   zntpath.splitroot("\\?\UNC\"))z\\?\UNC\r[   r[   z#ntpath.splitroot("\\?\UNC\server\"))z\\?\UNC\server\r[   r[   z(ntpath.splitroot("\\?\UNC\server\share"))rj   r[   r[   z,ntpath.splitroot("\\?\UNC\server\share\dir"))rj   r2   rr   zIntpath.splitroot("\\?\VOLUME{00000000-0000-0000-0000-000000000000}\spam"))z0\\?\VOLUME{00000000-0000-0000-0000-000000000000}r2   rs   z&ntpath.splitroot("\\?\BootPartition\"))z\\?\BootPartitionr2   r[   z&ntpath.splitroot("\\.\BootPartition\"))z\\.\BootPartitionr2   r[   z&ntpath.splitroot("\\.\PhysicalDrive0"))z\\.\PhysicalDrive0r[   r[   zntpath.splitroot("\\.\nul"))\\.\nulr[   r[   zntpath.splitroot("//")zntpath.splitroot("///"))z///r[   r[   zntpath.splitroot("///y"))z///yr[   r[   zntpath.splitroot("//x"))z//xr[   r[   zntpath.splitroot("//x/"))z//x/r[   r[   zntpath.splitroot(" :/foo"))z :rc   rY   zntpath.splitroot("/:/foo"))r[   rc   z:/foo)rE   rI   r#   	splitrootr^   s    r   test_splitrootzTestNtpath.test_splitroot~   s   %|4(/:-/CD,.AB'8&6/1GH-/CD/1GH.0EF13KL/1GH 	,.AB02IJ 	*,=>*,=>02IJ02IJ 	)+;<'8D:	<?5	7F9	;@3	5F<	>@6	8 	))*GH@	B 	+-?@+-?@,.AB/1GH,.AB-/CD46QR9;[\=?cdZP	R79WX79WX79WX,.AB.0EF.0EF02IJ35OP/1GH13KL9;[\>4	6C9	;^T	V;=_`;=_`:<]^/1GH 	'8(/:)+;<(/:)+;< 	+-?@+-?@r   c                     t        dd       t        dd       t        dd       t        dd       t        d	d
       t        dd       y )Nzntpath.split("c:\foo\bar"))zc:\foobarz*ntpath.split("\\conky\mountpoint\foo\bar"))z\\conky\mountpoint\foory   zntpath.split("c:\"))c:\r[   z#ntpath.split("\\conky\mountpoint\"))z\\conky\mountpoint\r[   zntpath.split("c:/"))c:/r[   z#ntpath.split("//conky/mountpoint/"))z//conky/mountpoint/r[   r]   r^   s    r   
test_splitzTestNtpath.test_split   sP    -/AB@4	6 	%|48.	0 	$k246QRr   c                     t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       y )Nzntpath.isabs("c:\")   z#ntpath.isabs("\\conky\mountpoint\")zntpath.isabs("\foo")zntpath.isabs("\foo\bar")z"ntpath.isabs("\\conky\mountpoint")zntpath.isabs("\\.\C:")r]   r^   s    r   
test_isabszTestNtpath.test_isabs   sF    %q)8!<&*+Q/ 	6:*A.r   c                 L    t        dd       t        dd       t        dd       y )Nz>ntpath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])z
/home/swenz;ntpath.commonprefix(["\home\swen\spam", "\home\swen\eggs"])z\home\swen\z;ntpath.commonprefix(["/home/swen/spam", "/home/swen/spam"])z/home/swen/spamr]   r^   s    r   test_commonprefixzTestNtpath.test_commonprefix   s,    O	R	!L 	"r   c           	         t        dd       t        dd       t        dd       t        dd       t        dd	       t        d
d       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        d d       t        d!d"       t        d#d$       t        d%d&       t        d'd(       t        d)d*       t        d+d,       t        d-d.       t        d/d0       t        d1d2       t        d3d4       t        d5d6       t        d7d8       t        d9d:       t        d;d<       t        d=d<       t        d>d0       t        d?d0       t        d@d0       t        dAd0       t        dBd8       t        dCd8       t        dDd8       t        dEdF       t        dGdH       t        dIdJ       t        dKdL       dMD ]  }dND ]  }t        dO|dP|dQ|         t        dRdS       t        dTdS       t        dUdS       t        dVdW       t        dXdY       t        dZd[       t        d\d]       t        d^d_       t        d`da       t        dbdS       y )cNzntpath.join("")r[   zntpath.join("", "", "")zntpath.join("a")azntpath.join("/a")z/azntpath.join("\a")rn   zntpath.join("a:")za:zntpath.join("a:", "\b")za:\bzntpath.join("a", "\b")z\bzntpath.join("a", "b", "c")za\b\czntpath.join("a\", "b", "c")zntpath.join("a", "b\", "c")zntpath.join("a", "b", "\c")z\czntpath.join("d:\", "\pleep")zd:\pleepzntpath.join("d:\", "a", "b")zd:\a\bzntpath.join('', 'a')z ntpath.join('', '', '', '', 'a')zntpath.join('a', '')za\z ntpath.join('a', '', '', '', '')zntpath.join('a\', '')z!ntpath.join('a\', '', '', '', '')zntpath.join('a/', '')za/zntpath.join('a/b', 'x/y')za/b\x/yzntpath.join('/a/b', 'x/y')z/a/b\x/yzntpath.join('/a/b/', 'x/y')z/a/b/x/yzntpath.join('c:', 'x/y')zc:x/yzntpath.join('c:a/b', 'x/y')z	c:a/b\x/yzntpath.join('c:a/b/', 'x/y')z	c:a/b/x/yzntpath.join('c:/', 'x/y')zc:/x/yzntpath.join('c:/a/b', 'x/y')z
c:/a/b\x/yzntpath.join('c:/a/b/', 'x/y')z
c:/a/b/x/yz&ntpath.join('//computer/share', 'x/y')z//computer/share\x/yz'ntpath.join('//computer/share/', 'x/y')z//computer/share/x/yz*ntpath.join('//computer/share/a/b', 'x/y')z//computer/share/a/b\x/yzntpath.join('a/b', '/x/y')z/x/yzntpath.join('/a/b', '/x/y')zntpath.join('c:', '/x/y')zntpath.join('c:a/b', '/x/y')zntpath.join('c:/', '/x/y')zntpath.join('c:/a/b', '/x/y')z'ntpath.join('//computer/share', '/x/y')z(ntpath.join('//computer/share/', '/x/y')z)ntpath.join('//computer/share/a', '/x/y')zntpath.join('c:', 'C:x/y')zC:x/yzntpath.join('c:a/b', 'C:x/y')z	C:a/b\x/yzntpath.join('c:/', 'C:x/y')zC:/x/yzntpath.join('c:/a/b', 'C:x/y')z
C:/a/b\x/y)
r[   za/bz/a/brf   zc:a/br{   zc:/a/bz//computer/sharez//computer/share/z//computer/share/a/b)zd:zd:x/yzd:/zd:/x/yz//machine/commonz//machine/common/z//machine/common/x/yzntpath.join(z, )z*ntpath.join('\\computer\share\', 'a', 'b')z\\computer\share\a\bz)ntpath.join('\\computer\share', 'a', 'b')z&ntpath.join('\\computer\share', 'a\b')z*ntpath.join('//computer/share/', 'a', 'b')z//computer/share/a\bz)ntpath.join('//computer/share', 'a', 'b')z//computer/share\a\bz&ntpath.join('//computer/share', 'a/b')z//computer/share\a/bzntpath.join('\\', 'computer')z
\\computerz#ntpath.join('\\computer\', 'share')z\\computer\sharez%ntpath.join('\\computer\share\', 'a')z\\computer\share\az'ntpath.join('\\computer\share\a\', 'b')r]   )rJ   xys      r   	test_joinzTestNtpath.test_join   s    "%("-!3'"D)#U+"D))73(%0+Y7-y9-y9-u5/=.
;%s+137%u-159'/3U;&-*J7+[9,j9)73,l;-{;*H5-}=.=79PQ8:PQ;=XY+V4,f5*H5-x8+X6.98:PQ9;QR:<RS+W5.=,h7/?S 	:AW :15q9:	: 	?A\]=?Z[;=XY;=TU:<TU79PQ0.A79NO:<TU=?Z[r   c                 4   t        dd       t        dd       t        dd       t        dd       t        dd       t        d	d
       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        d d!       t        d"d#       t        d$d%       t        d&d'       t        d(d)       t        d*d+       t        d,d-       t        d.d/       t        d0d1       t        d2d1       t        d3d1       t        d4d1       t        d5d6       t        d7d8       t        d9d:       t        d;d<       y )=Nz$ntpath.normpath('A//////././//.//B')zA\Bzntpath.normpath('A/./B')zntpath.normpath('A/foo/../B')zntpath.normpath('C:A//B')zC:A\Bzntpath.normpath('D:A/./B')zD:A\Bzntpath.normpath('e:A/foo/../B')ze:A\Bzntpath.normpath('C:///A//B')zC:\A\Bzntpath.normpath('D:///A/./B')zD:\A\Bz"ntpath.normpath('e:///A/foo/../B')ze:\A\Bzntpath.normpath('..')..zntpath.normpath('.').zntpath.normpath('')zntpath.normpath('/')r2   zntpath.normpath('c:/')rz   zntpath.normpath('/../.././..')zntpath.normpath('c:/../../..')zntpath.normpath('../.././..')..\..\..zntpath.normpath('K:../.././..')z
K:..\..\..zntpath.normpath('C:////a/b')zC:\a\bz'ntpath.normpath('//machine/share//a/b')z\\machine\share\a\bzntpath.normpath('\\.\NUL')\\.\NULzntpath.normpath('\\?\D:/XY\Z')z\\?\D:/XY\Zz1ntpath.normpath('handbook/../../Tests/image.png')z..\Tests\image.pngz4ntpath.normpath('handbook/../../../Tests/image.png')z..\..\Tests\image.pngz.ntpath.normpath('handbook///../a/.././../b/c')z..\b\cz/ntpath.normpath('handbook/a/../..///../../b/c')z	..\..\b\cz$ntpath.normpath('//server/share/..')\\server\share\z%ntpath.normpath('//server/share/../')z'ntpath.normpath('//server/share/../..')z(ntpath.normpath('//server/share/../../')zntpath.normpath('\\foo\\')z\\foo\\zntpath.normpath('\\foo\')z\\foo\zntpath.normpath('\\foo')z\\foozntpath.normpath('\\')r3   r]   r^   s    r   test_normpathzTestNtpath.test_normpath<  s   5v>)62.7*H5+X60(;-y9.	:3Y?&.%t,$d+%t,'0/6/8.<0-@-y98:PQ.
;3^DBDYZEG_`?K@,O5;PQ6;PQ8;PQ9;PQ 	/?-{;+Y7(&1r   c                     t        j                  t        j                               }t	        d|       t	        d|       t	        d|       t	        d|       t	        d|       y )Nzntpath.realpath('.')zntpath.realpath('./.')z&ntpath.realpath('/'.join(['.'] * 100))zntpath.realpath('.\.')z&ntpath.realpath('\'.join(['.'] * 100)))r#   normpathr%   getcwdrE   rJ   expecteds     r   test_realpath_curdirzTestNtpath.test_realpath_curdirf  sM    ??299;/%x0'27B((38(Cr   c                    t        j                  t        j                               }t	        dt        j
                  |             t	        dt        j
                  t        j
                  |                   t	        dt        j                  |      d   dz          t	        dt        j
                  t        j
                  |                   t	        dt        j                  |      d   dz          y )Nzntpath.realpath('..')zntpath.realpath('../..')z&ntpath.realpath('/'.join(['..'] * 50))r   r2   zntpath.realpath('..\..')z&ntpath.realpath('\'.join(['..'] * 50)))r#   r   r%   r   rE   dirname
splitdriver   s     r   test_realpath_pardirzTestNtpath.test_realpath_pardirn  s    ??299;/&x(@A)~~fnnX67	97  *1-4	6*~~fnnX67	98  *1-4	6r   zneed _getfinalpathnamec                    t        j                  t        j                        }t	        |d      j                          | j                  t        j                  |       | j                  t        j                  |dz          t        j                  ||dz          | j                  t        j                  |dz         |       | j                  t        j                  t        j                  |dz               t        j                  |             t        j                  D ch c]  }| d	 c}t        t        j                                z
  }|j#                         j%                         }| j'                  t        j                  |      |       | j'                  |dz   t        j                  t        j                  dz   d             y c c}w )Nwb1z:\ spamFstrict)r#   abspathr   TESTFNopenclose
addCleanupunlinkr%   symlinkrM   realpathr:   stringascii_uppercaseset
listdrivespopr<   rI   )rJ   ABSTFNcdrivesds        r   test_realpath_basiczTestNtpath.test_realpath_basicz  sI    	 0 01VT  "	((&1	((&3,7


66C<(V__Vc\:FCV__R[[#-FGV,	.
 &,%;%;<QCs)<s2==??SSJJL!+Q/ 	(*)9)9H)DUS	U =s   "Gc                    t        j                  t        j                        }t	        j
                  |dz   |       | j                  t        j                  |       | j                  t        t         j                  |d       | j                  t        t         j                  |dz   d       | j                  t        t         j                  |dz   d       y )Nr   Tr   2r   )r#   r   r   r   r%   r   r   r   assertRaisesFileNotFoundErrorr   r   rJ   r   s     r   test_realpath_strictzTestNtpath.test_realpath_strict  s    
 	 0 01


6C<(	((&1+V__fTR+V__fslSWX'6??FX4EdSr   c                    t        j                  t        j                        }t	        |d      j                          | j                  t        j                  |       | j                  t        j                  |dz          t        j                  |t        j                  |dz                | j                  t        j                  |dz         |       y )Nr   r   )r#   r   r   r   r   r   r   r   r%   r   relpathrM   r   r   s     r   test_realpath_relativez!TestNtpath.test_realpath_relative  s     	 0 01VT  "	((&1	((&3,7


66>>&3,78V__Vc\:FCr   c                 H	   t        j                  t        j                        }t	        j
                  |       | j                  t        j                  |       t        j                  |      5  t	        j
                  d       t	        j                  d       t	        j                  dd       t	        j                  dd       t	        j                  d       t	        j                  dd       t	        j                  dd       t	        j                  d	d
       t	        j                  dd       t	        j                  dd       t	        j                  |dz   d       t	        j                  dd       | j                  t        j                  d      |dz          | j                  t        j                  d      |dz          | j                  t        j                  d
      |dz          | j                  t        j                  d      |dz          | j                  t        j                  d      |dz          | j                  t        j                  d      |dz          | j                  t        j                  d      |dz          | j                  t        j                  d      |dz          | j                  t        j                  d      t	        j                  |dz                | j                  t        j                  d      t	        j                  |dz                | j                  t        j                  d      t	        j                  |dz                | j                  t        j                  d      t	        j                  |dz                | j                  t        j                  d      t	        j                  |dz                | j                  t        j                  d       t	        j                  |dz                | j                  t        j                  d!      t	        j                  |dz                | j                  t        j                  d"      t	        j                  |dz                d d d        y # 1 sw Y   y xY w)#Nsubdirr   	recursiver   parentrJ   missingbrokenz
broken\barbroken1zself\self\brokenbroken2z"subdir\parent\subdir\parent\brokenbroken3z\brokenbroken4zrecursive\..\brokenbroken5z\missingz
broken\fooz\missing\fooz\broken\barzbroken1\bazz\broken\bar\bazz\self\self\missingz$\subdir\parent\subdir\parent\missings   brokens
   broken\foos   broken1s   broken1\bazs   broken2s   broken3s   broken4s   broken5)r#   r   r   r   r%   mkdirr   rmtree
change_cwdchdirr   rM   r   r:   r   s     r   test_realpath_broken_symlinksz(TestNtpath.test_realpath_broken_symlinks  su    	 0 01
	((&1!!&) 0	DHHXHHXJJsK(JJtX&HHTNJJsF#JJy(+JJ}i0JJ*I6JJ<iHJJv
*I6JJ-y9  !:!'+!57  !?!'/!9;   !<!'.!8:  !@!'*<!<>  !;!'*?!?A  !;!'*Q!QS  !;!'+!57  !;!'+!57   !;!#Vk-A!BD  !@!#Vo-E!FH  !=!#Vn-D!EG  !A!#V6H-H!IK  !<!#V6K-K!LN  !=!#V6]-]!^`  !<!#Vk-A!BD  !<!#Vk-A!BD_0	D 0	D 0	Ds   .P!RR!c                 J   t        j                  t        j                        }| j	                  t        j
                  |       | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          t        j                  ||       | j                  t        j                  |      |       t        j                  |dz   |dz          t        j                  |dz   |dz          |dz   |dz   f}| j                  t        j                  |dz         |       | j                  t        j                  |dz         |       | j                  t        j                  |dz         d |D               | j                  t        j                  |dz         t        j                  |             | j                  t        j                  |d	z         t        j                  |      d
z          t        j                  |dz   |dz          | j                  t        j                  |dz   t        j                  |      z   dz         |dz          | j                  t        j                  |dz   t        j                  |      z   dz         |       t        j                  t        j                  |      dz   |dz          | j                  t        j                  |dz         |dz          t        j                  dt        j                  t        j                  |            z   dz   t        j                  |      z   dz   |dz          | j                  t        j                  |dz         |dz          | j                  t        j                  t        j                  |            |       y )Nr   r   r   r   r   1\xc              3   H   K   | ]  }t        j                  |d         yw)r   N)r#   join)r'   rs     r   r)   z9TestNtpath.test_realpath_symlink_loops.<locals>.<genexpr>  s     A16;;q#.As    "1\..1\..\xz\xr   1\..\a\b..\r2   )r#   r   r   r   r   r   r%   r   rM   r   rQ   r   basename)rJ   r   r   s      r   test_realpath_symlink_loopsz&TestNtpath.test_realpath_symlink_loops  s2    	 0 01	((&1	((&3,7	((&3,7	((&3,7	((&3,7	((&3,7


66"V__V4f=


6C<#.


6C<#.SL&3,/&//&3,7B&//&3,7B&//&6/:AA	CV__Vg-=>#^^F3	5V__Vj-@A#^^F3e;	=


6C<#.V__Vi-?/5v/F.GIL.M N#c\	+ 	&//&9*<,2OOF,C+DFI+J K"	$ 	

6??6*V3Vc\BV__Vc\:FSLI


6FOOFNN6,BCC"OOF3469:;AC<	IV__Vc\:FSLI 	V__V__V-DEvNr   c                    t        j                  t        j                        }| j	                  t        j
                  |       | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          t        j                  ||       | j                  t        t         j                  |d       t        j                  |dz   |dz          t        j                  |dz   |dz          | j                  t        t         j                  |dz   d       | j                  t        t         j                  |dz   d       | j                  t        t         j                  |dz   d       | j                  t        j                  |d	z   d      t        j                  |             | j                  t        t         j                  |d
z   d       t        j                  |dz   |dz          | j                  t        t         j                  |dz   t        j                  |      z   dz   d       | j                  t        t         j                  |dz   t        j                  |      z   dz   d       t        j                  t        j                  |      dz   |dz          | j                  t        t         j                  |dz   d       t        j                  dt        j                  t        j                  |            z   dz   t        j                  |      z   dz   |dz          | j                  t        t         j                  |dz   d       | j                  t        t         j                  t        j                  |      d       y )Nr   r   r   r   r   Tr   r   r   r   r   r   r   r   r2   )r#   r   r   r   r   r   r%   r   r   r   r   rM   r   r   r   s     r   "test_realpath_symlink_loops_strictz-TestNtpath.test_realpath_symlink_loops_strict  s    	 0 01	((&1	((&3,7	((&3,7	((&3,7	((&3,7	((&3,7


66"'6??F4H


6C<#.


6C<#.'6??FSLN'6??FSLN'6??FVODQ 	V__Vg-=dK#^^F3	5'6??FZ4GPTU


6C<#.'6??FY4F/5v/F5GIL5M48 	 	: 	'6?? 9,vv/FFL!% 	 	' 	

6??6*V3Vc\B'6??FSLN


6FOOFNN6,BCC"OOF3469:;AC<	I'6??FSLN 	'6??FOOF4K!% 	 	'r   c                    t        j                  t        j                        }| j	                  t        j
                  |dz          | j	                  t        j
                  d|z   dz          | j	                  t        j
                  |dz          | j	                  t        j
                  |dz          t        |dz   d      5 }|j                  d       d d d        t        j                  |dz   |dz          t        d|z   dz   d      5 }|j                  d       d d d        t        j                  d|z   dz   |dz          | j                  t        j                  |dz         |dz          | j                  t        j                  |dz         d|z   dz          t        t        j                  |dz         d	      5 }| j                  |j                         d       d d d        t        t        j                  |dz         d	      5 }| j                  |j                         d       d d d        | j                  t        j                  d|z   dz         d|z   dz          | j                  t        j                  d|z   dz         d|z   dz          y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)
N3z\\?\z3.3linkz3.linkr      0   1rb)r#   r   r   r   r   r   r   writer%   r   rM   r   rI   read)rJ   r   fs      r   test_realpath_symlink_prefixz'TestNtpath.test_realpath_symlink_prefix=  sX    	 0 01	((&3,7	(()f*<t*CD	((&7*:;	((&8*;<&3,% 	GGDM	


6C<'!12)f$t+T2 	aGGDM	


9v%,fx.?@V__Vg-=>#c\	+V__Vh->?&/$6	8 &//&7"23T: 	-aQVVXt,	-&//&8"34d; 	-qQVVXt,	- 	V__Y-?'-IJ&/#5	7V__Y-?(-JK&/$6	8-	 		 		- 	-	- 	-s0   J
J">!J/	!J;J"J,/J8;Kc                     t        dd       y )Nzntpath.realpath('NUL')r   r]   r^   s    r   test_realpath_nulzTestNtpath.test_realpath_nul_  s    '4r   zneed _getshortpathnamec                 r   t        j                  t        j                        }t        j                  |       t        j
                  |       t        j                  |       | j                  t        j
                  |       t        j                  |d      }t        j                  |       t        |      }t        j                  |d      }t        j                  |d      }t        |d      5 }|j                  d       d d d        | j                  |t        j                  |             t        j                  |      5  | j                  |t        j                  d             d d d        t        j                  |j!                               5  | j                  |t        j                  d             d d d        t        j                  |      5  | j                  |t        j                  d             d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   fxY w# 1 sw Y   y xY w)NMyVeryLongDirectoryNamezfile.txtr   s   content)r#   r   r   r   r   r   r%   r   r   r   r   r   r   rM   r   r   lower)rJ   r   test_dir_longtest_dir_shorttest_file_longtest_file_shortr   s          r   test_realpath_cwdzTestNtpath.test_realpath_cwdc  s    	 0 01  
	((&1F,EF
*=9]J? ++njA.$' 	 1GGJ	  	^V___-MN!!-0 	N  1LM	N!!-"5"5"78 	N  1LM	N!!.1 	N  1LM	N 	N	  	 
	N 	N	N 	N	N 	Ns0   1H&H&H!&H-HH!H*-H6c                 \   t        j                         5 }|j                          d|d<   d|d<   d|d<   t        dd       t        dd	       t        d
d       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd	       t        dd       t        dd       t        dd       t        d d!       t        d"d#       t        d$d%       t        d&d'       d d d        y # 1 sw Y   y xY w)(Nry   rY   baz1z{foobaz2z{foo}zntpath.expandvars("foo")zntpath.expandvars("$foo bar")zbar barzntpath.expandvars("${foo}bar")barbarzntpath.expandvars("$[foo]bar")z	$[foo]barzntpath.expandvars("$bar bar")z$bar barzntpath.expandvars("$?bar")z$?barzntpath.expandvars("$foo}bar")zbar}barzntpath.expandvars("${foo")z${foozntpath.expandvars("${{foo}}")zbaz1}zntpath.expandvars("$foo$foo")zntpath.expandvars("$bar$bar")z$bar$barzntpath.expandvars("%foo% bar")zntpath.expandvars("%foo%bar")zntpath.expandvars("%foo%%foo%")z$ntpath.expandvars("%%foo%%foo%foo%")z%foo%foobarzntpath.expandvars("%?bar%")z%?bar%zntpath.expandvars("%foo%%bar")zbar%barz ntpath.expandvars("'%foo%'%bar")z'%foo%'%barzntpath.expandvars("bar'%foo%")z	bar'%foo%)r   EnvironmentVarGuardclearrE   rJ   envs     r   test_expandvarszTestNtpath.test_expandvars  s   **, 	DIIKCJ CK!CL-u52I>3X>3[A2J?/92I>/92G<2H=2J?3Y?2H=4h?9=I0(;3Y?7I4lC/	D 	D 	Ds   DD""D+zneed os_helper.FS_NONASCIIc                    d }t        j                         5 }|j                          t         j                  }||d<   d|z   ||<    |dd|z          |d|z  d|z          |dd|z          |d	|z  d
|z          |dd|z          |d|z  d|z          |dd|z          |dj	                  |      d|z          |dd|z          |dj	                  |      d
|z         d d d        y # 1 sw Y   y xY w)Nc                 "    t        d| z  |       y )Nzntpath.expandvars(%r)r]   )valuer   s     r   checkz2TestNtpath.test_expandvars_nonascii.<locals>.check  s    *U2H=r   rs   hamz	$spam barz%s barz$%s barz
${spam}barz%sbarz${%s}barzham%sbarz	$spam}barz%s}barz$%s}barz
%spam% barz%{}% barz	ham%s barz	%spam%barz%{}%bar)r   r   r   FS_NONASCIIr   )rJ   r   r   nonasciis       r   test_expandvars_nonasciiz#TestNtpath.test_expandvars_nonascii  s   	>**, 	EIIK ,,H"CK!H,CM+x(23)h&	H(<=,( 23*x'h)>?+x(23)h&	H(<=,8 34*##H-{X/EF+w12)""8,j8.CD	E 	E 	Es   CC..C7c                    t        dd       t        j                         5 }|j                          t        dd       d|d<   d|d<   d	|d
<   t        dd       t        dd       |d= t        dd       t        dd       |j                          d|d<   d	|d
<   t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       |j                          d|d<   d|d<   d	|d
<   t        dd       t        dd       |j                          d|d<   d|d
<   t        dd       t        dd       d d d        y # 1 sw Y   y xY w)Nzntpath.expanduser("test")testzntpath.expanduser("~test")z~testC:\	HOMEDRIVEz
Users\ericHOMEPATHericUSERNAMEzC:\Users\testzntpath.expanduser("~")zC:\Users\ericz
Users\testUSERPROFILEz"ntpath.expanduser("~test\foo\bar")zC:\Users\test\foo\barz"ntpath.expanduser("~test/foo/bar")zC:\Users\test/foo/barzntpath.expanduser("~\foo\bar")zC:\Users\eric\foo\barzntpath.expanduser("~/foo/bar")zC:\Users\eric/foo/barzF:\HOMEidle)rE   r   r   r   r   s     r   test_expanduserzTestNtpath.test_expanduser  s{   *F3**, *	@IIK/9%C+C
O$C
O/1BC+->?K /?+];IIK!2C$C
O/1BC+->?9.07,.5.03,. IIK CK!2C$C
O/1BC+->? IIK!2C$C
O/9+->?U*	@ *	@ *	@s   D*EEzabspath requires 'nt' modulec                 ^   t        dd       t        dd       t        dd       t        dd       t        d	d       t        d
d       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd        t        d!d        t        d"d        t        d#d        t        d$d        t        d%d&       t        d'd(       t        d)d(       t        d*d(       t        d+d(       t        d,d(       t        d-d       t        d.d       t        d/d       t        d0d       t        d1d       t        j                  t        j                        5 }t        d2|       t        d3|d4z          t        d5|d6z          t	        j
                  |      \  }}t        d7|d8z          d d d        y # 1 sw Y   y xY w)9Nzntpath.abspath("C:\")r   z-ntpath.abspath("\\?\C:////spam////eggs. . .")z\\?\C:\spam\eggsz-ntpath.abspath("\\.\C:////spam////eggs. . .")z\\.\C:\spam\eggsz#ntpath.abspath("//spam//eggs. . .")z\\spam\eggsz#ntpath.abspath("\\spam\\eggs. . .")zntpath.abspath("C:/spam. . .")zC:\spamzntpath.abspath("C:\spam. . .")zntpath.abspath("C:/nul")ru   zntpath.abspath("C:\nul")zntpath.abspath("//..")r3   zntpath.abspath("//../")z\\..\zntpath.abspath("//../..")zntpath.abspath("//../../")z\\..\..\zntpath.abspath("//../../../")zntpath.abspath("//../../../..")z ntpath.abspath("//../../../../")zntpath.abspath("//server")z\\serverzntpath.abspath("//server/")z	\\server\zntpath.abspath("//server/..")zntpath.abspath("//server/../")z\\server\..\z ntpath.abspath("//server/../..")z!ntpath.abspath("//server/../../")z#ntpath.abspath("//server/../../..")z$ntpath.abspath("//server/../../../")z ntpath.abspath("//server/share")z\\server\sharez!ntpath.abspath("//server/share/")r   z#ntpath.abspath("//server/share/..")z$ntpath.abspath("//server/share/../")z&ntpath.abspath("//server/share/../..")z'ntpath.abspath("//server/share/../../")zntpath.abspath("C:\nul. . .")zntpath.abspath("//... . .")zntpath.abspath("//.. . . .")zntpath.abspath("//../... . .")zntpath.abspath("//../.. . . .")zntpath.abspath("")zntpath.abspath(" ")z\ zntpath.abspath("?")z\?zntpath.abspath("/abc/")z\abc)rE   r   temp_cwdr   r#   r   )rJ   cwd_dirdrive_s       r   test_abspathzTestNtpath.test_abspath  s	   '0ACZ[ACZ[4:JK8:JK/*=0*=)L9*L9'6:(:>*:>+>B.>B0>B1>B+|D,~F.~F/7IJ17IJ27IJ47IJ57IJ1:MN2:OP4:OP5:OP7:OP8:OP/>,v6-v6/*=0*=	 0 01 	?W'1('E/:('E/:((1HE1,ego>	? 	? 	?s   AH##H,c                    t        dd       t        dd       t        dd       t        dd       t        j                  t        j                        5 }t	        j
                  |      }t        dd	|z   d
z          t        dd	|z   dz          d d d        t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        dd       t        d d       t        d!d       t        d"d       t        d#d       y # 1 sw Y   xY w)$Nzntpath.relpath("a")r   z#ntpath.relpath(ntpath.abspath("a"))zntpath.relpath("a/b")r   zntpath.relpath("../a/b")z..\a\bzntpath.relpath("a", "../b")r   rn   zntpath.relpath("a/b", "../c")z\a\bzntpath.relpath("a", "b/c")z..\..\az*ntpath.relpath("c:/foo/bar/bat", "c:/x/y")z..\..\foo\bar\batz@ntpath.relpath("//conky/mountpoint/a", "//conky/mountpoint/b/c")zntpath.relpath("a", "a")r   z(ntpath.relpath("/foo/bar/bat", "/x/y/z")z..\..\..\foo\bar\batz*ntpath.relpath("/foo/bar/bat", "/foo/bar")batz#ntpath.relpath("/foo/bar/bat", "/")zfoo\bar\batz#ntpath.relpath("/", "/foo/bar/bat")r   z$ntpath.relpath("/foo/bar/bat", "/x")z..\foo\bar\batz$ntpath.relpath("/x", "/foo/bar/bat")z
..\..\..\xzntpath.relpath("/", "/")zntpath.relpath("/a", "/a")zntpath.relpath("/a/b", "/a/b")z"ntpath.relpath("c:/foo", "C:/FOO"))rE   r   r	  r   r#   r   )rJ   r
  
currentdirs      r   test_relpathzTestNtpath.test_relpath  s5   $c*4c:&/):6	 0 01 	PW1J0&2CE2IJ2F:4Eh4NO	P 	+[9;=TUQS^_)3/9;VW;UC4oF4lC57JK5G)3/+S1/53S9#	P 	Ps   :D??Ec                     d } fd} j                  t        t        j                  g         |t        ddg        |t        dd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dgd        |ddgd        |ddgd        |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        |g dd        |g d d        |d!d"g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                 B    t        d| z  j                  dd      |       y )Nzntpath.commonpath(%r)r3   r2   )rE   r8   )pathsr   s     r   r   z)TestNtpath.test_commonpath.<locals>.check$  s"    +e3<<VTJr   c           
          j                  | t        j                  |       j                  | t        j                  |D cg c]  }t        j                  |       c}       y c c}w r"   )r   r#   
commonpathr%   r:   )excr  r(   rJ   s      r   check_errorz/TestNtpath.test_commonpath.<locals>.check_error'  sL    c6#4#4e<c6#4#47<=!r{{1~=?=s   A&zC:\Program FileszProgram FileszC:Program Filesz\Program FileszC:\Program Files\zC:\\Program FileszC:\Program Files\\zC:\.\Program FileszC:\Program Files\.r   zC:\binzC:\Program Files\BarzC:\Program Files\FoozC:\ProjectszC:/Program Files/Barzc:/program files/barzc:\program fileszD:\Program Filesrs   alotr[   and\jamand\spamandzand\\jamz
and\spam\\z	and\.\jamz
.\and\spam)r  r  r  )r  r  r  z	C:and\jamz
C:and\spamzC:andz	spam\alotz
\spam\alots   C:\Program FileszProgram Files\Foos   Program Filess   C:\Program Files\Foos   Program Files\Foo)r   
ValueErrorr#   r  	TypeError)rJ   r   r  s   `  r   test_commonpathzTestNtpath.test_commonpath#  s    		?
 	*f&7&7<J!4o FGJ!46G HIJ!2O DEJ2E FG"#%89"$78:MN$&9:!	#$&;<!	#$&=>!	#%'=>!	#vy!6*"I.7"$<=!	#')AB!	#"N3V<$n5v>')?@!	#')?@!	#%'?@!	# 	J!46I JKvhvv'vv#z;'/|_-u5}n-u5/4.6|]+W5rdBr< "%J^ 45)V%6%6/1IJ	L)V%6%6/1EF	H)V%6%6+-EF	H)V%6%6.0IJ	L)V%6%6.0EF	H)V%6%6*,EF	Hr   z&Emscripten cannot fstat unnamed files.c           	      *   t               5 }t               5 }| j                  t        j                  |j	                         |j	                                      | j                  t        j                  |j	                         |j	                                      t        j                  dk(  r4| j                  t              5  t        j                  dd       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win32)
r	   
assertTruer#   sameopenfilefilenoassertFalsesysplatformr   r   )rJ   tf1tf2s      r   test_sameopenfilezTestNtpath.test_sameopenfileh  s    _ 
	0]_ 
	0OOF//

cjjlKLV00szz|LM||w&&&w/ 0 ''B/0
	0 
	0 
	00 0
	0 
	0 
	0 
	0s;   D	B+C=C1C= D	1C:6C==D	D		Dc                    | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d	             | j                  t        j                  d
             | j                  t        j                  d             | j                  t        j                  d             t        j                         5 }| j                  t        j                  |             d d d        t        j                  dk(  r@t        j                  d      }t        j                  |      \  }}t        j                  |      5  | j                  t        j                  |j                                      | j                  t        j                  |j                                      d d d        | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d             y y # 1 sw Y   _xY w# 1 sw Y   xY w)Nrz   r   r{   zC:/z\\.\c:\z\\.\C:\s   c:\s   C:\s   c:/s   C:/s   \\.\c:\s   \\.\C:\r!  
SystemRootz\\localhost\c$z\\localhost\c$\s   \\localhost\c$s   \\localhost\c$\)r#  r#   ismountr   temp_dirr&  r'  r(  r%   getenvr   r   r   upper)rJ   r   test_cwdr  r   s        r   test_ismountzTestNtpath.test_ismountv  s*   v./v./u-.u-.}56}56w/0w/0v./v./~67~67! 	0QV^^A./	0 <<7" yy.H ++H5KE4%%h/ @  !>?  !>?@ OOFNN+>?@OOFNN+@ABOOFNN+?@AOOFNN+ABC! #	0 	0@ @s   %MA%MMMc                 `    | j                  |j                         |j                                y)z<Assert that two strings are equal ignoring case differences.N)rI   r   )rJ   s1s2s      r   assertEqualCIzTestNtpath.assertEqualCI  s    RXXZ0r   zOS helpers require 'nt' modulec                    t        j                  t        j                        }|t	        j
                  |      fD ]Y  }t        j                  |      }t        j                  |      d   }t        j                  |      d   }| j                  ||       [ t        j                  t        j                        \  }}| j                  |d       | j                  |d       t        j                  t        j                  j                               \  }}	| j                  ||       | j                  |	d       t        j                  t        j                  fD ]  }t        j                  |      }
| j!                  |
t"               | j                  t%        |
      d       t        j                  |j                               }| j!                  |t&               | j                  t%        |      d        y )Nr   )nt_getfinalpathnamer'  
executabler%   r:   _getvolumepathnamer#   r   r7  _getdiskusageexec_prefixassertGreaterr<   rI   prefixassertIsInstancer,   lenr+   )rJ   r;  r   volume_path
path_drivevolume_path_drivecapfreeb_capb_free
final_pathb_final_paths               r   test_nt_helperszTestNtpath.test_nt_helpers  s   
 ))#..9
J 77 	>D//5K**403J & 1 1+ >q Az+<=		> $$S__5	T3"4#(()?)?)ABv$61%ZZ0 	5D--d3J!!*c2s:2//>L!!,6s<0!4	5r   r!  z/Can only test junctions with creation on win32.c                 F   t        j                         5 }t        j                  |      5  t        j                  d       dd l}	 |j                  dd       | j                  t        j                  d             | j                  t        j                  d             | j                  t        j                  d      t        j                  d             d d d        d d d        y # t        $ r t        j                  d      w xY w# 1 sw Y   4xY w# 1 sw Y   y xY w)Ntmpdirr   testjuncz!creating the test junction failed)r   r/  r   r%   r   _winapiCreateJunctionr   unittestSkipTestr#  r#   
isjunctionr&  rM   r   )rJ   r   rP  s      r   test_isjunctionzTestNtpath.test_isjunction  s    ! 	]Q%%a( ]"Q**8Z@  1 1* =>  !2!28!<=$$V__Z%@&//RZB[\]	] 	]  Q"++,OPPQ] ]	] 	]s;   DDC)B DD)DDD	DD z#drive letters are a windows conceptc                     t         j                  j                  d      }|t        |      dk7  s|d   dk7  rt	        j
                  d      | j                  t         j                  j                  d|z                y )NSystemDrive   r~   :z'SystemDrive is not defined or malformedz\\.\)	r%   environgetrB  rR  rS  r&  r   isfile)rJ   r  s     r   test_isfile_driveletterz"TestNtpath.test_isfile_driveletter  s_    

}-=CJ!OuQx3##$MNN	E(9:;r   pipezneed os.pipe()c                 .   t        j                         \  }}	 | j                  t        j                  |             t        j
                  |       t        j
                  |       y # t        j
                  |       t        j
                  |       w xY wr"   )r%   r^  r&  r#   r\  r   )rJ   prpws      r   test_isfile_anonymous_pipez%TestNtpath.test_isfile_anonymous_pipe  s]    B	V]]2./HHRLHHRL HHRLHHRLs   $A( (,Bzwindows onlyc           
         dd l }dt        j                          }|j                  ||j                  dddddd      }	 | j                  t        j                  |             |j                  |       y # |j                  |       w xY w)Nr   z//./PIPE/python_isfile_test_r~   )	rP  r%   getpidCreateNamedPipePIPE_ACCESS_INBOUNDr&  r#   r\  CloseHandle)rJ   rP  
named_pipehs       r   test_isfile_named_pipez!TestNtpath.test_isfile_named_pipe  sx    3BIIK=A
##J$+$?$?$%q!Q16	#V]]:67"G"s   $A5 5Bc                 t   | j                  t        j                  j                  d             | j                  t        j                  j	                  d             | j                  t        j                  j                  d             | j                  t        j                  j                  d             y )Nz\\.\CON)r&  r%   r   r\  isdirislinkr#  existsr^   s    r   test_con_devicezTestNtpath.test_con_device  sl    
34z23
34z23r   zFast paths are only for win32c                    | j                  t        j                  j                  t        j
                  u        | j                  t        j                  t        j                  j                               | j                  t        j                  j                  t        j                  u        | j                  t        j                  t        j                  j                               | j                  t        j                  j                  t        j                  u        | j                  t        j                  t        j                  j                               | j                  t        j                  j                  t        j                  u        | j                  t        j                  t        j                  j                               | j                  t        j                  j                  t        j                   u        | j                  t        j                  t        j                  j                               y r"   )r#  r%   r   r   r9  _path_normpathr&  inspect
isfunctionrl  _path_isdirr\  _path_isfilerm  _path_islinkrn  _path_existsr^   s    r   test_fast_paths_in_usez!TestNtpath.test_fast_paths_in_use  s@    	((B,=,==>++BGG,<,<=>78++BGGMM:;"//9:++BGGNN;<"//9:++BGGNN;<"//9:++BGGNN;<r   r9  zDev Drives only exist on Win32c                 8   | j                  t        j                  t        j                        d       | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  t        j                         d         d       | j                  t        j                  d             | j                  t              5  t        j                  d       d d d        y # 1 sw Y   y xY w)N)TFr      .r   z2\\?\Volume{00000000-0000-0000-0000-000000000000}\\)rO   r#   
isdevdriver   r   r%   listvolumesr&  r   r   r9  _path_isdevdriver^   s    r   test_isdevdrivezTestNtpath.test_isdevdrive   s     	f''	(8(89=If'',m<f''-}=f''(8(;<mL**+`abw' 	W UV	W 	W 	Ws   1DDz'isdevdrive fallback only used off Win32c                 h    | j                  t        j                  t        j                               y r"   )r&  r#   r{  r   r   r^   s    r   test_isdevdrive_fallbackz#TestNtpath.test_isdevdrive_fallback  s#     	**9+;+;<=r   N)8rR   rS   rT   r_   rl   rw   r|   r   r   r   r   r   r   r   skip_unless_symlinkrR  
skipUnlessHAVE_GETFINALPATHNAMEr   r   r   r   r   r   r   r   HAVE_GETSHORTPATHNAMEr   r   r   r   r  r9  r  r  r  skipIfr   r+  r3  r7  rL  r'  r(  rU  r]  r.   r%   rb  rj  ro  r   rx  namer~  r  rU   r   r   rW   rW   Y   sE   
D10XAt
S/"D\L(2TD
6 ""X.0HIU J #U* ""X.0HI	T J #	T ""X.0HID J #D ""X.0HI5D J #5Dn ""X.0HI+O J #+OZ ""X.0HI(' J #('T ""X.0HI8 J #8@ X.0HI5 J5 X.0HIX.0HIN J JN6D4 X..0LME NE&-@b X;<)? =)?V:0CHJ X__]$LM0 N0"DH1 X=>5 ?5: X__S\\W,._`] a] X__S\\W,.ST< U< XV,.>? @ X__S\\W,n=	# >	# X__S\\W,n=4 >4 X__S\\W,.MN=  O= X__RWW_&FGW HW X__RWW_&OP> Q>r   rW   c                       e Zd ZeZdgZy)NtCommonTestr   N)rR   rS   rT   r#   
pathmodule
attributesrU   r   r   r  r    s    JJr   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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_ntpath.PathLikeTests)	r   r   	file_namer   	file_pathr   r   r   r   )rJ   files     r   setUpzPathLikeTests.setUp  sm    "))!)"2"23	(($..9$..$* 	5dJJ34	5 	5 	5s   5BBc                 h    | j                   || j                         || j                               y r"   )rM   r  r  )rJ   funcs     r   _check_functionzPathLikeTests._check_function%  s$    T$..143GHr   c                 
   | j                  | j                  j                         t        j                  dk(  rK| j                  t        j                  d      d       | j                  t        j                  d      d       y y )Nr!  u   ΩΩu   ωΩzabc def)r  r   r$   r'  r(  rI   r#   r^   s    r   test_path_normcasez PathLikeTests.test_path_normcase(  s]    TYY//0<<7"V__^<gFV__\:LI #r   c                 N    | j                  | j                  j                         y r"   )r  r   isabsr^   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 )Nr   br   )rI   r   r   r   r^   s    r   test_path_joinzPathLikeTests.test_path_join1  s;    Xc]C@S#6	8r   c                 N    | j                  | j                  j                         y r"   )r  r   splitr^   s    r   test_path_splitzPathLikeTests.test_path_split5  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   splitextr^   s    r   test_path_splitextz PathLikeTests.test_path_splitext8      TYY//0r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_splitdrivez"PathLikeTests.test_path_splitdrive;      TYY112r   c                 N    | j                  | j                  j                         y r"   )r  r   rv   r^   s    r   test_path_splitrootz!PathLikeTests.test_path_splitroot>  s    TYY001r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_basenamez PathLikeTests.test_path_basenameA  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_dirnamezPathLikeTests.test_path_dirnameD      TYY../r   c                 N    | j                  | j                  j                         y r"   )r  r   rm  r^   s    r   test_path_islinkzPathLikeTests.test_path_islinkG  s    TYY--.r   c                 N    | j                  | j                  j                         y r"   )r  r   lexistsr^   s    r   test_path_lexistszPathLikeTests.test_path_lexistsJ  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   r.  r^   s    r   test_path_ismountzPathLikeTests.test_path_ismountM  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   
expanduserr^   s    r   test_path_expanduserz"PathLikeTests.test_path_expanduserP  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   
expandvarsr^   s    r   test_path_expandvarsz"PathLikeTests.test_path_expandvarsS  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_normpathz PathLikeTests.test_path_normpathV  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_abspathzPathLikeTests.test_path_abspathY  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_realpathz PathLikeTests.test_path_realpath\  r  r   c                 N    | j                  | j                  j                         y r"   )r  r   r   r^   s    r   test_path_relpathzPathLikeTests.test_path_relpath_  r  r   c                     | j                   j                  | j                  | j                  g      }| j	                  || j                         y r"   )r   r  r  r  rM   )rJ   common_paths     r   test_path_commonpathz"PathLikeTests.test_path_commonpathb  s7    ii**DNNDNN+KL[$..9r   c                 N    | j                  | j                  j                         y r"   )r  r   rl  r^   s    r   test_path_isdirzPathLikeTests.test_path_isdirf  r  r   N)rR   rS   rT   r#   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rU   r   r   r  r    sw    D5IJ.8.13210/00331010:.r   r  __main__)$rr  r#   r%   r   r'  rR  r=   test.supportr   r   r   r   test.support.os_helperr   r   r   tempfiler	   r9  ImportErrorr:  r  AttributeErrorr   r  r   r0   rE   TestCaserG   rW   
CommonTestr  r  rR   mainrU   r   r   <module>r     s     	  
   0 2 + ! "!
 !# !
#<03X&& 3y> y>x#..0A0A 
M.N M.` zHMMO s"   
B  "!"  "!"s6    C C C  CCCC C*)C*