Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_ntpath.cpython-310.pyc

o

0�i���@sjddlZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddlm
Z
ddlmZzddlZWneyMdZYnwzejWney^dZYnwd	ZzddlZWneyrdZYnwd	Zd
d�Zdd
�Zdd�Zdd�ZGdd�dej�ZGdd�de�ZGdd�de
jej�ZGdd�de�Z e!dkr�e�"�dSdS)�N)�
ALLOW_MISSING)�support)�	os_helper)�FakePath)�test_genericpath)�
TemporaryFileFTcCsntjddd�j}tjtjtjg|_tj|_||dd�}|s&td�t�	����t�
|�}||||�}|d|�S)NZkernel32T)Zuse_last_errorrz&failed to get short path name 0x{:08X})�ctypesZWinDLLZGetShortPathNameWZ	c_wchar_pZc_uint32�argtypesZrestype�OSError�formatZget_last_errorZcreate_unicode_buffer)�pathZGSPNZ
result_len�result�r�7/opt/alt/python310/lib64/python3.10/test/test_ntpath.py�_getshortpathname#s
�
rcCsBt|tttjf�rt�t�|��St|d�rt	dd�|D��S|S)N�__iter__css �|]}t�t�|��VqdS�N)�ntpath�normcase�os�fsdecode��.0�prrr�	<genexpr>3s�z_norm.<locals>.<genexpr>)
�
isinstance�bytes�strr�PathLikerrr�hasattr�tuple)rrrr�_norm/s

r!cCs&|�dd�}t|�}||kr&t|�t|�kr&t�dt|�t|�t|�f��|�dd�}|�dd�}|�dd	�}|�d
d�}|�dd
�}|�dd�}t�|��d�}|�	dd��d�}t
���t
�dt
�t|�}Wd�n1stwYt|�t|�kr�t�dt|�t|�t|�f��dS)N�\�\\z%%s should return: %s but returned: %sz('z(b'z("z(b"z['z[b'z["z[b"z, 'z, b'z, "z, b"�latin1�ascii�backslashreplace�ignore)�replace�evalr!rZ
TestFailedrr�fsencode�decode�encode�warnings�catch_warnings�simplefilter�DeprecationWarning�repr)�fnZ
wantResultZ	gotResultrrr�tester7s.�

���r3cs�fdd�}|S)aqSimplistic 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.
    cs��fdd�}|S)Nc	sZ�D](}|�|���|g|�|�Ri|��Wd�n1s!wY|��qdSr)�subTestZ
doCleanups)�self�args�kwargsZ	parameter)�func�
parametersrr�_parameterized[s�
�zE_parameterize.<locals>._parametrize_decorator.<locals>._parameterizedr)r8r:�r9)r8r�_parametrize_decoratorZsz-_parameterize.<locals>._parametrize_decoratorr)r9r<rr;r�
_parameterizeOsr=c@seZdZdd�Zdd�ZdS)�NtpathTestCasecCs,||kst|�t|�krdS|�||�dSr)r!�assertEqual)r5Zpath1Zpath2rrr�assertPathEqualeszNtpathTestCase.assertPathEqualcCs|�t|�t|��dSr)ZassertInr!)r5rZpathsetrrr�assertPathInjszNtpathTestCase.assertPathInN)�__name__�
__module__�__qualname__r@rArrrrr>dsr>c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zeje�ed�eiddidei�dd����Zeje�ed�d d!���Zeje�ed�eiddidei�d"d#����Zeje�ed�d$d%���Zeje�ed�d&d'���Zeje�ed�d(d)���Zeje�ed�d*d+���Zeje�ed�eiddidei�d,d-����Ze�ed�d.d/��Ze�ed�e�e d0�d1d2���Z!d3d4�Z"e�ej#d5�d6d7��Z$e%�&d8�d9d:��Z'd;d<�Z(e�e)d=�d>d?��Z*d@dA�Z+dBdC�Z,dDdE�Z-dFdG�Z.dHdI�Z/e�e)dJ�dKdL��Z0dMS)N�
TestNtpathcCshtdd�tdd�tdd�tdd�td	d
�tdd�td
d�tdd�tdd�tdd�dS)Nzntpath.splitext("foo.ext"))�foo�.extzntpath.splitext("/foo/foo.ext"))z/foo/foorGzntpath.splitext(".ext"))rG�zntpath.splitext("\foo.ext\foo"))z\foo.ext\foorHzntpath.splitext("foo.ext\"))zfoo.ext\rHzntpath.splitext(""))rHrHzntpath.splitext("foo.bar.ext"))zfoo.barrGz!ntpath.splitext("xx/foo.bar.ext"))z
xx/foo.barrGz!ntpath.splitext("xx\foo.bar.ext"))z
xx\foo.barrGzntpath.splitext("c:a/b\c.d"))zc:a/b\cz.d�r3�r5rrr�
test_splitextos








zTestNtpath.test_splitextcCsftdd�tdd�tdd�tdd�td	d
�tdd�td
d�tdd�|�t�d�d�dS)Nzntpath.splitdrive("c:\foo\bar"))�c:�\foo\barzntpath.splitdrive("c:/foo/bar"))rL�/foo/barz/ntpath.splitdrive("\\conky\mountpoint\foo\bar"))z\\conky\mountpointrMz/ntpath.splitdrive("//conky/mountpoint/foo/bar"))z//conky/mountpointrNz0ntpath.splitdrive("\\\conky\mountpoint\foo\bar"))rHz\\\conky\mountpoint\foo\barz0ntpath.splitdrive("///conky/mountpoint/foo/bar"))rHz///conky/mountpoint/foo/barz0ntpath.splitdrive("\\conky\\mountpoint\foo\bar"))rHz\\conky\\mountpoint\foo\barz0ntpath.splitdrive("//conky//mountpoint/foo/bar"))rHz//conky//mountpoint/foo/baru//conky/MOUNTPOİNT/foo/bar)u//conky/MOUNTPOİNTrN)r3r?r�
splitdriverJrrr�test_splitdrive{s6���������zTestNtpath.test_splitdrivecCs@tdd�tdd�tdd�tdd�td	d
�tdd�dS)
Nzntpath.split("c:\foo\bar"))zc:\foo�barz*ntpath.split("\\conky\mountpoint\foo\bar"))z\\conky\mountpoint\foorQzntpath.split("c:\"))�c:\rHz#ntpath.split("\\conky\mountpoint\"))z\\conky\mountpoint\rHzntpath.split("c:/"))�c:/rHz#ntpath.split("//conky/mountpoint/"))z//conky/mountpoint/rHrIrJrrr�
test_split�s
�
�
zTestNtpath.test_splitcC�,tdd�tdd�tdd�tdd�dS)Nzntpath.isabs("c:\")�z#ntpath.isabs("\\conky\mountpoint\")zntpath.isabs("\foo")zntpath.isabs("\foo\bar")rIrJrrr�
test_isabs�s


zTestNtpath.test_isabscCs"tdd�tdd�tdd�dS)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/spamrIrJrrr�test_commonprefix�s���zTestNtpath.test_commonprefixcCs2tdd�tdd�tdd�tdd�tdd	�td
d�tdd
�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�td d�td!d"�td#d$�td%d&�td'd(�td)d*�td+d,�td-d.�td/d0�td1d2�td3d4�td5d6�td7d8�td9d:�td;d<�td=d<�td>d0�td?d0�td@d0�tdAd0�tdBd8�tdCd8�tdDd8�tdEdF�tdGdH�tdIdJ�tdKdL�dMD]}dND]}tdO||f|�q�q�tdPdQ�tdRdQ�tdSdQ�tdTdU�tdVdW�tdXdY�dS)ZNzntpath.join("")rHzntpath.join("", "", "")zntpath.join("a")�azntpath.join("/a")z/azntpath.join("\a")�\azntpath.join("a:")za:zntpath.join("a:", "\b")za:\bzntpath.join("a", "\b")z\bzntpath.join("a", "b", "c")za\b\czntpath.join("a\", "b", "c")zntpath.join("a", "b\", "c")zntpath.join("a", "b", "\c")z\czntpath.join("d:\", "\pleep")zd:\pleepzntpath.join("d:\", "a", "b")zd:\a\bzntpath.join('', 'a')z ntpath.join('', '', '', '', 'a')zntpath.join('a', '')za\z ntpath.join('a', '', '', '', '')zntpath.join('a\', '')z!ntpath.join('a\', '', '', '', '')zntpath.join('a/', '')za/zntpath.join('a/b', 'x/y')za/b\x/yzntpath.join('/a/b', 'x/y')z/a/b\x/yzntpath.join('/a/b/', 'x/y')z/a/b/x/yzntpath.join('c:', 'x/y')zc:x/yzntpath.join('c:a/b', 'x/y')z	c:a/b\x/yzntpath.join('c:a/b/', 'x/y')z	c:a/b/x/yzntpath.join('c:/', 'x/y')zc:/x/yzntpath.join('c:/a/b', 'x/y')z
c:/a/b\x/yzntpath.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/yzntpath.join('a/b', '/x/y')z/x/yzntpath.join('/a/b', '/x/y')zntpath.join('c:', '/x/y')zntpath.join('c:a/b', '/x/y')zntpath.join('c:/', '/x/y')zntpath.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')zntpath.join('c:', 'C:x/y')zC:x/yzntpath.join('c:a/b', 'C:x/y')z	C:a/b\x/yzntpath.join('c:/', 'C:x/y')zC:/x/yzntpath.join('c:/a/b', 'C:x/y')z
C:/a/b\x/y)
rHza/bz/a/brLzc:a/brSzc:/a/bz//computer/sharez//computer/share/z//computer/share/a/b)zd:zd:x/yzd:/zd:/x/yz//machine/commonz//machine/common/z//machine/common/x/yzntpath.join(%r, %r)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/brI)r5�x�yrrr�	test_join�sp













































�




zTestNtpath.test_joincCs�tdd�tdd�tdd�tdd�tdd�td	d
�tdd�td
d�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�td d!�td"d#�td$d%�td&d'�dS)(Nz$ntpath.normpath('A//////././//.//B')zA\Bzntpath.normpath('A/./B')zntpath.normpath('A/foo/../B')zntpath.normpath('C:A//B')zC:A\Bzntpath.normpath('D:A/./B')zD:A\Bzntpath.normpath('e:A/foo/../B')ze:A\Bzntpath.normpath('C:///A//B')zC:\A\Bzntpath.normpath('D:///A/./B')zD:\A\Bz"ntpath.normpath('e:///A/foo/../B')ze:\A\Bzntpath.normpath('..')�..zntpath.normpath('.')�.zntpath.normpath('')zntpath.normpath('/')r"zntpath.normpath('c:/')rRzntpath.normpath('/../.././..')zntpath.normpath('c:/../../..')zntpath.normpath('../.././..')�..\..\..zntpath.normpath('K:../.././..')z
K:..\..\..zntpath.normpath('C:////a/b')zC:\a\bz'ntpath.normpath('//machine/share//a/b')z\\machine\share\a\bzntpath.normpath('\\.\NUL')�\\.\NULzntpath.normpath('\\?\D:/XY\Z')z\\?\D:/XY\ZrIrJrrr�
test_normpath�s,




















zTestNtpath.test_normpathcC�Dt�t���}td|�td|�td|�td|�td|�dS)Nzntpath.realpath('.')zntpath.realpath('./.')z&ntpath.realpath('/'.join(['.'] * 100))zntpath.realpath('.\.')z&ntpath.realpath('\'.join(['.'] * 100))�r�normpathr�getcwdr3�r5�expectedrrr�test_realpath_curdir�



zTestNtpath.test_realpath_curdircCrc)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)rdrgrrr�test_realpath_curdir_strictrjz&TestNtpath.test_realpath_curdir_strictcCrc)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)rdrgrrr�test_realpath_curdir_missing_oks �����z*TestNtpath.test_realpath_curdir_missing_okcC�~t�t���}tdt�|��tdt�t�|���tdt�|�dd�tdt�t�|���tdt�|�dd�dS)Nzntpath.realpath('..')zntpath.realpath('../..')z&ntpath.realpath('/'.join(['..'] * 50))rr"zntpath.realpath('..\..')z&ntpath.realpath('\'.join(['..'] * 50))�rrerrfr3�dirnamerOrgrrr�test_realpath_pardir#�����zTestNtpath.test_realpath_pardircCrm)Nz"ntpath.realpath('..', strict=True)z%ntpath.realpath('../..', strict=True)z3ntpath.realpath('/'.join(['..'] * 50), strict=True)rr"z%ntpath.realpath('..\..', strict=True)z3ntpath.realpath('\'.join(['..'] * 50), strict=True)rnrgrrr�test_realpath_pardir_strict/rqz&TestNtpath.test_realpath_pardir_strictcCrm)Nz+ntpath.realpath('..', strict=ALLOW_MISSING)z.ntpath.realpath('../..', strict=ALLOW_MISSING)z<ntpath.realpath('/'.join(['..'] * 50), strict=ALLOW_MISSING)rr"z.ntpath.realpath('..\..', strict=ALLOW_MISSING)z<ntpath.realpath('\'.join(['..'] * 50), strict=ALLOW_MISSING)rnrgrrr�test_realpath_pardir_missing_ok;s �����z*TestNtpath.test_realpath_pardir_missing_okzneed _getfinalpathname�strictTcCs�t�tj�}t|d���|�tj|�|�tj|d�t�	||d�|�
tj|dfi|��|�|�
tjt�|d�fi|��t�|��dS�N�wb�1)
r�abspathr�TESTFN�open�close�
addCleanup�unlinkr�symlinkr@�realpathr*�r5r7�ABSTFNrrr�test_realpath_basicHs�zTestNtpath.test_realpath_basiccCsZt�tj�}t�|d|�|�tj|�|jt	tj
|dd�|jt	tj
|ddd�dS)NrwT�rt�2)rrxrryrr~r|r}�assertRaises�FileNotFoundErrorr�r5r�rrr�test_realpath_strictVs
zTestNtpath.test_realpath_strictcCsrt�tj�}t|d���|�tj|�|�tj|d�t�	|t�
|d��|�tj|dfi|��|�dSru)
rrxrryrzr{r|r}rr~�relpathr@rr�rrr�test_realpath_relativeas"z!TestNtpath.test_realpath_relativecCsvt�tj�}t�|�|�tj|�t�|���t�d�t�	d�t�
dd�t�
dd�t�	d�t�
dd�t�
dd�t�
d	d
�t�
dd�t�
d
d�t�
|dd�t�
dd�|�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�t�
|d��|�t�d�t�
|d��|�t�d�t�
|d��|�t�d�t�
|d��|�t�d�t�
|d��|�t�d �t�
|d��|�t�d!�t�
|d��|�t�d"�t�
|d��Wd�dS1�s4wYdS)#NZsubdirr_�	recursiver^�parentr5ZmissingZbrokenz
broken\barZbroken1zself\self\brokenZbroken2z"subdir\parent\subdir\parent\brokenZbroken3z\brokenZbroken4zrecursive\..\brokenZbroken5z\missingz
broken\fooz\missing\fooz\broken\barzbroken1\bazz\broken\bar\bazz\self\self\missingz$\subdir\parent\subdir\parent\missingsbrokens
broken\foosbroken1sbroken1\bazsbroken2sbroken3sbroken4sbroken5)rrxrryr�mkdirr|�rmtree�
change_cwd�chdirr~r@rr*r�rrr�test_realpath_broken_symlinksms�



����������������$�z(TestNtpath.test_realpath_broken_symlinkscCsNt�tj�}|�tj|�|�tj|d�|�tj|d�|�tj|d�|�tj|d�|�tj|d�t�||�|�t�	|�|�t�|d|d�t�|d|d�|d|df}|�
t�	|d�|�|�
t�	|d�|�|�
t�	|d�dd�|D��|�t�	|d	�t�|��|�t�	|d
�t�|�d�t�|d|d�|�t�	|d
t�|�d�|d�|�
t�	|d
t�|�d�|�t�t�|�d|d�|�t�	|d�|d�t�dt�t�|��dt�|�d|d�|�t�	|d�|d�|�t�	t�|��|�dS)Nrwr�r\�crY�1\xcss�|]	}t�|d�VqdS)r[N)r�join)r�rrrrr�s�z9TestNtpath.test_realpath_symlink_loops.<locals>.<genexpr>�1\..�1\..\x�\xr[�1\..\�a\b�..\r")
rrxrryr|r}rr~r@rrAro�basename)r5r�rhrrr�test_realpath_symlink_loops�sf�������������z&TestNtpath.test_realpath_symlink_loopscCs6t�tj�}|�tj|�|�tj|d�|�tj|d�|�tj|d�|�tj|d�|�tj|d�t�||�|jt	tj
|dd�t�|d|d�t�|d|d�|jt	tj
|ddd�|jt	tj
|ddd�|jt	tj
|ddd�|�tj
|d	dd�t�|��|jt	tj
|d
dd�t�|d|d�|jt	tj
|dt�
|�ddd�|jt	tj
|dt�
|�ddd�t�t�
|�d
|d�|jt	tj
|ddd�t�dt�
t�|��dt�
|�d|d�|jt	tj
|ddd�|jt	tj
t�
|�dd�dS)Nrwr�r\r�rYTr�r�r�r�r[r�r�r�r")rrxrryr|r}rr~r�r
rr@ror�r�rrr�"test_realpath_symlink_loops_strict�sZ����
�����
�z-TestNtpath.test_realpath_symlink_loops_strictcCsNt�tj�}|�tj|�|�tj|d�|�tj|d�|�tj|d�|�tj|d�|�tj|d�|�tj|d�t�||�|jt	tj
|td�t�|d|d�t�|d|d�|jt	tj
|dtd�|jt	tj
|dtd�|jt	tj
|dtd�|�t�
|d	�t�
|��|�t�
|d
�t�
|�d�t�|d|d�|�t�
|dt�|�d�|d�|jt	tj
|dt�|�dtd�t�t�|�d
|d�|jt	tj
|dtd�t�dt�t�
|��dt�|�d|d�|jt	tj
|dtd�|jt	tj
t�|�td�dS)Nrwr�r\r�rYr[r�r�r�r�r�r�r�r�r")rrxrryr|r}rr~r�r
rrr@ror�r�rrr�!test_realpath_symlink_loops_raisesv���������������
�z,TestNtpath.test_realpath_symlink_loops_raisecCs t�tj�}|�tj|d�|�tjd|d�|�tj|d�|�tj|d�t|dd��
}|�d�Wd�n1sCwYt�	|d|d�td|dd��
}|�d�Wd�n1skwYt�	d|d|d�|�
tj|dfi|��|d�|�
tj|dfi|��d|d�tt�|d�d	��}|�|�
�d�Wd�n1s�wYtt�|d�d	��}|�|�
�d�Wd�n1s�wY|�
tjd|dfi|��d|d�|�
tjd|dfi|��d|d�dS)
N�3z\\?\z3.Z3linkz3.linkrv�0�1�rb)rrxrryr|r}rz�writerr~r@rr?�read)r5r7r��frrr�test_realpath_symlink_prefix7s>���
���
�
�z'TestNtpath.test_realpath_symlink_prefixcCrU)Nzntpath.realpath('NUL')raz$ntpath.realpath('NUL', strict=False)z#ntpath.realpath('NUL', strict=True)z,ntpath.realpath('NUL', strict=ALLOW_MISSING)rIrJrrr�test_realpath_nulZs


zTestNtpath.test_realpath_nulzneed _getshortpathnamec
Cs�t�tj�}t�|�t�|�t�|�|�tj|�t�	|d�}t�|�t
|�}t�	|d�}t�	|d�}t|d��
}|�d�Wd�n1sLwY|�
|t�|��iddidtifD]}|jdi|���mt�|��|�
|tjdi|���Wd�n1s�wYt�|����|�
|tjdi|���Wd�n1s�wYt�|��|�
|tjdi|���Wd�n1s�wYWd�n1s�wYqcdS)	NZMyVeryLongDirectoryName�file.txtrvscontentrtTr)r�)rrxrryr}r�rr�r|r�rrzr�r@rrr4r��lower)r5r�Z
test_dir_longZtest_dir_shortZtest_file_longZtest_file_shortr�r7rrr�test_realpath_cwdasL



�����������zTestNtpath.test_realpath_cwdcCst���x}|��d|d<d|d<d|d<tdd�tdd	�td
d�tdd
�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd	�tdd�tdd�tdd�td d!�td"d#�td$d%�td&d'�Wd�dS1swYdS)(NrQrFZbaz1z{fooZbaz2z{foo}zntpath.expandvars("foo")zntpath.expandvars("$foo bar")zbar barzntpath.expandvars("${foo}bar")Zbarbarzntpath.expandvars("$[foo]bar")z	$[foo]barzntpath.expandvars("$bar bar")z$bar barzntpath.expandvars("$?bar")z$?barzntpath.expandvars("$foo}bar")zbar}barzntpath.expandvars("${foo")z${foozntpath.expandvars("${{foo}}")zbaz1}zntpath.expandvars("$foo$foo")zntpath.expandvars("$bar$bar")z$bar$barzntpath.expandvars("%foo% bar")zntpath.expandvars("%foo%bar")zntpath.expandvars("%foo%%foo%")z$ntpath.expandvars("%%foo%%foo%foo%")z%foo%foobarzntpath.expandvars("%?bar%")z%?bar%zntpath.expandvars("%foo%%bar")zbar%barz ntpath.expandvars("'%foo%'%bar")z'%foo%'%barzntpath.expandvars("bar'%foo%")z	bar'%foo%)r�EnvironmentVarGuard�clearr3�r5�envrrr�test_expandvars�s2


















"�zTestNtpath.test_expandvarszneed os_helper.FS_NONASCIIcCs�dd�}t���l}|��tj}||d<d|||<|dd|�|d|d|�|dd	|�|d
|d|�|dd
|�|d|d|�|dd|�|d�|�d|�|dd	|�|d�|�d|�Wd�dS1swwYdS)NcSstd||�dS)Nzntpath.expandvars(%r)rI)�valuerhrrr�check��z2TestNtpath.test_expandvars_nonascii.<locals>.check�spamZhamz	$spam barz%s barz$%s barz
${spam}barz%sbarz${%s}barzham%sbarz	$spam}barz%s}barz$%s}barz
%spam% barz%{}% barz	ham%s barz	%spam%barz%{}%bar)rr�r��FS_NONASCIIr)r5r�r�Znonasciirrr�test_expandvars_nonascii�s"
"�z#TestNtpath.test_expandvars_nonasciiZcpucCs�tj}t���S}|��d|d<d}|�|d|�d|�|�|d|�d|�|�|d|d�d|d	�|�|d|�d	|�|�|d
|�d|�Wd�dS1s]wYdS)N�B�Ai��z%A%z%A%AZBAz''z%%�%z$$�$)r�
expandvarsrr�r�r?)r5r�r��nrrr�test_expandvars_large�s
 "�z TestNtpath.test_expandvars_largecCsDtdd�t����}|��tdd�d|d<d|d<d	|d
<tdd�tdd
�|d=tdd�tdd�|��d
|d<d	|d
<tdd�tdd
�tdd�tdd�tdd�tdd�|��d|d<d
|d<d	|d
<tdd�tdd
�|��d
|d<d|d
<tdd�tdd
�Wd�dS1s�wYdS)Nzntpath.expanduser("test")�testzntpath.expanduser("~test")z~test�C:\Z	HOMEDRIVEz
Users\ericZHOMEPATHZericZUSERNAMEz
C:\Users\testzntpath.expanduser("~")z
C:\Users\ericz
Users\testZUSERPROFILEz"ntpath.expanduser("~test\foo\bar")zC:\Users\test\foo\barz"ntpath.expanduser("~test/foo/bar")zC:\Users\test/foo/barzntpath.expanduser("~\foo\bar")zC:\Users\eric\foo\barzntpath.expanduser("~/foo/bar")zC:\Users\eric/foo/barzF:\�HOMEZidle)r3rr�r�r�rrr�test_expanduser�sR








����


"�zTestNtpath.test_expanduserzabspath requires 'nt' modulecCs~tdd�t�tj��*}td|�td|d�td|d�t�|�\}}td|d	�Wd�dS1s8wYdS)
Nzntpath.abspath("C:\")r�zntpath.abspath("")zntpath.abspath(" ")z\ zntpath.abspath("?")z\?zntpath.abspath("/abc/")z\abc)r3r�temp_cwdryrrO)r5�cwd_dir�drive�_rrr�test_abspath�s

"�zTestNtpath.test_abspathcCstdd�tdd�tdd�tdd�t�tj��}t�|�}tdd	|d
�tdd	|d�Wd�n1s<wYtd
d�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�tdd�td d�td!d�td"d�td#d�dS)$Nzntpath.relpath("a")rYz#ntpath.relpath(ntpath.abspath("a"))zntpath.relpath("a/b")r�zntpath.relpath("../a/b")z..\a\bzntpath.relpath("a", "../b")r�rZzntpath.relpath("a/b", "../c")z\a\bzntpath.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")zntpath.relpath("a", "a")r_z(ntpath.relpath("/foo/bar/bat", "/x/y/z")z..\..\..\foo\bar\batz*ntpath.relpath("/foo/bar/bat", "/foo/bar")Zbatz#ntpath.relpath("/foo/bar/bat", "/")zfoo\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
..\..\..\xzntpath.relpath("/", "/")zntpath.relpath("/a", "/a")zntpath.relpath("/a/b", "/a/b")z"ntpath.relpath("c:/foo", "C:/FOO"))r3rr�ryrr�)r5r�Z
currentdirrrr�test_relpath�s.




�












zTestNtpath.test_relpathcsZdd�}�fdd�}��ttjg�|tddg�|tddg�|tddg�|tddg�|dgd�|ddgd�|d	dgd�|d	d	gd�|d
dgd�|dd
gd�|ddgd�|ddgd�|ddgd�|ddgd�|ddgd�|d	dgd�|ddgd�|ddgd�|ddgd�|tddg�|dgd�|ddgd�|ddgd�|ddgd�|ddgd�|dd gd�|gd!�d�|gd"�d�|d#d$gd%�|dgd�|dd&gd�|tdd'g���ttjd(dg���ttjd(d)g���ttjd*dg���ttjdd+g���ttjdd,g���ttjdd+g�dS)-NcSstd|�dd�|�dS)Nzntpath.commonpath(%r)r#r")r3r()�pathsrhrrrr�s�z)TestNtpath.test_commonpath.<locals>.checkcs.��|tj|���|tjdd�|D��dS)NcSsg|]}t�|��qSr)rr*rrrr�
<listcomp>szCTestNtpath.test_commonpath.<locals>.check_error.<locals>.<listcomp>)r�r�
commonpath)�excr�rJrr�check_errors
�z/TestNtpath.test_commonpath.<locals>.check_errorzC:\Program Filesz
Program FileszC:Program Filesz\Program FileszC:\Program Files\zC:\\Program FileszC:\Program Files\\zC:\.\Program FileszC:\Program Files\.r�zC:\binzC:\Program Files\BarzC:\Program Files\FoozC:\ProjectszC:/Program Files/Barzc:/program files/barzc:\program fileszD:\Program Filesr��alotrH�and\jam�and\spam�andzand\\jamz
and\spam\\z	and\.\jamz
.\and\spam)r�r�r�)r�r�r�z	C:and\jamz
C:and\spamzC:andz	spam\alotz
\spam\alotsC:\Program FileszProgram Files\Foos
Program FilessC:\Program Files\FoosProgram Files\Foo)r��
ValueErrorrr��	TypeError)r5r�r�rrJr�test_commonpaths����������
�
�
�
�
�
�zTestNtpath.test_commonpathc
Cs�t��^}t��B}|�t�|��|����|�t�|��|����tjdkrB|�t	��t�dd�Wd�n1s=wYWd�n1sLwYWd�dSWd�dS1sdwYdS)N�win32���)
r�
assertTruer�sameopenfile�fileno�assertFalse�sys�platformr�r
)r5Ztf1Ztf2rrr�test_sameopenfileYs
��P�zTestNtpath.test_sameopenfilecCs�|�t�d��|�t�d��|�t�d��|�t�d��|�t�d��|�t�d��|�t�d��|�t�d��|�t�d	��|�t�d
��|�t�d��|�t�d��t���}|�t�|��Wd�n1swwYtjd
kr�t�tj	�\}}t�
t�tj	���|�t�|����|�t�|�
���Wd�n1s�wY|�t�d��|�t�d��|�t�d��|�t�d��dSdS)NrRr�rSzC:/z\\.\c:\z\\.\C:\sc:\sC:\sc:/sC:/s\\.\c:\s\\.\C:\r�z\\localhost\c$z\\localhost\c$\s\\localhost\c$s\\localhost\c$\)r�r�ismountrZtemp_dirr�r�r�rO�
executabler�ror��upper)r5�dr�rrrr�test_ismountfs4
�
��zTestNtpath.test_ismountcCs|�|��|���dS)z<Assert that two strings are equal ignoring case differences.N)r?r�)r5�s1�s2rrr�
assertEqualCI�szTestNtpath.assertEqualCIzOS helpers require 'nt' modulecCst�tj�}|t�|�fD]}t�|�}t�|�d}t�|�d}|�	||�q
t�
tj�\}}|�|d�|�|d�t�
tj�
��\}}	|�||�|�|	d�tjtjfD]*}t�|�}
|�|
t�|�t|
�d�t�|�
��}|�|t�|�t|�d�qYdS)Nr)�nt�_getfinalpathnamer�r�rr*Z_getvolumepathnamerrOr�Z
_getdiskusage�exec_prefixZ
assertGreaterr,r?�prefixZassertIsInstancer�lenr)r5r�rZvolume_pathZ
path_driveZvolume_path_driveZcapZfreeZb_capZb_freeZ
final_pathZb_final_pathrrr�test_nt_helpers�s(

�zTestNtpath.test_nt_helpersN)1rBrCrDrKrPrTrWrXr]rbrirkrlrprrrsrZskip_unless_symlink�unittestZ
skipUnless�HAVE_GETFINALPATHNAMEr=rr�r�r�r�r�r�r�r�r��HAVE_GETSHORTPATHNAMEr�r�r�r�rZrequires_resourcer�r�r�r�r�r�r�r�r�r�rrrrrEnszA


	
	
7
-
*
4

 


#


1
	E
#
rEc@seZdZeZdgZdS)�NtCommonTestr�N)rBrCrDrZ
pathmoduleZ
attributesrrrrr��s
r�c@s�eZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+S),�
PathLikeTestscCsbtj|_ttj�|_|�tj|j�t|jdd��}|�d�Wd�dS1s*wYdS)NZxbrstest_ntpath.PathLikeTests)	rry�	file_namer�	file_pathr|r}rzr�)r5�filerrr�setUp�s"�zPathLikeTests.setUpcCs|�||j�||j��dSr)r@r�r�)r5r8rrr�_check_function�szPathLikeTests._check_functioncCs2|�|jj�tjdkr|�t�d�d�dSdS)Nr�uΩΩuωΩ)r�rrr�r�r?rrJrrr�test_path_normcase�s
�z PathLikeTests.test_path_normcasecC�|�|jj�dSr)r�r�isabsrJrrr�test_path_isabs�r�zPathLikeTests.test_path_isabscCs,|�|j�dtd�d�|j�ddd��dS)NrY�br�)r?rr�rrJrrr�test_path_join�s�zPathLikeTests.test_path_joincCr�r)r�r�splitrJrrr�test_path_split�r�zPathLikeTests.test_path_splitcCr�r)r�r�splitextrJrrr�test_path_splitext�r�z PathLikeTests.test_path_splitextcCr�r)r�rrOrJrrr�test_path_splitdrive�r�z"PathLikeTests.test_path_splitdrivecCr�r)r�rr�rJrrr�test_path_basename�r�z PathLikeTests.test_path_basenamecCr�r)r�rrorJrrr�test_path_dirname�r�zPathLikeTests.test_path_dirnamecCr�r)r�r�islinkrJrrr�test_path_islink�r�zPathLikeTests.test_path_islinkcCr�r)r�r�lexistsrJrrr�test_path_lexists�r�zPathLikeTests.test_path_lexistscCr�r)r�rr�rJrrr�test_path_ismount�r�zPathLikeTests.test_path_ismountcCr�r)r�r�
expanduserrJrrr�test_path_expanduser�r�z"PathLikeTests.test_path_expandusercCr�r)r�rr�rJrrr�test_path_expandvars�r�z"PathLikeTests.test_path_expandvarscCr�r)r�rrerJrrr�test_path_normpath�r�z PathLikeTests.test_path_normpathcCr�r)r�rrxrJrrr�test_path_abspath�r�zPathLikeTests.test_path_abspathcCr�r)r�rrrJrrr�test_path_realpath�r�z PathLikeTests.test_path_realpathcCr�r)r�rr�rJrrr�test_path_relpath�r�zPathLikeTests.test_path_relpathcCs&|j�|j|jg�}|�||j�dSr)rr�r�r�r@)r5Zcommon_pathrrr�test_path_commonpath�sz"PathLikeTests.test_path_commonpathcCr�r)r�r�isdirrJrrr�test_path_isdir�r�zPathLikeTests.test_path_isdirN)rBrCrDrrr�r�r�r�r�r�r�r�rrrrrrr	r
rrr
rrrrrrr��s.r��__main__)#rr�
subprocessr�r�r-rr�rZtest.supportrZtest.support.os_helperrrZtempfilerr��ImportErrorr��AttributeErrorr�rr�rr!r3r=ZTestCaser>rEZ
CommonTestr�r�rB�mainrrrr�<module>s\�
��
DL�