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: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_posixpath.cpython-37.pyc
B

��g�r�@s�ddlZddlZddlZddlZddlmZmZmZmZddlm	Z	m
Z
ddlmZddlm
Z
yddlZWnek
r�dZYnXee	j�Zdd�Zdd	�ZGd
d�dej�ZGdd
�d
e
jej�ZGdd�dej�Zedkr�e��dS)�N)�realpath�abspath�dirname�basename)�support�test_genericpath)�FakePath)�mockcCs"dtk}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�//usr/local/lib/python3.7/test/test_posixpath.py�!skip_if_ABSTFN_contains_backslashsrcCs(yt�|�Wntk
r"YnXdS)N)�os�rmdir�OSError)rrrr�
safe_rmdirsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Ze�e��d�dd��Ze�edkd�dd��Ze�edkd�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zed*d+��Zed,d-��Ze�ee d.�d/�ed0d1���Z!e�ee d.�d/�ed2d3���Z"e�ee d.�d/�ed4d5���Z#e�ee d.�d/�ed6d7���Z$e�ee d.�d/�ed8d9���Z%e�ee d.�d/�ed:d;���Z&e�ee d.�d/�ed<d=���Z'e�ee d.�d/�ed>d?���Z(d@dA�Z)dBdC�Z*dDdE�Z+dS)F�
PosixPathTestcCs|��dS)N)�tearDown)�selfrrr�setUp&szPosixPathTest.setUpcCs0x*dD]"}t�tj|�ttj|�qWdS)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)Nz/foo�barz/barZbazz/bar/bazz/foo/bar/bazz/foo/zbar/zbaz/z
/foo/bar/baz/s/foosbars/barsbazs/bar/bazs/foo/bar/bazs/foo/sbar/sbaz/s
/foo/bar/baz/)�assertEqual�	posixpath�join)rrrr�	test_join.szPosixPathTest.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)Nz/foo/bar)z/foor!�/)r&r�foo)rr'z////foo)z////r'z
//foo//bar)z//foor!s/foo/bar)s/foosbar�/)r(�sfoo)r)sfoos////foo)s////sfoos
//foo//bar)s//foosbar)r"r#�split)rrrr�
test_split<szPosixPathTest.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�ASCIIr(sabc/sabc.def/s	/abc.def/r))r"r#�splitext�bytes)r�path�filenameZextrrr�splitextTestIs0


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..z........)r1)rrrr�
test_splitexteszPosixPathTest.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&Tz/fooz/foo/barzfoo/barr)r(s/foos/foo/barsfoo/bar)�assertIsr#�isabs)rrrr�
test_isabssszPosixPathTest.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)Nz/foo/barr!r&rr'z////fooz
//foo//bars/foo/barsbarr(r)sfoos////foos
//foo//bar)r"r#r)rrrr�
test_basename�szPosixPathTest.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)Nz/foo/barz/foor&r'rz////fooz////z
//foo//barz//foos/foo/bars/foor(sfoor)s////foos////s
//foo//bars//foo)r"r#r)rrrr�test_dirname�szPosixPathTest.test_dirnamec	Cs|�t�tjd�d�|�t�tjd�d�ttjdd��}|�d�WdQRX|�t�tjd�d�t��r�t	�
tjdtjd�|�t�tjd�d�t	�tjd�|�t�tjd�d�|�t�tjd�d�|�t�tjd�d�dS)NrFr�wbsfooT)
r4r#�islinkrr�lexists�open�write�can_symlinkr�symlink�remove�exists)r�frrr�test_islink�szPosixPathTest.test_islinkcCs(|�t�d�d�|�t�d�d�dS)Nr&Tr()r4r#�ismount)rrrr�test_ismount�szPosixPathTest.test_ismountcCsB|�t�t�d�z t�t�|�t�t�d�Wdtt�XdS)NF)r4r#rDrr�mkdirr)rrrr�test_ismount_non_existent�s

z'PosixPathTest.test_ismount_non_existentzTest requires symlink supportc	Cs4z"t�dt�|�t�t�d�Wdt�t�XdS)Nr&F)rr?rr4r#rDr)rrrr�test_ismount_symlinks�sz#PosixPathTest.test_ismount_symlinksNzTest requires posix modulecCs8tj}dd�}z|t_|�t�t�d�Wd|t_XdS)NcSs6d}d}|tkrd}d}t�d||dddddddf
�S)Nr�)r�posix�stat_result)r/�st_ino�st_devrrr�
fake_lstat�sz?PosixPathTest.test_ismount_different_device.<locals>.fake_lstatT)r�lstatr4r#rDr)r�
save_lstatrNrrr�test_ismount_different_device�sz+PosixPathTest.test_ismount_different_devicecCs8tj}dd�}z|t_|�t�t�d�Wd|t_XdS)NcSsPd}d}|�t�r"|tkr"td��|tkr2d}d}t�d||dddddddf
�S)Nrz!Fake [Errno 13] Permission deniedrI)�
startswithrrrJrK)r/rLrMrrrrN�szEPosixPathTest.test_ismount_directory_not_readable.<locals>.fake_lstatT)rrOr4r#rDr)rrPrNrrr�#test_ismount_directory_not_readable�sz1PosixPathTest.test_ismount_directory_not_readablecCs(|�t�d�d�|�t�d�d�dS)Nr'sfoo)r"r#�
expanduser)rrrr�test_expanduser�szPosixPathTest.test_expandusercCs�t����}d|d<|�t�d�d�d|d<|�t�d�d�xbdD]Z}|j|d��D||d<|�t�d�d�|�t�d�d�|�t�d	�d
�WdQRXqDWWdQRXdS)Nz/home/victor�HOME�~z
/home/victor/)r&rz//z///)�homer&z~/z~/fooz/foo)r�EnvironmentVarGuardr"r#rTZsubTest)r�envrXrrr�test_expanduser_home_envvar�s

z)PosixPathTest.test_expanduser_home_envvarcCsht�d�}|�t�d�t�|�t�d�t�t�d�dkrt|�t�d�dt�d��|�t�d�dt�d��|�t�d�t�|�t�d	�t�|�t�d
�t�|�t�d�t�t����}|d=|�	t
���j}|�
d�p�d}|�t�d�|�tjj|d
td��Ftjj|dtd��(x dD]}|�t�|�|��q*WWdQRXWdQRXWdQRXdS)N�pwdz~/s~/rWr&�~r(z~root/z~foo/s~root/s~foo/rV�getpwuid)Zside_effect�getpwnam)rWz~/.localz
~vstinner/)r�
import_moduleZassertIsInstancer#rT�strr.r"rYr^r�getuid�pw_dir�rstripr	Zpatch�object�KeyError)rr\rZrXr/rrr�test_expanduser_pwd�s.


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)Nrr2r&z//z///z///foo/.//bar//z/foo/barz///foo/.//bar//.//..//.//bazz/foo/bazz///..//./foo/.//barr)�.r(s//s///s///foo/.//bar//s/foo/bars///foo/.//bar//.//..//.//bazs/foo/bazs///..//./foo/.//bar)r"r#�normpath)rrrr�
test_normpath"s"zPosixPathTest.test_normpathcCs�|�td�t���|�td�t���|�td�dgd��t���|�td�t���|�td�t���|�td�dgd��t���dS)Nr2z./.r&�drhs./.r()r"rr�getcwdr$�getcwdb)rrrr�test_realpath_curdir6s z"PosixPathTest.test_realpath_curdircCs�|�td�tt����|�td�ttt�����|�td�dgd��d�|�td�tt����|�td�ttt�����|�td�dgd��d�dS)Nz..z../..r&rks..s../..r()r"rrrrlr$rm)rrrr�test_realpath_pardir@sz"PosixPathTest.test_realpath_pardirr?zMissing symlink implementationc	Cs:z(t�tdt�|�tt�td�Wdt�t�XdS)Nr)rr?rr"rrr)rrrr�test_realpath_basicJsz!PosixPathTest.test_realpath_basicc	Cs@z.t�t�td�t�|�tt�td�Wdt�t�XdS)Nr)	rr?r#�relpathrr"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�WdQRXWdt�	t�t�	td�t�	td�t�	td�t�	td�t�	td�XdS)Nrrz1/xz1/..z1/../xz/x�x�yz1/../za/b�az../r&�c)
rr?rr"rrrr�
change_cwdr)rrrr�test_realpath_symlink_loops_s8

("
z)PosixPathTest.test_realpath_symlink_loopsc
CsvzJt�t�t�dtt�td�t�dtd�|�ttd�t�Wdt�td�t�td�t	t�XdS)Nz../z/selfzself/self/selfz/link)
rrFrr?rr"rrrr)rrrr�(test_realpath_repeated_indirect_symlinks�s
z6PosixPathTest.test_realpath_repeated_indirect_symlinkscCs�d}z�t�t�x8t|�D],}t�d�d|gd�td|d�qWt�dtd�|�ttd|�t�t�	t��|�td|�t�WdQRXWdx&t|d�D]}t�
td|�q�Wtt�XdS)N�
r&z%dz/%drIr2z/0)rrFr�ranger?r$r"rrrwrr)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�WdQRXWdt�td�t	td�t	t�XdS)Nz/yz/kruz/y/a)
rrFrr?rrwr"rrr)rrrr�test_realpath_resolve_parents�s
"z+PosixPathTest.test_realpath_resolve_parentsc
Cs�z�t�t�t�td�t�td�t�tdtd�|�ttd�td�t�tt���"|�tt	t�d�td�WdQRXWdt�
td�ttd�ttd�tt�XdS)Nz/kz/k/yz/link-yz
/link-y/..)rrFrr?r"rrrwrrrr)rrrr�(test_realpath_resolve_before_normalizing�s
z6PosixPathTest.test_realpath_resolve_before_normalizingc
Cs�zzt�t�t�td�t�ttd�t�tt���:tt�}|�t	|d�t�|�t	|d�td�WdQRXWdt�
td�ttd�tt�XdS)Nz/k�linkzlink/k)rrFrr?rrwrrr"rrr)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�Wd|t_XdS)NcSsdS)Nz/home/user/barrrrrr�<lambda>�r)z,PosixPathTest.test_relpath.<locals>.<lambda>���rruza/bz../a/bz../bz../z/az../cz/a/bzb/cz../../ar2z/foo/bar/batz/x/y/zz../../../foo/bar/batz/foo/barZbatr&zfoo/bar/batz../../..z/xz../foo/bar/batz
../../../x)
rrlr/r*�assertRaises�
ValueErrorr#rqr"r)rZreal_getcwd�curdirrrr�test_relpath�s.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�Wd|t_XdS)NcSsdS)Ns/home/user/barrrrrrr�r)z2PosixPathTest.test_relpath_bytes.<locals>.<lambda>r�r)�asa/bs../a/bs../bs../s/as../cs/a/bsb/cs../../arhs/foo/bar/bats/x/y/zs../../../foo/bar/bats/foo/barsbatr(sfoo/bar/bats../../..s/xs../foo/bar/bats
../../../xsbytesra)rrmr/r*r�r�r#rqr"r�	TypeError)rZreal_getcwdbr�rrr�test_relpath_bytess4z 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�|dddgd�|dddgd�|dgd�|ddgd�|tddg���ttjd dg���ttjd d!g���ttjd"dg���ttjdd#g���ttjdd$g���ttjd%d#g�dS)&Ncs8��t�|�|���t�dd�|D��t�|��dS)NcSsg|]}t�|��qSr)r�fsencode)�.0�prrr�
<listcomp>,sz@PosixPathTest.test_commonpath.<locals>.check.<locals>.<listcomp>)r"r#�
commonpathrr�)�pathsZexpected)rrr�check*sz,PosixPathTest.test_commonpath.<locals>.checkcs.��|tj|���|tjdd�|D��dS)NcSsg|]}t�|��qSr)rr�)r�r�rrrr�1szFPosixPathTest.test_commonpath.<locals>.check_error.<locals>.<listcomp>)r�r#r�)�excr�)rrr�check_error.s
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/lib64ZspamZalotrzand/jamzand/spam�andzand//jamz
and/spam//z	and/./jamz
./and/spamz	spam/alotz
/spam/alots	/usr/lib/zusr/lib/python3susr/lib/s/usr/lib/python3susr/lib/python3zusr/lib/)r�r�r#r�r�)rr�r�r)rr�test_commonpath)sP










zPosixPathTest.test_commonpath),�__name__�
__module__�__qualname__rrr%r+r1r3r6r7r8rCrErGrZ
skipUnlessrr>rHZskipIfrJrQrSrUr[rgrjrrnro�hasattrrrprrrxryr~rr�r�r�r�r�rrrrr$sb



	
	'

	(
rc@seZdZeZddddgZdS)�PosixCommonTestrq�samefile�sameopenfile�samestatN)r�r�r�r#Z
pathmoduleZ
attributesrrrrr�`sr�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)*�
PathLikeTestsc	CsPtj��|_ttj�|_|�tj|j�t|jdd��}|�	d�WdQRXdS)NZxbrstest_posixpath.PathLikeTests)
rr�lower�	file_namer�	file_pathZ
addCleanuprr<r=)r�filerrrris
zPathLikeTests.setUpcCs|�||j�||j��dS)N)r"r�r�)r�funcrrr�assertPathEqualpszPathLikeTests.assertPathEqualcCs|�|jj�dS)N)r�r/�normcase)rrrr�test_path_normcasessz PathLikeTests.test_path_normcasecCs|�|jj�dS)N)r�r/r5)rrrr�test_path_isabsvszPathLikeTests.test_path_isabscCs,|�|j�dtd�d�|j�ddd��dS)Nru�brv)r"r/r$r)rrrr�test_path_joinyszPathLikeTests.test_path_joincCs|�|jj�dS)N)r�r/r*)rrrr�test_path_split}szPathLikeTests.test_path_splitcCs|�|jj�dS)N)r�r/r-)rrrr�test_path_splitext�sz PathLikeTests.test_path_splitextcCs|�|jj�dS)N)r�r/�
splitdrive)rrrr�test_path_splitdrive�sz"PathLikeTests.test_path_splitdrivecCs|�|jj�dS)N)r�r/r)rrrr�test_path_basename�sz PathLikeTests.test_path_basenamecCs|�|jj�dS)N)r�r/r)rrrr�test_path_dirname�szPathLikeTests.test_path_dirnamecCs|�|jj�dS)N)r�r/r:)rrrr�test_path_islink�szPathLikeTests.test_path_islinkcCs|�|jj�dS)N)r�r/r;)rrrr�test_path_lexists�szPathLikeTests.test_path_lexistscCs|�|jj�dS)N)r�r/rD)rrrr�test_path_ismount�szPathLikeTests.test_path_ismountcCs|�|jj�dS)N)r�r/rT)rrrr�test_path_expanduser�sz"PathLikeTests.test_path_expandusercCs|�|jj�dS)N)r�r/�
expandvars)rrrr�test_path_expandvars�sz"PathLikeTests.test_path_expandvarscCs|�|jj�dS)N)r�r/ri)rrrr�test_path_normpath�sz PathLikeTests.test_path_normpathcCs|�|jj�dS)N)r�r/r)rrrr�test_path_abspath�szPathLikeTests.test_path_abspathcCs|�|jj�dS)N)r�r/r)rrrr�test_path_realpath�sz PathLikeTests.test_path_realpathcCs|�|jj�dS)N)r�r/rq)rrrr�test_path_relpath�szPathLikeTests.test_path_relpathcCs&|j�|j|jg�}|�||j�dS)N)r/r�r�r�r")rZcommon_pathrrr�test_path_commonpath�sz"PathLikeTests.test_path_commonpathN)r�r�r�r#r/rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�es*r��__main__)rr#r�warningsrrrrrrrZtest.supportrr	rJ�ImportErrorrrrrZTestCaserZ
CommonTestr�r�r��mainrrrr�<module>s.


@G