
    7bhX                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
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d Z G d dej>                        Z  G d de       Z! G d dejD                  ej>                        Z# G d de       Z$e%dk(  r ejL                          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)ALLOW_MISSING)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       :/opt/python-3.12.12/usr/lib/python3.12/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>5   s"     CdV__R[[^4ds   24)

isinstancebytesstrr&   PathLiker$   r%   r'   hasattrtuple)r   s    r   _normr1   1   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evalr1   r   r-   r&   fsencodedecodeencodewarningscatch_warningssimplefilterDeprecationWarningrepr)fn
wantResult	gotResults      r   testerrF   9   sa   	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                        fd}|S )aq  Simplistic decorator to parametrize a test

    Runs the decorated test multiple times in subTest, with a value from
    'parameters' passed as an extra positional argument.
    Calls doCleanups() after each run.

    Not for general use. Intended to avoid indenting for easier backports.

    See https://discuss.python.org/t/91827 for discussing generalizations.
    c                       fd}|S )Nc                     D ]:  }| j                  |      5   | g||i | d d d        | j                          < y # 1 sw Y   xY wr#   )subTest
doCleanups)selfargskwargs	parameterfunc
parameterss       r   _parameterizedzE_parameterize.<locals>._parametrize_decorator.<locals>._parameterized]   sF    '	\\),::i:6: -! (,,s   AA	 )rP   rR   rQ   s   ` r   _parametrize_decoratorz-_parameterize.<locals>._parametrize_decorator\   s    	"
 r   rS   )rQ   rT   s   ` r   _parameterizerU   Q   s     "!r   c                       e Zd Zd Zd Zy)NtpathTestCasec                 b    ||k(  st        |      t        |      k(  ry | j                  ||       y r#   )r1   assertEqual)rL   path1path2s      r   assertPathEqualzNtpathTestCase.assertPathEqualg   s+    E>U5\U5\9&r   c                 L    | j                  t        |      t        |             y r#   )assertInr1   )rL   r   pathsets      r   assertPathInzNtpathTestCase.assertPathInl   s    eDk5>2r   N)__name__
__module____qualname__r\   r`   rS   r   r   rW   rW   f   s    '
3r   rW   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d Zej$                   ej(                  ed       ei ddidei      d                      Zej$                   ej(                  ed      d               Z ej(                  ed      d        Z ej(                  ed       ei ddidei      d               Zej$                   ej(                  ed       ei ddidei      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       ei ddidei      d                      Z! ej(                  ed      d        Z" ej(                  ed       ej(                  e#d      d               Z$d Z% ej(                  ejL                  d       d!        Z'd" Z( ej(                  e)d#      d$        Z*d% Z+d& Z, ejZ                  e.d'      d(        Z/d) Z0d* Z1 ej(                  e)d+      d,        Z2 ejZ                  e3jh                  d-k7  d.      d/        Z5 ejZ                  e3jh                  d-k7  d0      d1        Z6 ej(                   e7e8d2      d3      d4        Z9 ejZ                  e3jh                  d-k7  d5      d6        Z: ejZ                  e3jh                  d-k7  d5      d7        Z; ejZ                  e3jh                  d-k7  d8      e<d9               Z= ejZ                  e8j|                  d:k7  d;      d<        Z? ejZ                  e8j|                  d:k(  d=      d>        Z@y?)@
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/foorh   zntpath.splitext(".ext"))rh    zntpath.splitext("\foo.ext\foo"))z\foo.ext\foori   zntpath.splitext("foo.ext\"))zfoo.ext\ri   zntpath.splitext("")ri   ri   zntpath.splitext("foo.bar.ext"))zfoo.barrh   z!ntpath.splitext("xx/foo.bar.ext"))z
xx/foo.barrh   z!ntpath.splitext("xx\foo.bar.ext"))z
xx\foo.barrh   zntpath.splitext("c:a/b\c.d"))zc:a/b\cz.drF   rL   s    r   test_splitextzTestNtpath.test_splitextq   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('')rj   zntpath.splitdrive('foo'))ri   rg   zntpath.splitdrive('foo\bar'))ri   foo\barzntpath.splitdrive('foo/bar'))ri   foo/barzntpath.splitdrive('\'))ri   r3   zntpath.splitdrive('/'))ri   /zntpath.splitdrive('\foo\bar'))ri   \foo\barzntpath.splitdrive('/foo/bar'))ri   /foo/barzntpath.splitdrive("c:foo\bar"))c:ro   zntpath.splitdrive("c:foo/bar"))rt   rp   zntpath.splitdrive("c:\foo\bar"))rt   rr   zntpath.splitdrive("c:/foo/bar"))rt   rs   zntpath.splitdrive('\\'))r4   ri   zntpath.splitdrive('//'))//ri   z/ntpath.splitdrive("\\conky\mountpoint\foo\bar"))\\conky\mountpointrr   z/ntpath.splitdrive("//conky/mountpoint/foo/bar"))//conky/mountpointrs   z-ntpath.splitdrive("\\?\UNC\server\share\dir"))\\?\UNC\server\sharez\dirz-ntpath.splitdrive("//?/UNC/server/share/dir"))//?/UNC/server/sharez/dirrk   rl   s    r   test_splitdrivezTestNtpath.test_splitdrive}   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(''))ri   ri   ri   zntpath.splitroot('foo'))ri   ri   rg   zntpath.splitroot('foo\bar'))ri   ri   ro   zntpath.splitroot('foo/bar'))ri   ri   rp   zntpath.splitroot('\'))ri   r3   ri   zntpath.splitroot('/'))ri   rq   ri   zntpath.splitroot('\foo\bar'))ri   r3   ro   zntpath.splitroot('/foo/bar'))ri   rq   rp   zntpath.splitroot("c:foo\bar"))rt   ri   ro   zntpath.splitroot("c:foo/bar"))rt   ri   rp   zntpath.splitroot("c:\foo\bar"))rt   r3   ro   zntpath.splitroot("c:/foo/bar"))rt   rq   rp   zntpath.splitroot('c:\\a'))rt   r3   \azntpath.splitroot('c:\\\a/b'))rt   r3   z\\a/bzntpath.splitroot('c:/\'))rt   rq   r3   zntpath.splitroot('c:\/'))rt   r3   rq   zntpath.splitroot('/\a/b\/\'))z/\a/br3   z/\zntpath.splitroot('\/a\b/\/'))z\/a\brq   z\/zntpath.splitroot('\\'))r4   ri   ri   zntpath.splitroot('//'))ru   ri   ri   z.ntpath.splitroot("\\conky\mountpoint\foo\bar"))rv   r3   ro   z.ntpath.splitroot("//conky/mountpoint/foo/bar"))rw   rq   rp   z/ntpath.splitroot("\\\conky\mountpoint\foo\bar"))z\\\conkyr3   mountpoint\foo\barz/ntpath.splitroot("///conky/mountpoint/foo/bar"))z///conkyrq   mountpoint/foo/barz/ntpath.splitroot("\\conky\\mountpoint\foo\bar"))z\\conky\r3   r}   z/ntpath.splitroot("//conky//mountpoint/foo/bar"))z//conky/rq   r~   u   //conky/MOUNTPOİNT/foo/bar)u   //conky/MOUNTPOİNTrq   rp   zntpath.splitroot("//?/c:"))//?/c:ri   ri   zntpath.splitroot("//./c:"))z//./c:ri   ri   zntpath.splitroot("//?/c:/"))r   rq   ri   zntpath.splitroot("//?/c:/dir"))r   rq   dirzntpath.splitroot("//?/UNC"))z//?/UNCri   ri   zntpath.splitroot("//?/UNC/"))z//?/UNC/ri   ri   z#ntpath.splitroot("//?/UNC/server/"))z//?/UNC/server/ri   ri   z(ntpath.splitroot("//?/UNC/server/share"))ry   ri   ri   z,ntpath.splitroot("//?/UNC/server/share/dir"))ry   rq   r   zIntpath.splitroot("//?/VOLUME{00000000-0000-0000-0000-000000000000}/spam"))z0//?/VOLUME{00000000-0000-0000-0000-000000000000}rq   spamz&ntpath.splitroot("//?/BootPartition/"))z//?/BootPartitionrq   ri   z&ntpath.splitroot("//./BootPartition/"))z//./BootPartitionrq   ri   z&ntpath.splitroot("//./PhysicalDrive0"))z//./PhysicalDrive0ri   ri   zntpath.splitroot("//./nul"))z//./nulri   ri   zntpath.splitroot("\\?\c:"))\\?\c:ri   ri   zntpath.splitroot("\\.\c:"))z\\.\c:ri   ri   zntpath.splitroot("\\?\c:\"))r   r3   ri   zntpath.splitroot("\\?\c:\dir"))r   r3   r   zntpath.splitroot("\\?\UNC"))z\\?\UNCri   ri   zntpath.splitroot("\\?\UNC\"))z\\?\UNC\ri   ri   z#ntpath.splitroot("\\?\UNC\server\"))z\\?\UNC\server\ri   ri   z(ntpath.splitroot("\\?\UNC\server\share"))rx   ri   ri   z,ntpath.splitroot("\\?\UNC\server\share\dir"))rx   r3   r   zIntpath.splitroot("\\?\VOLUME{00000000-0000-0000-0000-000000000000}\spam"))z0\\?\VOLUME{00000000-0000-0000-0000-000000000000}r3   r   z&ntpath.splitroot("\\?\BootPartition\"))z\\?\BootPartitionr3   ri   z&ntpath.splitroot("\\.\BootPartition\"))z\\.\BootPartitionr3   ri   z&ntpath.splitroot("\\.\PhysicalDrive0"))z\\.\PhysicalDrive0ri   ri   zntpath.splitroot("\\.\nul"))\\.\nulri   ri   zntpath.splitroot("//")zntpath.splitroot("///"))z///ri   ri   zntpath.splitroot("///y"))z///yri   ri   zntpath.splitroot("//x"))z//xri   ri   zntpath.splitroot("//x/"))z//x/ri   ri   zntpath.splitroot(" :/foo"))z :rq   rg   zntpath.splitroot("/:/foo"))ri   rq   z:/foo)rF   rY   r$   	splitrootrl   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\foor   zntpath.split("c:\"))c:\ri   z#ntpath.split("\\conky\mountpoint\"))z\\conky\mountpoint\ri   zntpath.split("c:/"))c:/ri   z#ntpath.split("//conky/mountpoint/"))z//conky/mountpoint/ri   rk   rl   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:")rk   rl   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/spamrk   rl   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("")ri   zntpath.join("", "", "")zntpath.join("a")azntpath.join("/a")z/azntpath.join("\a")r|   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)
ri   za/bz/a/brt   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')rk   )rL   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WS 	?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('/')r3   zntpath.normpath('c:/')r   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('\\')r4   rk   rl   s    r   test_normpathzTestNtpath.test_normpathS  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&   getcwdrF   rL   expecteds     r   test_realpath_curdirzTestNtpath.test_realpath_curdir}  sM    ??299;/%x0'27B((38(Cr   c                     t        j                  t        j                               }t	        d|       t	        d|       t	        d|       t	        d|       t	        d|       y )Nz!ntpath.realpath('.', strict=True)z#ntpath.realpath('./.', strict=True)z3ntpath.realpath('/'.join(['.'] * 100), strict=True)z#ntpath.realpath('.\.', strict=True)z3ntpath.realpath('\'.join(['.'] * 100), strict=True)r   r   s     r   test_realpath_curdir_strictz&TestNtpath.test_realpath_curdir_strict  sM    ??299;/2H=4h?DhO5x@ExPr   c                     t        j                  t        j                               }t	        d|       t	        d|       t	        d|       t	        d|       t	        d|       y )Nz*ntpath.realpath('.', strict=ALLOW_MISSING)z,ntpath.realpath('./.', strict=ALLOW_MISSING)z<ntpath.realpath('/'.join(['.'] * 100), strict=ALLOW_MISSING)z,ntpath.realpath('.\.', strict=ALLOW_MISSING)z<ntpath.realpath('\'.join(['.'] * 100), strict=ALLOW_MISSING)r   r   s     r   test_realpath_curdir_missing_okz*TestNtpath.test_realpath_curdir_missing_ok  s\    ??299;/;	=	M	>	N	r   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   r3   zntpath.realpath('..\..')z&ntpath.realpath('\'.join(['..'] * 50))r$   r   r&   r   rF   dirname
splitdriver   s     r   test_realpath_pardirzTestNtpath.test_realpath_pardir  s    ??299;/&x(@A)~~fnnX67	97  *1-4	6*~~fnnX67	98  *1-4	6r   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('..', strict=True)z%ntpath.realpath('../..', strict=True)z3ntpath.realpath('/'.join(['..'] * 50), strict=True)r   r3   z%ntpath.realpath('..\..', strict=True)z3ntpath.realpath('\'.join(['..'] * 50), strict=True)r   r   s     r   test_realpath_pardir_strictz&TestNtpath.test_realpath_pardir_strict  s    ??299;/3V^^H5MN6~~fnnX67	9D  *1-4	67~~fnnX67	9E  *1-4	6r   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('..', strict=ALLOW_MISSING)z.ntpath.realpath('../..', strict=ALLOW_MISSING)z<ntpath.realpath('/'.join(['..'] * 50), strict=ALLOW_MISSING)r   r3   z.ntpath.realpath('..\..', strict=ALLOW_MISSING)z<ntpath.realpath('\'.join(['..'] * 50), strict=ALLOW_MISSING)r   r   s     r   test_realpath_pardir_missing_okz*TestNtpath.test_realpath_pardir_missing_ok  s    ??299;/<~~h'	)?~~fnnX67	9M  *1-4	6@~~fnnX67	9N  *1-4	6r   zneed _getfinalpathnamestrictTc                 T   t        j                  t        j                        }t	        |d      j                          | j                  t        j                  |       | j                  t        j                  |dz          t        j                  ||dz          | j                  t        j                  |dz   fi ||       | j                  t        j                  t        j                  |dz         fi |t        j                  |             t        j                  D ch c]  }| d	 c}t        t        j                                z
  }|j#                         j%                         }| j'                  t        j                  |d      |       |rF| j)                  t*              5  t        j                  t        j                  dz   fi | d d d        y | j'                  |dz   t        j                  t        j                  dz   fi |       y c c}w # 1 sw Y   y xY w)Nwb1z:\Fr   z spam)r$   abspathr   TESTFNopenclose
addCleanupunlinkr&   symlinkr\   realpathr;   stringascii_uppercaseset
listdrivespopr=   rY   assertRaisesr   )rL   rN   ABSTFNcdrivesds         r   test_realpath_basiczTestNtpath.test_realpath_basic  s    	 0 01VT  "	((&1	((&3,7


66C<(V__Vc\DVDfMV__R[[#-FQ&QV,	.
 &,%;%;<%;QCs)%;<s2==??SSJJL!591= ""7+	 0 08 ; *"(* ,+ Vh. &	0@0@80K Vv VX = ,+s   $H-(HH'c                 ^   t        j                  t        j                        }t	        j
                  |dz   |       | j                  t        j                  |       | j                  t        t         j                  |d       | j                  t        t         j                  |dz   d       y )Nr   Tr   2)r$   r   r   r   r&   r   r   r   r   FileNotFoundErrorr   rL   r   s     r   test_realpath_strictzTestNtpath.test_realpath_strict  s{    
 	 0 01


6C<(	((&1+V__fTR+V__fslSWXr   c                    t         j                  }t        j                  t        j                        }t        j                  |      }|dz   }| j                   ||d      |       | j                  t        t         j                  |d       | j                  t        t         j                  |t               |dz   }| j                   ||d      |       | j                  t        t         j                  |d       | j                  t        t         j                  |t               |dz   }| j                   ||d      |       | j                  t        t         j                  |d       | j                  t        t         j                  |t               |dz   }| j                   ||d      |       | j                  t        t         j                  |d       | j                  t        t         j                  |t               |dz   }| j                   ||d      t        j                                | j                   ||d      t        j                                | j                   ||t              t        j                                |d	z   }| j                   ||d      t        j                                | j                   ||d      t        j                                | j                   ||t              t        j                                |d
z   }| j                   ||d      |dz          | j                  t        t         j                  |d       | j                   ||t              |dz          |dz   }| j                   ||d      |dz          | j                  t        t         j                  |d       | j                   ||t              |dz          y )N Fr   T    z\nonexistent\x s   \nonexistent\x z \..s    \..z\nonexistent\x \..z\nonexistents   \nonexistent\x \..s   \nonexistent)r$   r   r   r   r   r&   r;   rY   r   r   r   r   getcwdb)rL   r   r   ABSTFNbr   s        r   test_realpath_invalid_pathsz&TestNtpath.test_realpath_invalid_paths  s
   ??	 0 01++f%$u5t<'6??DF'6??DO $u5t<'6??DF'6??DO..$u5t<'6??DF'6??DO00$u5t<'6??DF'6??DO
"$u5ryy{C$t4biikB$}=ryy{K$$u5rzz|D$t4bjjlC$}=rzz|L22$u5v7OP'6??DF$}=v?WX44$u5wAQ7QR'6??DF$}=wIY?YZr   c                 ,   t         j                  }t        j                  t        j                        }t        j                  |      }|dz   } | j                  t        t         j                  |fi |  | j                  t        t         j                  |fi | |dz   } | j                  t        t         j                  |fi |  | j                  t        t         j                  |fi | |dz   } | j                  t        t         j                  |fi |  | j                  t        t         j                  |fi | |dz   } | j                  t        t         j                  |fi |  | j                  t        t         j                  |fi | y )N   s   \nonexistent\s   \..s   \nonexistent\\..)	r$   r   r   r   r   r&   r;   r   UnicodeDecodeError)rL   rN   r   r   r   r   s         r   #test_realpath_invalid_unicode_pathsz.TestNtpath.test_realpath_invalid_unicode_paths  sI    ??	 0 01++f% ,footNvN,footNvN//,footNvN,footNvN$,footNvN,footNvN33,footNvN,footNvNr   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   fi ||       y )Nr   r   )r$   r   r   r   r   r   r   r   r&   r   relpathr\   r   )rL   rN   r   s      r   test_realpath_relativez!TestNtpath.test_realpath_relative"  s     	 0 01VT  "	((&1	((&3,7


66>>&3,78V__Vc\DVDfMr   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   parentrL   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   r\   r   r;   r   s     r   test_realpath_broken_symlinksz(TestNtpath.test_realpath_broken_symlinks.  sh    	 0 01
	((&1!!&)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_ *))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     A16;;q#.s    "1\..1\..\x\xr   1\..\a\b..\r3   )r$   r   r   r   r   r   r&   r   r\   r   r`   r   basename)rL   r   r   s      r   test_realpath_symlink_loopsz&TestNtpath.test_realpath_symlink_loopsg  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   r3   )r$   r   r   r   r   r   r&   r   r   r   r   r\   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
                  |       | 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          | j	                  t        j
                  |dz          t        j                  ||       | j                  t        t         j                  |t               t        j                  |dz   |dz          t        j                  |dz   |dz          | j                  t        t         j                  |dz   t               | j                  t        t         j                  |dz   t               | j                  t        t         j                  |dz   t               | 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        t         j                  |dz   t        j                  |      z   dz   t               t        j                  t        j                  |      dz   |dz          | j                  t        t         j                  |dz   t               t        j                  dt        j                  t        j                  |            z   dz   t        j                  |      z   dz   |dz          | j                  t        t         j                  |dz   t               | j                  t        t         j                  t        j                  |      t               y )Nr   r   r   r   r   r   r   r   r   r   r   r   r   r   r3   )r$   r   r   r   r   r   r&   r   r   r   r   r   r\   r   r   r   s     r   !test_realpath_symlink_loops_raisez,TestNtpath.test_realpath_symlink_loops_raise  sT    	 0 01	((&1	((&3,7	((&3,7	((&3,7	((&3,7	((&3,7	((&3,7


66"'6??F=Q


6C<#.


6C<#.'6??FSL#0 	 	2'6??FSL#0 	 	2'6??FVO#0 	 	2
 	V__Vg-=>#^^F3	5V__Vj-@A#^^F3e;	= 	

6C<#.V__Vi-?/5v/F.GIL.M N#c\	+ 	V__Y!883>  	 	"
 	

6??6*V3Vc\B'6??FSL#0 	 	2 	

6FOOFNN6,BCC013678>	F'6??FSL#0 	 	2 	'6??FOOF4K#0 	 	2r   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   fi ||dz          | j                  t        j                  |dz   fi |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   fi |d|z   dz          | j                  t        j                  d|z   dz   fi |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   r\   r   rY   read)rL   rN   r   fs       r   test_realpath_symlink_prefixz'TestNtpath.test_realpath_symlink_prefix  sN    	 0 01	((&3,7	(()f*<t*CD	((&7*:;	((&8*;<&3,%GGDM &


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


9v%,fx.?@V__Vg-=HH#c\	+V__Vh->I&I&/$6	8 &//&7"23T:aQVVXt, ;&//&8"34d;qQVVXt, < 	V__Y-?'-ITVT&/#5	7V__Y-?(-JUfU&/$6	8- &% 32 ;:;;s0   J
J& !J3!J?J#&J03J<?Kc                 d    t        dd       t        dd       t        dd       t        dd       y )Nzntpath.realpath('NUL')r   z$ntpath.realpath('NUL', strict=False)z#ntpath.realpath('NUL', strict=True)z,ntpath.realpath('NUL', strict=ALLOW_MISSING)rk   rl   s    r   test_realpath_nulzTestNtpath.test_realpath_nul  s.    '45zB4jA=zJr   zneed _getshortpathnamec                    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                  |             i ddidt        ifD ]  } | j                   di |5  t        j"                  |      5  | j                  |t        j                  di |       d d d        t        j"                  |j%                               5  | j                  |t        j                  di |       d d d        t        j"                  |      5  | j                  |t        j                  di |       d d d        d d d         y # 1 sw Y   4xY w# 1 sw Y   xY w# 1 sw Y   pxY w# 1 sw Y   9xY w# 1 sw Y   3xY w)	NMyVeryLongDirectoryNamefile.txtr   s   contentr   TrS   )r
  )r$   r   r   r   r   r   r&   r   r   r   r   r   r  r\   r   r   rJ   r   lower)rL   r   test_dir_longtest_dir_shorttest_file_longtest_file_shortr  rN   s           r   test_realpath_cwdzTestNtpath.test_realpath_cwd"  s    	 0 01  
	((&1F,EF
*=9]J? ++njA.$'1GGJ ( 	^V___-MN8T*X},EEF''))-8((&=f=? 9 ))-*=*=*?@((&=f=? A )).9((&=f=? : (' F (' 98 A@ :9 ('s`   1H5I&(&I+I&9&II&<&I"I&5H?II&II&I#I&&I0	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)(Nr   rg   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clearrF   rL   envs     r   test_expandvarszTestNtpath.test_expandvarsG  s   **,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/ -,,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)rk   )valuer   s     r   checkz2TestNtpath.test_expandvars_nonascii.<locals>.checkc  s    *U2H=r   r   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   )rL   r  r  nonasciis       r   test_expandvars_nonasciiz#TestNtpath.test_expandvars_nonasciia  s   	>**,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 -,,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)rF   r   r  r  r  s     r   test_expanduserzTestNtpath.test_expanduseru  sn   *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       | j                  t        j                  t        j                  d                   | j                  t        j                  d      t        j                  t        j                  d      d             | j                  t        j                  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        d2d.       t        d3d       t        d4d       t        d5d       t        d6d       t        d7d       t        j                  t        j                        5 }t        d8|       t        d9|d:z          t        d;|d<z          t        j                  |      \  }}t        d=|d>z          d d d        y # 1 sw Y   y xY w)?Nz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")r   zntpath.abspath("C:\nul")zC:spamzC: zC:r   z :spamz :\spamzntpath.abspath("//..")r4   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)rF   
assertTruer$   isabsr   rY   r   r   temp_cwdr   r   )rL   cwd_dirdrive_s       r   test_abspathzTestNtpath.test_abspath  se   '0ACZ[ACZ[4:JK8:JK/*=0*=)L9*L9V^^H%=>?16;;v~~d?SU[3\]4mD'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1W'1('E/:('E/:((1HE1,ego> 211s   0AKK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   r|   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"))rF   r   r0  r   r$   r   )rL   r1  
currentdirs      r   test_relpathzTestNtpath.test_relpath  s*   $c*4c:&/):6	 0 01W1J0&2CE2IJ2F:4Eh4NO 2 	+[9;=TUQS^_)3/9;VW;UC4oF4lC57JK5G)3/+S1/53S9# 21s   :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)r4   r3   )rF   r9   )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)   rL   s      r   check_errorz/TestNtpath.test_commonpath.<locals>.check_error  sP    c6#4#4e<c6#4#47<=u!r{{1~u=?=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 Filesr   alotri   and\jamand\spamandzand\\jamz
and\spam\\z	and\.\jamz
.\and\spam)rA  rB  r@  )rA  rB  rC  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)rL   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
   r.  r$   sameopenfilefilenoassertFalsesysplatformr   r   )rL   tf1tf2s      r   test_sameopenfilezTestNtpath.test_sameopenfile2  s    _]_OOF//

cjjlKLV00szz|LM||w&&&w/ ''B/ 0 &5__ 0/ &5___s;   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)Nr   r$  r   zC:/z\\.\c:\z\\.\C:\s   c:\s   C:\s   c:/s   C:/s   \\.\c:\s   \\.\C:\rH  
SystemRootz\\localhost\c$z\\localhost\c$\s   \\localhost\c$s   \\localhost\c$\)r.  r$   ismountr   temp_dirrL  rM  rN  r&   getenvr   r   r  upper)rL   r   test_cwdr2  r   s        r   test_ismountzTestNtpath.test_ismount@  s   v./v./u-.u-.}56}56w/0w/0v./v./~67~67!QV^^A./ " <<7" yy.H ++H5KE4%%h/  !>?  !>? 0 OOFNN+>?@OOFNN+@ABOOFNN+?@AOOFNN+ABC! # "! 0/s   %MA%MMMc                 `    | j                  |j                         |j                                y)z<Assert that two strings are equal ignoring case differences.N)rY   r  )rL   s1s2s      r   assertEqualCIzTestNtpath.assertEqualCId  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_getfinalpathnamerM  
executabler&   r;   _getvolumepathnamer$   r   r]  _getdiskusageexec_prefixassertGreaterr=   rY   prefixassertIsInstancer-   lenr,   )rL   ra  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_helpersh  s}   
 ))#..9
J 77D//5K**403J & 1 1+ >q Az+<=	 8 $$S__5	T3"4#(()?)?)ABv$61%ZZ0D--d3J!!*c2s:2//>L!!,6s<0!4 1r   rH  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   rU  r   r&   r   _winapiCreateJunctionr   unittestSkipTestr.  r$   
isjunctionrL  r\   r   )rL   r   rv  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getrh  rx  ry  rL  r   isfile)rL   r2  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  rL  r$   r  r   )rL   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   )	rv  r&   getpidCreateNamedPipePIPE_ACCESS_INBOUNDrL  r$   r  CloseHandle)rL   rv  
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)rL  r&   r   r  isdirislinkr.  existsrl   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   r_  _path_normpathrL  inspect
isfunctionr  _path_isdirr  _path_isfiler  _path_islinkr  _path_existsrl   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   r_  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}\\)r^   r$   
isdevdriver   r   r&   listvolumesrL  r   r   r_  _path_isdevdriverl   s    r   test_isdevdrivezTestNtpath.test_isdevdrive  s     	f''	(8(89=If'',m<f''-}=f''(8(;<mL**+`abw' UV (''s   1DDz'isdevdrive fallback only used off Win32c                 h    | j                  t        j                  t        j                               y r#   )rL  r$   r  r   r   rl   s    r   test_isdevdrive_fallbackz#TestNtpath.test_isdevdrive_fallback  s#     	**9+;+;<=r   N)Ara   rb   rc   rm   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   skip_unless_symlinkrx  
skipUnlessHAVE_GETFINALPATHNAMErU   r   r   r   r   r   r   r   r   r   r   r  r  HAVE_GETSHORTPATHNAMEr  r  r  r!  r,  r_  r4  r8  rF  skipIfr   rQ  rY  r]  rr  rM  rN  r{  r  r/   r&   r  r  r  r   r  namer  r  rS   r   r   re   re   p   sQ   
D10XAt
S/"D\L(2TDQ
6
66 ""X.0HI2$'(M)BCX D J #X4 ""X.0HIY J #Y X.0HI%[ J%[N X.0HI2$'(M)BCO D JO" ""X.0HI2$'(M)BCN D J #N ""X.0HI5D J #5Dn ""X.0HI+O J #+OZ ""X.0HI(' J #('T ""X.0HI22 J #22h ""X.0HI2$'(M)BC8 D J #8@ X.0HIK JK X.0HIX.0HI!? J J!?FD4 X..0LME NE&-@b X;<,? =,?\: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   re   c                       e Zd ZeZdgZy)NtCommonTestr   N)ra   rb   rc   r$   
pathmodule
attributesrS   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  )rL   files     r   setUpzPathLikeTests.setUp  sd    "))!)"2"23	(($..9$..$*dJJ34 +**s   5BBc                 h    | j                   || j                         || j                               y r#   )r\   r  r  )rL   rP   s     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 )NrH  u   ΩΩu   ωΩzabc def)r  r   r%   rM  rN  rY   r$   rl   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   r/  rl   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   )rY   r   r   r   rl   s    r   test_path_joinzPathLikeTests.test_path_join  s;    Xc]C@S#6	8r   c                 N    | j                  | j                  j                         y r#   )r  r   splitrl   s    r   test_path_splitzPathLikeTests.test_path_split  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   splitextrl   s    r   test_path_splitextz PathLikeTests.test_path_splitext      TYY//0r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_splitdrivez"PathLikeTests.test_path_splitdrive      TYY112r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_splitrootz!PathLikeTests.test_path_splitroot  s    TYY001r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_basenamez PathLikeTests.test_path_basename  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_dirnamezPathLikeTests.test_path_dirname      TYY../r   c                 N    | j                  | j                  j                         y r#   )r  r   r  rl   s    r   test_path_islinkzPathLikeTests.test_path_islink  s    TYY--.r   c                 N    | j                  | j                  j                         y r#   )r  r   lexistsrl   s    r   test_path_lexistszPathLikeTests.test_path_lexists  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   rT  rl   s    r   test_path_ismountzPathLikeTests.test_path_ismount  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   
expanduserrl   s    r   test_path_expanduserz"PathLikeTests.test_path_expanduser  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   
expandvarsrl   s    r   test_path_expandvarsz"PathLikeTests.test_path_expandvars  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_normpathz PathLikeTests.test_path_normpath   r  r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_abspathzPathLikeTests.test_path_abspath#  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   s    r   test_path_realpathz PathLikeTests.test_path_realpath&  r  r   c                 N    | j                  | j                  j                         y r#   )r  r   r   rl   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  r\   )rL   common_paths     r   test_path_commonpathz"PathLikeTests.test_path_commonpath,  s7    ii**DNNDNN+KL[$..9r   c                 N    | j                  | j                  j                         y r#   )r  r   r  rl   s    r   test_path_isdirzPathLikeTests.test_path_isdir0  r  r   N)ra   rb   rc   r$   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rS   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__)'r  r$   r&   r   
subprocessrM  rx  r>   r   test.supportr   r   r   r   test.support.os_helperr   r#  r	   tempfiler
   r_  ImportErrorr`  r  AttributeErrorr   r  r   r1   rF   rU   TestCaserW   re   
CommonTestr  r  ra   mainrS   r   r   <module>r     s     	   
     0 2 + ! "!
 !# !
#<0"*3X&& 3l> l>^##..0A0A 
M.N M.` zHMMO C)   
B  "!"  "!"s6   
C C  C- CC C*)C*-C76C7