HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_posixpath.cpython-310.pyc
o

�it��@sddlZddlZddlZddlZddlmZmZmZmZddlm	Z	ddl
mZddl
mZddl
mZddlmZzddlZWneyKdZYnweej�Zdd	�Zd
d�ZGdd
�d
ej�ZGdd�de	jej�ZGdd�dej�Zedkr�e��dSdS)�N)�realpath�abspath�dirname�basename)�test_genericpath)�
import_helper)�	os_helper)�FakePath)�mockcCs"dtv}d}|t�|�|�g|S)z�
    On Windows, posixpath.abspath still returns paths with backslashes
    instead of posix forward slashes. If this is the case, several tests
    fail, so skip them.
    �\z'ABSTFN is not a posix path - tests fail)�ABSTFN�unittest�skip)�testZfound_backslash�msg�r�0/usr/local/lib/python3.10/test/test_posixpath.py�!skip_if_ABSTFN_contains_backslashsrcCs&zt�|�WdStyYdSw�N)�os�rmdir�OSError)rrrr�
safe_rmdir!s
�rc@sBeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Ze�e��d�dd��Ze�edud�dd��Ze�edud�d d!��Zd"d#�Zd$d%�Ze�ejd&kd'�d(d)��Zd*d+�Zed,d-��Zed.d/��Z e�e!e"d0�d1�ed2d3���Z#e�e!e"d0�d1�ed4d5���Z$e�e!e"d0�d1�ed6d7���Z%e�e!e"d0�d1�ed8d9���Z&e�e!e"d0�d1�ed:d;���Z'e�e!e"d0�d1�ed<d=���Z(e�e!e"d0�d1�ed>d?���Z)e�e!e"d0�d1�ed@dA���Z*e�e!e"d0�d1�edBdC���Z+e�e!e"d0�d1�edDdE���Z,dFdG�Z-dHdI�Z.dJdK�Z/dS)L�
PosixPathTestcCs|��dSr)�tearDown��selfrrr�setUp)szPosixPathTest.setUpcCs,dD]}t�tj|�ttj|�qdS)N)��1�2)r�unlink�TESTFNr)r�suffixrrrr,s�zPosixPathTest.tearDowncCs�|�t�dddd�d�|�t�ddd�d�|�t�ddd	�d
�|�t�ddd
d�d�|�t�ddd�d�|�t�ddd�d�dS)N�/foo�barz/barZbazz/bar/bazz/foo/bar/bazz/foo/zbar/zbaz/z
/foo/bar/baz/�/foo�bars/barsbazs/bar/bazs/foo/bar/bazs/foo/sbar/sbaz/s
/foo/bar/baz/)�assertEqual�	posixpath�joinrrrr�	test_join1s �����zPosixPathTest.test_joincCs�|�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�dS)N�/foo/bar)r$r%�/)r-r�foo)rr.�////foo)�////r.�
//foo//bar)�//foor%�/foo/bar)r&r'�/)r4��foo)r5r6�////foo)�////r6�
//foo//bar)�//foor')r(r)�splitrrrr�
test_split?�zPosixPathTest.test_splitcCs�|�t�|�||f�|�t�d|�d||f�|�t�d|�d||f�|�t�d|�d||f�|�t�d|�d||f�|�t�|d�||ddf�t|d�}t|d�}t|d�}|�t�|�||f�|�t�d|�d||f�|�t�d|�d||f�|�t�d	|�d	||f�|�t�d
|�d
||f�|�t�|d�||ddf�dS)Nr-zabc/zabc.def/z	/abc.def/r�ASCIIr4sabc/sabc.def/s	/abc.def/r5)r(r)�splitext�bytes)r�path�filename�extrrr�splitextTestLsB
�
�
��



�
�
�
��zPosixPathTest.splitextTestcCs�|�ddd�|�ddd�|�ddd�|�dd	d
�|�ddd�|�d
d
d�|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�|�ddd�dS)Nzfoo.barr.z.barzfoo.boo.barzfoo.boozfoo.boo.biff.barzfoo.boo.biffz.csh.rcz.cshz.rcZnodotsrz.cshrcz...manydotsz...manydots.extz.ext�.�..z........)rDrrrr�
test_splitexthszPosixPathTest.test_splitextcCs�|�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�dS)
NrFr-Tr$r,zfoo/barr5r4r&r3sfoo/bar)�assertIsr)�isabsrrrr�
test_isabsvr=zPosixPathTest.test_isabscCs�|�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	�dS)Nr,r%r-rr.r/r1r3r'r4r5r6r7r9)r(r)rrrrr�
test_basename�r=zPosixPathTest.test_basenamecCs�|�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�dS)Nr,r$r-r.rr/r0r1r2r3r&r4r6r5r7r8r9r:)r(r)rrrrr�test_dirname�r=zPosixPathTest.test_dirnamecCs�|�t�tjd�d�|�t�tjd�d�ttjdd��
}|�d�Wd�n1s0wY|�t�tjd�d�t��r�t	�
tjdtjd�|�t�tjd�d�t	�tjd�|�t�tjd�d�|�t�tjd�d�|�t�tjd�d�|�t�tjd�d�|�t�t	�
tj�d�d�|�t�tjd	�d�|�t�t	�
tj�d
�d�dS)NrFr �wbr6Tu�����)rHr)�islinkrr"�lexists�open�write�can_symlinkr�symlink�remove�exists�fsencode)r�frrr�test_islink�s"�"zPosixPathTest.test_islinkcCsT|�t�d�d�|�t�d�d�|�t�td��d�|�t�td��d�dS)Nr-Tr4)rHr)�ismountr	rrrr�test_ismount�szPosixPathTest.test_ismountcCs�|�t�t�d�zt�t�|�t�t�d�Wtt�ntt�w|�t�d�d�|�t�d�d�|�t�d�d�|�t�d�d�dS)NFu/�s/�z/s/)rHr)r\rr�mkdirrrrrr�test_ismount_non_existent�s
z'PosixPathTest.test_ismount_non_existentzTest requires symlink supportc	Cs<zt�dt�|�t�t�d�Wt�t�dSt�t�w)Nr-F)rrVrrHr)r\r!rrrr�test_ismount_symlinks�sz#PosixPathTest.test_ismount_symlinksNzTest requires posix modulecC�<tj}dd�}z|t_|�t�t�d�W|t_dS|t_w)NcSs6d}d}|tkrd}d}t�d||dddddddf
�S)Nr�)r�posix�stat_result�rA�st_ino�st_devrrr�
fake_lstat�sz?PosixPathTest.test_ismount_different_device.<locals>.fake_lstatT�r�lstatrHr)r\r�rZ
save_lstatrhrrr�test_ismount_different_device�sz+PosixPathTest.test_ismount_different_devicecCra)NcSsPd}d}|�t�r|tkrtd��|tkrd}d}t�d||dddddddf
�S)Nrz!Fake [Errno 13] Permission deniedrb)�
startswithrrrcrdrerrrrh�szEPosixPathTest.test_ismount_directory_not_readable.<locals>.fake_lstatTrirkrrr�#test_ismount_directory_not_readable�sz1PosixPathTest.test_ismount_directory_not_readablecCs(|�t�d�d�|�t�d�d�dS)Nr.r6)r(r)�
expanduserrrrr�test_expanduser�szPosixPathTest.test_expanduserc
Cs�t���]}d|d<|�t�d�d�d|d<|�t�d�d�dD]7}|j|d��'||d<|�t�d�d�|�t�d�d�|�t�d	�d
�Wd�n1sSwYq!Wd�dS1sdwYdS)Nz/home/victor�HOME�~z
/home/victor/)r-r�//�///)�homer-�~/z~/foor$)r�EnvironmentVarGuardr(r)roZsubTest)r�envrurrr�test_expanduser_home_envvar�s
���"�z)PosixPathTest.test_expanduser_home_envvar�vxworkszno home directory on VxWorksc
Cs�t�d�}|�t�d�t�|�t�d�t�t�d�dkr:|�t�d�dt�d��|�t�d�dt�d��|�t�d�t�|�t�d	�t�|�t�d
�t�|�t�d�t�t�	��l}|d=|�
t���j
}|�d�ptd}|�t�d�|�tjj|d
td��/tjj|dtd��dD]}|�t�|�|�q�Wd�n1s�wYWd�n1s�wYWd�dSWd�dS1s�wYdS)N�pwdrvs~/rrr-�~r4z~root/z~foo/s~root/s~foo/rq�getpwuid)Zside_effect�getpwnam)rrz~/.localz
~vstinner/)r�
import_moduleZassertIsInstancer)ro�strr@r(rrwr}r�getuid�pw_dir�rstripr
Zpatch�object�KeyError)rr{rxrurArrr�test_expanduser_pwdsB
��
�����
"�z!PosixPathTest.test_expanduser_pwdcCs|�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�dS)NrrEr-rsrtz///foo/.//bar//r,z///foo/.//bar//.//..//.//bazz/foo/bazz///..//./foo/.//barr5�.r4s//s///s///foo/.//bar//r3s///foo/.//bar//.//..//.//bazs/foo/bazs///..//./foo/.//bar)r(r)�normpathrrrr�
test_normpath5s(���zPosixPathTest.test_normpathcCs�|�td�t���|�td�t���|�td�dgd��t���|�td�t���|�td�t���|�td�dgd��t���dS)NrEz./.r-�dr�s./.r4)r(rr�getcwdr*�getcwdbrrrr�test_realpath_curdirIs $z"PosixPathTest.test_realpath_curdircCs�|�td�tt����|�td�ttt�����|�td�dgd��d�|�td�tt����|�td�ttt�����|�td�dgd��d�dS)NrFz../..r-r�s..s../..r4)r(rrrr�r*r�rrrr�test_realpath_pardirSs z"PosixPathTest.test_realpath_pardirrVzMissing symlink implementationc	CsBzt�tdt�|�tt�td�Wt�t�dSt�t�w�Nr)rrVrr(rrr!rrrr�test_realpath_basic]sz!PosixPathTest.test_realpath_basicc	CsVz$t�tdt�|jtttdd�|jtttddd�Wt�t�dSt�t�w)NrT��strictr )rrVr�assertRaises�FileNotFoundErrorrrr!rrrr�test_realpath_stricths
z"PosixPathTest.test_realpath_strictc	CsHzt�t�td�t�|�tt�td�Wt�t�dSt�t�wr�)	rrVr)�relpathrr(rrr!rrrr�test_realpath_relativeusz$PosixPathTest.test_realpath_relativec
Cs��z?t�tt�|�tt�t�t�tdtd�t�tdtd�|�ttd�td�|�ttd�td�|�ttd�td�|�ttd�tt��|�ttd�tt�d�t�tdtd�|�ttd	tt�d�td�|�ttd	tt�d�td�t�tt�d
td�|�ttd�td
�t�dttt��d
tt�dtd�|�ttd�td�t�tt���|�ttt��t�Wd�n31s�wYWt�	t�t�	td�t�	td�t�	td�t�	td�t�	td�dSWt�	t�t�	td�t�	td�t�	td�t�	td�t�	td�dSt�	t�t�	td�t�	td�t�	td�t�	td�t�	td�w)Nrr �1/x�1/..�1/../x�/x�x�y�1/../�a/b�a�../r-�c)
rrVrr(rrrr�
change_cwdr!rrrr�test_realpath_symlink_loopssb������
�

�z)PosixPathTest.test_realpath_symlink_loopsc
Cs��z6t�tt�|jtttdd�t�tdtd�t�tdtd�|jtttddd�|jtttddd�|jtttddd�|jtttddd�|jtttddd�t�tdtd	�|jtttd
tt�d	dd�|jtttd
tt�ddd�t�tt�dtd�|jtttddd�t�d
ttt��dtt�dtd�|jtttddd�t�	tt���|jtttt�dd�Wd�n31s�wYWt�
t�t�
td�t�
td�t�
td	�t�
td�t�
td�dSWt�
t�t�
td�t�
td�t�
td	�t�
td�t�
td�dSt�
t�t�
td�t�
td�t�
td	�t�
td�t�
td�w)NTr�rr r�r�r�r�r�r�r�r�r�r-r�)rrVrr�rrrrrr�r!rrrr�"test_realpath_symlink_loops_strict�sb������
�

�z0PosixPathTest.test_realpath_symlink_loops_strictc
Cs�z8t�t�t�dtt�td�t�dtd�|�ttd�t�Wt�td�t�td�t	t�dSt�td�t�td�t	t�w)Nr�z/selfzself/self/selfz/link)
rr^rrVrr(rrr!rrrrr�(test_realpath_repeated_indirect_symlinks�s
�
z6PosixPathTest.test_realpath_repeated_indirect_symlinkscCsd}zlt�t�t|�D]}t�d�d|gd�td|d�qt�dtd�|�ttd|�t�t�	t��|�td|�t�Wd�n1sQwYWt|d�D]}t�
td|�q]tt�dSt|d�D]}t�
td|�qutt�w)N�
r-z%dz/%drbrEz/0)rr^r�rangerVr*r(rrr�r!r)r�depth�irrr�test_realpath_deep_recursion�s"
*���
z*PosixPathTest.test_realpath_deep_recursionc
Cs�z_t�t�t�td�t�tdtd�t�td��|�td�td�Wd�n1s3wYWt�td�t	td�t	t�dSWt�td�t	td�t	t�dSt�td�t	td�t	t�w)Nz/y�/kr�z/y/a)
rr^rrVrr�r(rr!rrrrr�test_realpath_resolve_parents�s"
���
z+PosixPathTest.test_realpath_resolve_parentsc
Cs6z�t�t�t�td�t�td�t�tdtd�|�ttd�td�t�tt���|�tt	t�d�td�Wd�n"1sJwYWt�
td�ttd�ttd�tt�dSWt�
td�ttd�ttd�tt�dSt�
td�ttd�ttd�tt�w)Nr�z/k/yz/link-yz
/link-y/..)rr^rrVr(rrr�rrr!rrrrr�(test_realpath_resolve_before_normalizing
s0
����
z6PosixPathTest.test_realpath_resolve_before_normalizingc
Cszmt�t�t�td�t�ttd�t�tt���"tt�}|�t	|d�t�|�t	|d�td�Wd�n1sAwYWt�
td�ttd�tt�dSWt�
td�ttd�tt�dSt�
td�ttd�tt�w)Nr��linkzlink/k)rr^rrVrr�rrr(rr!r)r�baserrr�test_realpath_resolve_first's&
���
z)PosixPathTest.test_realpath_resolve_firstcCs�tjdd�}t_z�tj�t���d}|�ttjd�|�t�d�d�|�t�t�	d��d�|�t�d�d�|�t�d�d�|�t�dd�d	|d
�|�t�dd�d	|d�|�t�dd
�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�d
d
�d�|�t�dd�d�W|t_dS|t_w)NcS�dS)Nz/home/user/barrrrrr�<lambda><�z,PosixPathTest.test_relpath.<locals>.<lambda>���rr�r�z../a/bz../br�z/az../cz/a/bzb/cz../../arEz/foo/bar/batz/x/y/zz../../../foo/bar/batr,Zbatr-zfoo/bar/batz../../..r�z../foo/bar/batz
../../../x)
rr�rAr;r��
ValueErrorr)r�r(r)rZreal_getcwd�curdirrrr�test_relpath;s0
�zPosixPathTest.test_relpathcCs�tjdd�}t_z�tj�t���d}|�ttjd�|�t�d�d�|�t�t�	d��d�|�t�d�d�|�t�d�d�|�t�dd�d	|d
�|�t�dd�d	|d�|�t�dd
�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�dd�d�|�t�d
d
�d�|�t�dd�d�|�t
tjdd�|�t
tjdd�W|t_dS|t_w)NcSr�)Ns/home/user/barrrrrrr�Vr�z2PosixPathTest.test_relpath_bytes.<locals>.<lambda>r�r5�asa/bs../a/bs../bs../s/as../cs/a/bsb/cs../../ar�s/foo/bar/bats/x/y/zs../../../foo/bar/batr3sbatr4sfoo/bar/bats../../..s/xs../foo/bar/bats
../../../xsbytesr�)rr�rAr;r�r�r)r�r(r�	TypeError)rZreal_getcwdbr�rrr�test_relpath_bytesUs8
�
�z PosixPathTest.test_relpath_bytescs��fdd�}�fdd�}��ttjg�|tddg�|tddg�|dgd�|ddgd�|ddgd�|ddgd�|d	d
gd�|ddgd�|d
dgd
�|ddgd
�|ddgd�|ddgd�|ddgd�|ddgd�|dgd�|ddgd�|ddgd�|ddgd�|ddgd�|ddgd�|gd�d�|gd�d�|dgd�|dd gd�|tdd!g���ttjd"dg���ttjd"d#g���ttjd$dg���ttjdd%g���ttjdd&g���ttjd'd%g�dS)(Ncs8��t�|�|���t�dd�|D��t�|��dS)NcS�g|]}t�|��qSr�rrY��.0�prrr�
<listcomp>v�z@PosixPathTest.test_commonpath.<locals>.check.<locals>.<listcomp>)r(r)�
commonpathrrY)�pathsZexpectedrrr�checkts�z,PosixPathTest.test_commonpath.<locals>.checkcs.��|tj|���|tjdd�|D��dS)NcSr�rr�r�rrrr�{r�zFPosixPathTest.test_commonpath.<locals>.check_error.<locals>.<listcomp>)r�r)r�)�excr�rrr�check_errorxs
�z2PosixPathTest.test_commonpath.<locals>.check_errorz/usrZusrz
/usr/localz/usr/local/z/usr//localz//usr/localz/usr/./localz/./usr/localr-z/devz	/usr/lib/z/usr/lib/python3z/usr/libz/usr/lib64/z
/usr/lib64Zspam�alotr�and/jam�and/spam�andzand//jamz
and/spam//z	and/./jamz
./and/spam)r�r�r�)r�r�r�z	spam/alotz
/spam/alots	/usr/lib/zusr/lib/python3susr/lib/s/usr/lib/python3susr/lib/python3zusr/lib/)r�r�r)r�r�)rr�r�rrr�test_commonpathss\
�
�
�
�
�
�zPosixPathTest.test_commonpath)0�__name__�
__module__�__qualname__rrr+r<rDrGrJrKrLr[r]r_r
Z
skipUnlessrrUr`ZskipIfrcrlrnrpry�sys�platformr�r�rr�r��hasattrrr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr's�




�


�
'
	
	��
��'�'�����rc@seZdZeZgd�ZdS)�PosixCommonTest)r��samefile�sameopenfile�samestatN)r�r�r�r)Z
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)S)*�
PathLikeTestscCsbtj|_ttj�|_|�tj|j�t|jdd��}|�d�Wd�dS1s*wYdS)N�xbrstest_posixpath.PathLikeTests)	rr"�	file_namer	�	file_pathZ
addCleanupr!rSrT)r�filerrrr�s"�zPathLikeTests.setUpcCs|�||j�||j��dSr)r(r�r�)r�funcrrr�assertPathEqual�szPathLikeTests.assertPathEqualcC�|�|jj�dSr)r�rA�normcaserrrr�test_path_normcase��z PathLikeTests.test_path_normcasecCr�r)r�rArIrrrr�test_path_isabs�r�zPathLikeTests.test_path_isabscCs,|�|j�dtd�d�|j�ddd��dS)Nr��br�)r(rAr*r	rrrr�test_path_join�s�zPathLikeTests.test_path_joincCr�r)r�rAr;rrrr�test_path_split�r�zPathLikeTests.test_path_splitcCr�r)r�rAr?rrrr�test_path_splitext�r�z PathLikeTests.test_path_splitextcCr�r)r�rA�
splitdriverrrr�test_path_splitdrive�r�z"PathLikeTests.test_path_splitdrivecCr�r)r�rArrrrr�test_path_basename�r�z PathLikeTests.test_path_basenamecCr�r)r�rArrrrr�test_path_dirname�r�zPathLikeTests.test_path_dirnamecCr�r)r�rArQrrrr�test_path_islink�r�zPathLikeTests.test_path_islinkcCr�r)r�rArRrrrr�test_path_lexists�r�zPathLikeTests.test_path_lexistscCr�r)r�rAr\rrrr�test_path_ismount�r�zPathLikeTests.test_path_ismountcCr�r)r�rArorrrr�test_path_expanduser�r�z"PathLikeTests.test_path_expandusercCr�r)r�rA�
expandvarsrrrr�test_path_expandvars�r�z"PathLikeTests.test_path_expandvarscCr�r)r�rAr�rrrr�test_path_normpath�r�z PathLikeTests.test_path_normpathcCr�r)r�rArrrrr�test_path_abspath�r�zPathLikeTests.test_path_abspathcCr�r)r�rArrrrr�test_path_realpath�r�z PathLikeTests.test_path_realpathcCr�r)r�rAr�rrrr�test_path_relpath�r�zPathLikeTests.test_path_relpathcCs&|j�|j|jg�}|�||j�dSr)rAr�r�r�r()rZcommon_pathrrr�test_path_commonpath�sz"PathLikeTests.test_path_commonpathN)r�r�r�r)rArr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s,r��__main__)rr)r�r
rrrrrrZtest.supportrrZtest.support.os_helperr	r
rc�ImportErrorr"rrrZTestCaserZ
CommonTestr�r�r��mainrrrr�<module>s:�

G�