403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_dbm_dumb.cpython-36.pyc
3

�w2_�(�@s�dZddlZddlZddlZddlZddlZddlZddljZ	ddl
mZddlm
Z
ejZdd�ZGdd�dej�Zed	kr�ej�dS)
zATest script for the dumbdbm module
   Original by Roger E. Masse
�N)�support)�partialcCs:x4dD],}ytjt|�Wqtk
r0YqXqWdS)N�.dir�.dat�.bak)rrr)�os�unlink�_fname�OSError)Zext�r�7/opt/alt/python36/lib64/python3.6/test/test_dbm_dumb.py�
_delete_filess

r
c@sBeZdZddddddddd	d
ddd
ddjd�diZdd�Zejee	d�d�ejee	d�d�dd���Z
dd�Zdd�Zdd�Z
d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zejee	d�d�d@dA��Zejej dB�dCdD��Z!dEdF�Z"dGdH�Z#dIS)J�DumbDBMTestCase�0��asPython:�bsProgramming�csthe�dsway�fsGuido�gsintended�üzutf-8�!cCsTtjtd�}|jt|j��g�x|jD]}|j|||<q(W|j|�|j�dS)N�c)	�dumbdbm�openr	�assertEqual�list�keys�_dict�read_helper�close)�self�f�keyrrr�test_dumbdbm_creation#s
z%DumbDBMTestCase.test_dumbdbm_creation�umaskztest needs os.umask()�chmodztest needs os.chmod()cCs�z$tjd�}tjtdd�}|j�Wdtj|�Xd}tjdkrDd}ddl}tjtd�}|j|j	|j
�|�tjtd	�}|j|j	|j
�|�dS)
N�ri�i��posixi�rz.datz.dir)rr&rrr	r!�name�statr�S_IMODE�st_mode)r"Z	old_umaskr#Z
expected_moder+�strrr�test_dumbdbm_creation_mode+s

z*DumbDBMTestCase.test_dumbdbm_creation_modecCs6tjt�}d|d<|j|dd�|j�|j�dS)Nrr)rrr	rr!)r"r#rrr�test_close_twiceAs

z DumbDBMTestCase.test_close_twicecCs`|j�tjtd�}d|jd<|d<|j|�|j|jdd�d�|j|dd�|j�dS)N�wsindentedrsxxxsfoo)	�init_dbrrr	rr r�
setdefaultr!)r"r#rrr�test_dumbdbm_modificationHs
z)DumbDBMTestCase.test_dumbdbm_modificationcCs�|j�tjtd�}|j|�|jtd��d|d<WdQRX|jtd��|d=WdQRX|j|jd�|j	d�|j|jdd�d�|j
|jd��|jt��|dWdQRX|j
�dS)	N�rz'The database is opened for reading only�xrrrsxxxsfoo)r2rrr	r �assertWarnsRegex�DeprecationWarningr�getrZassertIsNone�assertRaises�KeyErrorr!)r"r#rrr�test_dumbdbm_readRs
z!DumbDBMTestCase.test_dumbdbm_readcCs(|j�tjt�}|j|�}|j�dS)N)r2rrr	�keys_helperr!)r"r#rrrr�test_dumbdbm_keysds

z!DumbDBMTestCase.test_dumbdbm_keyscCs*tjt�}d|d<|jd|�|j�dS)Nshello�1)rrr	�assertInr!)r"r#rrr�test_write_containsjs
z#DumbDBMTestCase.test_write_containscCsHtjt�}d|d<d|d<|j�tjt�}|j|dd�|j�dS)Nshellor?shello2)rrr	r!r)r"r#rrr�test_write_write_readps

z%DumbDBMTestCase.test_write_write_readcCs4|j�tjtd�}|j|d|jdjd��dS)Nr5rzutf-8)r2rrr	rr�encode)r"r#rrr�
test_str_readzszDumbDBMTestCase.test_str_readcCsx|j�tjt�}d|d<d|d<|j�tjtd�}|jd|�|j|djd�|jdjd��|j|dd�dS)	Nrr�a�1r5zutf-8r?r)	r2rrr	r!r@rrCr)r"r#rrr�test_str_write_containss
z'DumbDBMTestCase.test_str_write_containscCs�tjt�}d|d<d|d<|j�tjtdd��}|j�}WdQRXtjdkr^|jdd	�}n|jd	d�}tjtdd
��}|j	|�WdQRXtjt�}|j
|dd�|j
|dd�dS)Nshellor?shello2�2z.dir�rb�
�
s
�wb)rrr	r!�io�readr�linesep�replace�writer)r"r#�file�datarrr�test_line_endings�s


z!DumbDBMTestCase.test_line_endingscCs4|j|�}x$|jD]}|j|j|||�qWdS)N)r=rr)r"r#rr$rrrr �s
zDumbDBMTestCase.read_helpercCs6tjtd�}x|jD]}|j|||<qW|j�dS)N�n)rrr	rr!)r"r#�krrrr2�szDumbDBMTestCase.init_dbcCs*t|j��}t|jj��}|j||�|S)N)�sortedrrr)r"r#rZdkeysrrrr=�szDumbDBMTestCase.keys_helperc	Cs�ddl}i}x�td�D]�}tjt�}xptd�D]d}|jd�}|j�dkr^||kr�||=||=q.|jd�|jd	�}|||<|||<|j|||�q.W|j�tjt�}t	d
d�|j
�D��}t	|j
��}|j||�|j�qWdS)
Nr��dZ
abcdefghijklmg�������?rrri'css |]\}}|jd�|fVqdS)zlatin-1N)rC)�.0rV�vrrr�	<genexpr>�sz.DumbDBMTestCase.test_random.<locals>.<genexpr>)rrr)�random�rangerrr	ZchoiceZ	randrangerr!rW�items)	r"r]�dZdummyr#rVr[ZexpectedZgotrrr�test_random�s(


zDumbDBMTestCase.test_randomcCsrtjtd��}d|d<WdQRXtjtd��}|jt|j��dg�WdQRX|jtj��|j�WdQRXdS)Nrzcontext managerzdumbdbm context managerr5sdumbdbm context manager)rrr	rrrr:�error)r"�dbrrr�test_context_manager�s z$DumbDBMTestCase.test_context_managercCs�tjtd�}|j�xhttj|�ttj|d�ttj|�ttj	|�fD]6}|j
tj��}|d�WdQRX|jt
|j�d�qDWxXtjd�tjd�tjd�tfD]6}|j
tj��}||�WdQRX|jt
|j�d�q�WdS)Nr�b�testz"DBM object has already been closedrZiterkeysr_)rrr	r!r�operator�delitem�setitem�getitem�containsr:rbr�strZ	exception�methodcaller�len)r"r#�meth�cmrrr�test_check_closed�s$



z!DumbDBMTestCase.test_check_closedcCsbtjtd��$}x|jD]}|j|||<qWWdQRXtjtd��}|j|j�g�WdQRXdS)NrU)rrr	rrr)r"r#rVrrr�test_create_new�s
zDumbDBMTestCase.test_create_newcCsxttdd��}|jd�WdQRXtj��B}|jt��tjt��}WdQRXWdQRX|j|j	�d�WdQRXdS)Nz.dirr1zstr(print('Hacked!')), 0
�)
rr	rQrZcaptured_stdoutr:�
ValueErrorrr�getvalue)r"�stream�stdoutr#rrr�	test_eval�s
zDumbDBMTestCase.test_evalcCsDx>dD]6}t�|jtd��tjt|�}WdQRX|j�qWdS)Nr5r1zIThe database file is missing, the semantics of the 'c' flag will be used.)r5r1)r
r7r8rrr	r!)r"�valuer#rrr�test_warn_on_ignored_flags�s
z*DumbDBMTestCase.test_warn_on_ignored_flagscCs>x8dD]0}|jtd��tjt|�}WdQRX|j�qWdS)N�x�rfz)Flag must be one of 'r', 'w', 'c', or 'n')r{r|N)r7r8rrr	r!)r"�flagr#rrr�test_invalid_flags

z!DumbDBMTestCase.test_invalid_flagcCs�tj���}tjj|d�}tj|d��8}|jt|j	��g�x|j
D]}|j
|||<qBWWdQRXtj|dtj
�tj|dtj
�tj|tj
tjB�tj|d��(}|jt|j	��t|j
��|j�WdQRXWdQRXdS)NrcrUz.dirz.datr5)rZtemp_dirr�path�joinrrrrrrr'r+�S_IRUSR�S_IXUSRrWr!)r"�dirZfnamer#r$rrr�test_readonly_filess
z#DumbDBMTestCase.test_readonly_filesz*requires OS support of non-ASCII encodingscCs�tj}xdD]}|jtj||�qWtj|d��}d|d<WdQRX|jtjj	|d��|jtjj	|d��tj|d��:}|j
t|j��dg�|jd|k�|j
|dd�WdQRXdS)	N�.dir�.dat�.bakrsvalueskeyr5)r�r�r�)
r�TESTFN_NONASCIIZ
addCleanuprrrZ
assertTruerr�existsrrr)r"�filename�suffixrcrrr�test_nonascii_filenames
z&DumbDBMTestCase.test_nonascii_filenamecCs
t�dS)N)r
)r"rrr�tearDown.szDumbDBMTestCase.tearDowncCs
t�dS)N)r
)r"rrr�setUp1szDumbDBMTestCase.setUpN)$�__name__�
__module__�__qualname__rCrr%�unittestZ
skipUnless�hasattrrr/r0r4r<r>rArBrDrGrTr r2r=rardrqrrrxrzr~r�rr�r�r�r�rrrrrsF


	
r�__main__)�__doc__rMrgrr+r��warningsZdbm.dumbZdumbrrfr�	functoolsrZTESTFNr	r
ZTestCaserr��mainrrrr�<module>s 


Youez - 2016 - github.com/yon3zu
LinuXploit