Your IP : 216.73.216.60


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_genericpath.cpython-39.opt-1.pyc

a

XC?h�V�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddd�ZGd	d
�d
�Z
Gdd�de
ej�ZGd
d�de
�ZGdd�dej�Zedkr�e��dS)z3
Tests common to genericpath, ntpath and posixpath
�N)�support)�assert_python_ok)�FakePath�foocCs:t|dd��}|�|�Wd�n1s,0YdS)NZxbr)�open�write)�filename�data�fp�r�:/opt/alt/python39/lib64/python3.9/test/test_genericpath.py�create_filesr
c@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	Csd|j|jD]R}|�t��4t|j|��|�d�|jj|���Wd�q1sT0YqdS)Nz!{}.{}() did not raise a TypeError)	�common_attributes�
attributes�assertRaises�	TypeError�getattr�
pathmoduleZfail�format�__name__)�self�attrrrr�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]t}|D]h}|||g�}|�|�|��|�|�|��||k�rt|�}|�|||d�|||d���q�qdS)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)rrZtestlist�s1�s2�p�nrrr�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�unlinkr
r&rr�os�remove)rrrrr�test_getsizecs


zGenericTest.test_getsizecCs�tj}|�tj|�t|d�t|dd��}|�d�Wd�n1sJ0Yt|dd��}|��}Wd�n1s~0Y|�|d�|�	|j
�|�|j
�|��dS)Nrr$r�bar�rbsfoobar)
rr1r2r3r
rr�readr&ZassertLessEqualrrr)rr�fr	rrr�
test_filetimens
(&

�zGenericTest.test_filetimecCsntj}t�|�}|�tj|�|�|j�|�d�|�|j�|�d�t	|�|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|jt
u�rj|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�dS)NFT������)rr1r4�fsencoder2r3�assertIsrrr
�genericpath�lexists�rrZ	bfilenamerrr�test_exists�s&
zGenericTest.test_exists�pipezrequires os.pipe()c	Csdt��\}}z*|�|j�|��Wt�|�t�|�nt�|�t�|�0|�|j�|��dS�N)r4rFr'rr�close�assertFalse)r�r�wrrr�test_exists_fd�s
�
zGenericTest.test_exists_fdc	Cs6tj}t�|�}|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�z>t|�|�|j�|�d�|�|j�|�d�Wt�|�nt�|�0z@t�	|�|�|j�|�d�|�|j�|�d�Wt�
|�nt�
|�0dS�NFr<r=r>r?T)rr1r4r@rArrr
r3�mkdir�rmdirrDrrr�
test_isdir�s$

zGenericTest.test_isdirc	Cs6tj}t�|�}|�|j�|�d�|�|j�|�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�|�|j�|d�d�z>t|�|�|j�|�d�|�|j�|�d�Wt�|�nt�|�0z@t�	|�|�|j�|�d�|�|j�|�d�Wt�
|�nt�
|�0dSrM)rr1r4r@rArrr
r3rNrOrDrrr�test_isfile�s$

zGenericTest.test_isfilecCsxtj}tjd}|�tj|�|�tj|�t|�|�|j�||��t|�|�|j�||��|�	t
|jj�dS�N�2)rr1r2r3r
r'r�samefilerIrr)rZfile1Zfile2rrr�
test_samefile�s
zGenericTest.test_samefilecCs|tj}tjd}|�tj|�|�tj|�t|�|||�|�|j�||��t�	|�t|�|�
|j�||��dSrR)rr1r2r3r
r'rrTr4r5rI�r�func�test_fn1�test_fn2rrr�_test_samefile_on_link_func�s


z'GenericTest._test_samefile_on_link_funccCs|�tj�dSrG)rZr4�symlink�rrrr�test_samefile_on_symlink�sz$GenericTest.test_samefile_on_symlinkc
CsHz|�tj�Wn2tyB}z|�d|�WYd}~n
d}~00dS�Nz
os.link(): %s)rZr4�link�PermissionError�skipTest�r�errr�test_samefile_on_link�sz!GenericTest.test_samefile_on_linkcCs�tj}tjd}|�tj|�|�tj|�t|�t�|�}|�|j�	|t�|���t|�t�|�}|�
|j�	||��|�t|jj	�dSrR)
rr1r2r3r
r4�statr'r�samestatrIrr)rrXrYZstat1Zstat2rrr�
test_samestat�s


zGenericTest.test_samestatcCs�tjd}tjd}|�tj|�|�tj|�t|�|||�|�|j�t�	|�t�	|���t�
|�t|�|�|j�t�	|�t�	|���dS)N�1rS)rr1r2r3r
r'rrfr4rer5rIrVrrr�_test_samestat_on_link_funcs


�
�z'GenericTest._test_samestat_on_link_funccCs|�tj�dSrG)rir4r[r\rrr�test_samestat_on_symlinksz$GenericTest.test_samestat_on_symlinkc
CsHz|�tj�Wn2tyB}z|�d|�WYd}~n
d}~00dSr^)rir4r_r`rarbrrr�test_samestat_on_link"sz!GenericTest.test_samestat_on_linkc	Cs�tj}|�tj|�t|�t|dd��`}|��}t|dd��,}|��}|�|j�	||��Wd�n1sp0YWd�n1s�0YdS)Nr8r)
rr1r2r3r
r�filenor'r�sameopenfile)rr�fp1Zfd1�fp2Zfd2rrr�test_sameopenfile(szGenericTest.test_sameopenfileN)r�
__module__�__qualname__rrr!r.r6r;rE�unittest�
skipUnless�hasattrr4rLrPrQrUrZrZskip_unless_symlinkr]rdrgrirjrkrprrrrrs,C
	

rc@seZdZeZdd�ZdS)�TestGenericTestc
CsXtjD�]J}|dkrqt|j|�}|j|d���|dvr\|d�|d�|d�|d�n�|�ttf��|d�Wd�n1s�0Y|�ttf��|d�Wd�n1s�0Y|�	t
d��|d�Wd�n1s�0Y|�	t
d��|d�Wd�n1�s(0YWd�q1�sH0YqdS)	Nr)r )rrru/tmp�abcdss
/tmp�abcdsz
/tmpabcdss
/tmpabcdsz
embedded null)rrrrZsubTestr�OSError�UnicodeEncodeError�UnicodeDecodeError�assertRaisesRegex�
ValueError)rr rWrrr�test_invalid_paths:s$
&&&z"TestGenericTest.test_invalid_pathsN)rrqrrrBrr|rrrrrv4srvc@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�dirnamerC�islink�ismount�
expanduserr��realpathcCs||jj}dD]}||�}|�|||��q|�|d�d�|�|d�d�ddddgtd�ddhfD]}|�t||�qddS)N)z	FoO/./BaRs	FoO/./BaRr"�Trg@�o)rr�r&�	bytearrayrr)rr�r,�pathrrr�
test_normcase^szCommonTest.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&)rr�rrr�test_splitdrivelszCommonTest.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�n1�s�0YdS)$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&)rr��envrrr�test_expandvarsws8zCommonTest.test_expandvarszneed support.FS_NONASCIIcsN�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�n1�s@0YdS)Ncs���|�|�dSrG)r&)�valueZexpected�r�rrr�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_NONASCIIr4r@)rr�r�Znonasciirr�r�test_expandvars_nonascii�s.
��z#CommonTest.test_expandvars_nonasciicCs�|�d|j�d��t���0t�dt�|�d|j�d��Wd�n1sR0Ytjdkrjdnd}t���Dt�dt�dd|ddfD]}|�	|j�|�t
�q�Wd�n1s�0YdS)	Nr��ignorer�win32r�sf��s/foosC:\)�assertInrr��warnings�catch_warnings�simplefilter�DeprecationWarning�sys�platform�assertIsInstance�bytes)rZundecodable_pathr�rrr�test_abspath�s
2
zCommonTest.test_abspathcCs`|�d|j�d��t���0t�dt�|�d|j�d��Wd�n1sR0YdS)Nr�r�r)r�rr�r�r�r�r�r\rrr�
test_realpath�s
zCommonTest.test_realpathcCs"dD]}|�|j�|�t�qdS)N)r"�.�/�\z///foo/.//bar//)r�rr��str)rr�rrr�test_normpath_issue5827�sz"CommonTest.test_normpath_issue5827c	Cs�|jj}dD]}|�||�t�qd}zt�|�WnttfyJYnF0t�	|��*dD]}|�||�t�q\Wd�n1s�0YdS)N)r"Zfuuufùùz/fuuzU:\uçwð)
rr�r�r�r4r@�AttributeErrorrxr�temp_cwd)rr�r�Zunicwdrrr�test_abspath_issue3426�sz!CommonTest.test_abspath_issue3426c	Cs�tjrtjdvrtj}ntjr&tj}n
|�d�t���Nt�dt	�t�
|��|��Wd�n1sn0YWd�n1s�0YdS)N)r��darwinzneed support.TESTFN_NONASCIIr�)rZTESTFN_UNDECODABLEr�r�ZTESTFN_NONASCIIrar�r�r�r�r�r�)r�namerrr�test_nonascii_abspath�s�

z CommonTest.test_nonascii_abspathc	Cs�tjdtfdd����d}|�t|��|j�dd�Wd�n1sJ0Y|�t|��|j�dd�Wd�n1s�0Y|�td��|j�dd�Wd�n1s�0Y|�td��|j�dd�Wd�n1s�0Y|�td��|j�d�Wd�n1�s20Y|�td	��|j�g�Wd�n1�sl0Y|�td
��&|j�td�td��Wd�n1�s�0YWd�n1�s�0YdS)
Nr"T��quiet�.Can't mix strings and bytes in path components�bytesr��int�*�listr�rr7)r�check_warnings�BytesWarningrzrrr�r��r�errmsgrrr�test_join_errors�s ,,,,,,zCommonTest.test_join_errorsc	Csntjdttffdd���@d}|�t|��|j�dd�Wd�n1sN0Y|�t|��|j�dd�Wd�n1s�0Y|�td��|j�dd�Wd�n1s�0Y|�td��|j�dd�Wd�n1s�0Y|�td	��&|j�td
�td��Wd�n1�s@0YWd�n1�s`0YdS)Nr"Tr�r�r�r�r�r�r�rr7)	rr�r�r�rzrr�relpathr�r�rrr�test_relpath_errorss�
,,,,zCommonTest.test_relpath_errorscCstddd|jj�dS)Nz-Sz-czimport )rrrr\rrr�test_importszCommonTest.test_importN)rrqrrrrr�r�r�rsrtrr�r�r�r�r�r�r�r�r�r�rrrrr}Ss

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)rr1�	file_namer�	file_pathr2r3r
r\rrr�setUpszPathLikeTests.setUpcCs|�||j�||j��dSrG)r&r�r�)rrWrrr�assertPathEqualszPathLikeTests.assertPathEqualcCs|�tjj�dSrG)r�r4r�rr\rrr�test_path_exists!szPathLikeTests.test_path_existscCs|�tjj�dSrG)r�r4r�rr\rrr�test_path_isfile$szPathLikeTests.test_path_isfilecCs|�tjj�dSrG)r�r4r�rr\rrr�test_path_isdir'szPathLikeTests.test_path_isdircCs"|�tj�|j|jg�|j�dSrG)r&r4r�rr�r�r\rrr�test_path_commonprefix*s�z$PathLikeTests.test_path_commonprefixcCs|�tjj�dSrG)r�r4r�rr\rrr�test_path_getsize.szPathLikeTests.test_path_getsizecCs|�tjj�dSrG)r�r4r�rr\rrr�test_path_getmtime1sz PathLikeTests.test_path_getmtimecCs|�tjj�dSrG)r�r4r�rr\rrr�test_path_getctime4sz PathLikeTests.test_path_getctimecCs|�tj�|j|j��dSrG)r'r4r�rTr�r�r\rrr�test_path_samefile7sz PathLikeTests.test_path_samefileN)
rrqrrr�r�r�r�r�r�r�r�r�r�rrrrr�sr��__main__)r)�__doc__rBr4r�rsr��testrZtest.support.script_helperrZtest.supportrr
rZTestCaservr}r�r�mainrrrr�<module>s$
"D%