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_genericpath.cpython-310.opt-1.pyc
o

�i]W�@s�dZddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZddd	�Z
Gd
d�d�ZGdd
�d
eej�ZGdd�de�ZGdd�dej�Zedkr_e��dSdS)z3
Tests common to genericpath, ntpath and posixpath
�N)�	os_helper)�warnings_helper)�assert_python_ok)�FakePath�foocCs<t|dd��}|�|�Wd�dS1swYdS)N�xbr)�open�write)�filename�data�fp�r
�2/usr/local/lib/python3.10/test/test_genericpath.py�create_files"�rc@s�eZdZgd�ZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	e
�ee
d�d
�dd��Zdd�Zdd�Zdd�Zdd�Zejdd��Zdd�Zdd�Zdd�Zejd d!��Zd"d#�Zd$d%�Zd&S)'�GenericTest)�commonprefix�getsize�getatime�getctime�getmtime�exists�isdir�isfilec	CsV|j|jD]"}|�t��t|j|��|�d�|jj|���1s#wYqdS)Nz!{}.{}() did not raise a TypeError)	�common_attributes�
attributes�assertRaises�	TypeError�getattr�
pathmoduleZfail�format�__name__)�self�attrr
r
r�test_no_arguments���zGenericTest.test_no_argumentc	Cs�|jj}|�|g�d�|�|ddg�d�|�|ddg�d�|�|ddg�d�|�|ddg�d	�|�|d
dg�d�|�|d
d
g�d
�|�|d
dg�d�|�|ddg�d�|�|ddg�d�|�|ddg�d�|�|ddg�d�|�|ddg�d�gd�}|D]7}|D]2}|||g�}|�|�|��|�|�|��||kr�t|�}|�|||d�|||d��q�q�dS)N�z/home/swenson/spamz/home/swen/spamz
/home/swenz/home/swen/eggsz/home/swen/zhome:swenson:spamzhome:swen:spamz	home:swenz:home:swen:spamz:home:swen:eggsz:home:swen:s/home/swenson/spams/home/swen/spams
/home/swens/home/swen/eggss/home/swen/shome:swenson:spamshome:swen:spams	home:swens:home:swen:spams:home:swen:eggss:home:swen:)r$�abcZXbcdZXbZXYZabcdZaXcZabd�abZaXZabcX�)rr�assertEqual�
assertTrue�
startswith�lenZassertNotEqual)r!rZtestlist�s1�s2�p�nr
r
r�test_commonprefix!s��
�
�
�
�
�
�
�
�
�
�
�
�$���zGenericTest.test_commonprefixcCs^tj}|�tj|�t|d�|�|j�|�d�t�	|�t|d�|�|j�|�d�dS)NsHello�sHello World!�)
r�TESTFN�
addCleanup�unlinkrr(rr�os�remove)r!r
r
r
r�test_getsizeds


zGenericTest.test_getsizecCs�tj}|�tj|�t|d�t|dd��
}|�d�Wd�n1s%wYt|dd��}|��}Wd�n1s?wY|�|d�|�	|j
�|�|j
�|��dS)Nrr&r�bar�rbsfoobar)
rr3r4r5rrr	�readr(ZassertLessEqualrrr)r!r
�frr
r
r�
test_filetimeos
�
�

�zGenericTest.test_filetimecCsptj}t�|�}|�tj|�|�|j�|�d�|�|j�|�d�t	|�|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|jt
ur�|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�dSdS)NFT������)rr3r6�fsencoder4r5�assertIsrrr�genericpath�lexists�r!r
Z	bfilenamer
r
r�test_exists�s(

�zGenericTest.test_exists�pipezrequires os.pipe()c	Csdt��\}}z|�|j�|��Wt�|�t�|�nt�|�t�|�w|�|j�|��dS�N)r6rHr)rr�close�assertFalse)r!�r�wr
r
r�test_exists_fd�s

�zGenericTest.test_exists_fdc	Cs4tj}t�|�}|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�zt|�|�|j�|�d�|�|j�|�d�Wt�|�nt�|�wz!t�	|�|�|j�|�d�|�|j�|�d�Wt�
|�dSt�
|�w�NFr>r?r@rAT)rr3r6rBrCrrrr5�mkdir�rmdirrFr
r
r�
test_isdir��$

zGenericTest.test_isdirc	Cs4tj}t�|�}|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�zt|�|�|j�|�d�|�|j�|�d�Wt�|�nt�|�wz!t�	|�|�|j�|�d�|�|j�|�d�Wt�
|�dSt�
|�wrO)rr3r6rBrCrrrr5rPrQrFr
r
r�test_isfile�rSzGenericTest.test_isfilecCsxtj}tjd}|�tj|�|�tj|�t|�|�|j�||��t|�|�|j�||��|�	t
|jj�dS�N�2)rr3r4r5rr)r�samefilerKrr)r!Zfile1Zfile2r
r
r�
test_samefile�s
zGenericTest.test_samefilecCs|tj}tjd}|�tj|�|�tj|�t|�|||�|�|j�||��t�	|�t|�|�
|j�||��dSrU)rr3r4r5rr)rrWr6r7rK�r!�func�test_fn1�test_fn2r
r
r�_test_samefile_on_link_func�s


z'GenericTest._test_samefile_on_link_funccC�|�tj�dSrI)r]r6�symlink�r!r
r
r�test_samefile_on_symlink��z$GenericTest.test_samefile_on_symlinkc
C�Hz	|�tj�WdSty#}z|�d|�WYd}~dSd}~ww�Nz
os.link(): %s)r]r6�link�PermissionError�skipTest�r!�er
r
r�test_samefile_on_link����z!GenericTest.test_samefile_on_linkcCs�tj}tjd}|�tj|�|�tj|�t|�t�|�}|�|j�	|t�|���t|�t�|�}|�
|j�	||��|�t|jj	�dSrU)
rr3r4r5rr6�statr)r�samestatrKrr)r!r[r\Zstat1Zstat2r
r
r�
test_samestat�s


zGenericTest.test_samestatcCs�tjd}tjd}|�tj|�|�tj|�t|�|||�|�|j�t�	|�t�	|���t�
|�t|�|�|j�t�	|�t�	|���dS)N�1rV)rr3r4r5rr)rrmr6rlr7rKrYr
r
r�_test_samestat_on_link_funcs


�

�z'GenericTest._test_samestat_on_link_funccCr^rI)rpr6r_r`r
r
r�test_samestat_on_symlinkrbz$GenericTest.test_samestat_on_symlinkc
Crcrd)rpr6rerfrgrhr
r
r�test_samestat_on_link#rkz!GenericTest.test_samestat_on_linkc	Cs�tj}|�tj|�t|�t|dd��9}|��}t|dd��}|��}|�|j�	||��Wd�n1s8wYWd�dSWd�dS1sPwYdS)Nr:r)
rr3r4r5rr�filenor)r�sameopenfile)r!r
�fp1�fd1�fp2�fd2r
r
r�test_sameopenfile)s��"�zGenericTest.test_sameopenfileN)r �
__module__�__qualname__rrr#r0r8r=rG�unittest�
skipUnless�hasattrr6rNrRrTrXr]rZskip_unless_symlinkrarjrnrprqrrryr
r
r
rrs.C
	

rc@seZdZeZdd�ZdS)�TestGenericTestc
CsPtjD]�}|dkr
qt|j|�}|j|d���|dvr,|d�|d�|d�|d�nj|�ttf��|d�Wd�n1sBwY|�ttf��|d�Wd�n1s]wY|�	t
d��|d�Wd�n1swwY|�	t
d��|d�Wd�n1s�wYWd�n1s�wYqdS)	Nr)r")rrru/tmp�abcdss
/tmp�abcdsz
/tmpabcdss
/tmpabcdsz
embedded null)rrrrZsubTestr�OSError�UnicodeEncodeError�UnicodeDecodeError�assertRaisesRegex�
ValueError)r!r"rZr
r
r�test_invalid_paths;s4


�
�
�
�����z"TestGenericTest.test_invalid_pathsN)r rzr{rDrr�r
r
r
rr5src@s�eZdZejgd�Zdd�Zdd�Zdd�Ze�	e
jd�d	d
��Zdd�Z
d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�
CommonTest)�curdir�pardir�extsep�sep�pathsep�defpath�altsep�devnull�normcase�
splitdrive�
expandvars�normpath�abspath�join�split�splitext�isabs�basename�dirnamerE�islink�ismount�
expanduserr��realpathcCs||jj}dD]}||�}|�|||��q|�|d�d�|�|d�d�ddddgtd�ddhfD]	}|�t||�q2dS)N)z	FoO/./BaRs	FoO/./BaRr$�Trg@�o)rr�r(�	bytearrayrr)r!r�r.�pathr
r
r�
test_normcase_s�zCommonTest.test_normcasecCsl|jj}|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�dS)
N�/foo/bar)r$r��foo:bar)r$r��:foo:bar)r$r��/foo/bar)r�r��foo:bar)r�r��:foo:bar)r�r�)rr�r()r!r�r
r
r�test_splitdrivemszCommonTest.test_splitdrivecCs�|jj}t����}|��d|d<d|d<d|d<|�|d�d�|�|d�d�|�|d	�d
�|�|d�d�|�|d�d�|�|d
�d
�|�|d�d�|�|d�d�|�|d�d�|�|d�d
�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d�d�|�|d �d!�|�|d"�d�|�|d#�d#�Wd�dS1s�wYdS)$NZbar�fooZbaz1z{fooZbaz2z{foo}z$foo barzbar barz	${foo}barZbarbarz	$[foo]barz$bar barz$?barz$foo}barzbar}barz${fooz${{foo}}zbaz1}z$foo$fooz$bar$barrs$foo barsbar bars	${foo}barsbarbars	$[foo]bars$bar bars$?bars$foo}barsbar}bars${foos${{foo}}sbaz1}s$foo$foos$bar$bar)rr�r�EnvironmentVarGuard�clearr()r!r��envr
r
r�test_expandvarsxs:
"�zCommonTest.test_expandvarszneed os_helper.FS_NONASCIIcsL�jj���fdd�}t����}|��tj}||d<d|||<|||�|dd|�|dd|�|d	|d
|�|d|d|�|dd
|�|t�|�t�|��|dt�d|��|dt�d|��|t�d	|�t�d
|��|t�d|�t�d|��|dt�d
|��Wd�dS1s�wYdS)Ncs���|�|�dSrI)r()�valueZexpected�r�r!r
r�check�sz2CommonTest.test_expandvars_nonascii.<locals>.checkZspamZhamz	$spam barz%s barz
${spam}barz%sbarz${%s}barzham%sbarz
$bar%s barz	$spam}barz%s}bars	$spam bars
${spam}bars	$spam}bar)rr�rr�r��FS_NONASCIIr6rB)r!r�r�Znonasciir
r�r�test_expandvars_nonascii�s0

��"�z#CommonTest.test_expandvars_nonasciicCs�|�d|j�d��t���t�dt�|�d|j�d��Wd�n1s)wYtjdkr5dnd}t���#t�dt�dd|ddfD]}|�	|j�|�t
�qIWd�dS1sawYdS)	Nr��ignorer�win32r�sf��s/foosC:\)�assertInrr��warnings�catch_warnings�simplefilter�DeprecationWarning�sys�platform�assertIsInstance�bytes)r!Zundecodable_pathr�r
r
r�test_abspath�s
�
�"�zCommonTest.test_abspathcCsb|�d|j�d��t���t�dt�|�d|j�d��Wd�dS1s*wYdS)Nr�r�r)r�rr�r�r�r�r�r`r
r
r�
test_realpath�s

"�zCommonTest.test_realpathcCs"dD]}|�|j�|�t�qdS)N)r$�.�/�\z///foo/.//bar//)r�rr��str)r!r�r
r
r�test_normpath_issue5827�s�z"CommonTest.test_normpath_issue5827c	Cs�|jj}dD]
}|�||�t�qd}zt�|�Wnttfy&YdSwt�	|��dD]
}|�||�t�q/Wd�dS1sEwYdS)N)r$Zfuuufùùz/fuuzU:\uçwð)
rr�r�r�r6rB�AttributeErrorr�r�temp_cwd)r!r�r�Zunicwdr
r
r�test_abspath_issue3426�s��"�z!CommonTest.test_abspath_issue3426c	Cs�tjrtjdvrtj}ntjrtj}n|�d�t���0t�dt	�t�
|��|��Wd�n1s7wYWd�dSWd�dS1sOwYdS)N)r��darwinzneed os_helper.TESTFN_NONASCIIr�)rZTESTFN_UNDECODABLEr�r�ZTESTFN_NONASCIIrgr�r�r�r�r�r�)r!�namer
r
r�test_nonascii_abspath�s



��"�z CommonTest.test_nonascii_abspathc	Cs�tjdtfdd���d}|�t|��|j�dd�Wd�n1s$wY|�t|��|j�dd�Wd�n1sAwY|�td��|j�dd�Wd�n1s^wY|�td��|j�dd�Wd�n1s{wY|�td��|j�d�Wd�n1s�wY|�td	��|j�g�Wd�n1s�wY|�td
��|j�td�td��Wd�n1s�wYWd�dSWd�dS1s�wYdS)
Nr$T��quiet�.Can't mix strings and bytes in path components�bytesr��int�*�listr�rr9)r�check_warnings�BytesWarningr�rrr�r��r!�errmsgr
r
r�test_join_errors�s4��������"�zCommonTest.test_join_errorsc	Csztjdttffdd���d}|�t|��|j�dd�Wd�n1s&wY|�t|��|j�dd�Wd�n1sCwY|�td��|j�dd�Wd�n1s`wY|�td��|j�dd�Wd�n1s}wY|�td	��|j�td
�td��Wd�n1s�wYWd�dSWd�dS1s�wYdS)Nr$Tr�r�r�r�r�r�r�rr9)	rr�r�r�r�rr�relpathr�r�r
r
r�test_relpath_errorss,�������"�zCommonTest.test_relpath_errorscCstddd|jj�dS)Nz-Sz-czimport )rrr r`r
r
r�test_importszCommonTest.test_importN)r rzr{rrr�r�r�r|r}rr�r�r�r�r�r�r�r�r�r�r
r
r
rr�Ts

r�c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�
PathLikeTestscCs4tj|_ttj�|_|�tj|j�t|jd�dS)Nstest_genericpath.PathLikeTests)rr3�	file_namer�	file_pathr4r5rr`r
r
r�setUpszPathLikeTests.setUpcCs|�||j�||j��dSrI)r(r�r�)r!rZr
r
r�assertPathEqual�zPathLikeTests.assertPathEqualcC�|�tjj�dSrI)r�r6r�rr`r
r
r�test_path_exists"�zPathLikeTests.test_path_existscCr�rI)r�r6r�rr`r
r
r�test_path_isfile%r�zPathLikeTests.test_path_isfilecCr�rI)r�r6r�rr`r
r
r�test_path_isdir(r�zPathLikeTests.test_path_isdircCs"|�tj�|j|jg�|j�dSrI)r(r6r�rr�r�r`r
r
r�test_path_commonprefix+s�z$PathLikeTests.test_path_commonprefixcCr�rI)r�r6r�rr`r
r
r�test_path_getsize/r�zPathLikeTests.test_path_getsizecCr�rI)r�r6r�rr`r
r
r�test_path_getmtime2r�z PathLikeTests.test_path_getmtimecCr�rI)r�r6r�rr`r
r
r�test_path_getctime5r�z PathLikeTests.test_path_getctimecCs|�tj�|j|j��dSrI)r)r6r�rWr�r�r`r
r
r�test_path_samefile8r�z PathLikeTests.test_path_samefileN)
r rzr{r�r�r�r�r�r�r�r�r�r�r
r
r
rr�sr��__main__)r)�__doc__rDr6r�r|r�Ztest.supportrrZtest.support.script_helperrZtest.support.os_helperrrrZTestCaserr�r�r �mainr
r
r
r�<module>s*
"D%�