Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_dbm_dumb.cpython-310.pyc
o

�9j�*�@s�dZddlZddlZddlZddlZddlZddlZddlmZ	ddl
mZddlm
Z
ddlmZe
jZdd�ZGdd	�d	ej�Zed
krLe��dSdS)zATest script for the dumbdbm module
   Original by Roger E. Masse
�N)�support)�	os_helper)�partialc	Cs2dD]}z	t�t|�WqtyYqwdS)N��.dir�.dat�.bak)�os�unlink�_fname�OSError)�ext�r�)/usr/lib/python3.10/test/test_dbm_dumb.py�
_delete_filess��rc@s&eZdZddddddddd	d
ddd
dd�d�diZdd�Ze�ee	d�d�dd��Z
dd�Zdd�Zdd�Z
dd�Zd 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?�Zd@dA�Ze�e j!dB�dCdD��Z"dEdF�Z#dGdH�Z$dIS)J�DumbDBMTestCase�0��asPython:�bsProgramming�csthe�dsway�fsGuido�gsintended�ü�utf-8�!cCspt�t�td���%}|�t|���g�|jD]	}|j|||<q|�	|�Wd�dS1s1wYdS)N�c)
�
contextlib�closing�dumbdbm�openr�assertEqual�list�keys�_dict�read_helper)�self�f�keyrrr�test_dumbdbm_creation%s
"�z%DumbDBMTestCase.test_dumbdbm_creation�umaskztest needs os.umask()c	Cs�zt�d�}t�tdd�}|��Wt�|�nt�|�wd}tjdkr'd}ddl}t�td�}|�|�	|j
�|�t�td	�}|�|�	|j
�|�dS)
N�ri�i��posixi�rrr)r	r+r r!r�close�name�statr"�S_IMODE�st_mode)r'�	old_umaskr(�
expected_moder0�strrr�test_dumbdbm_creation_mode,s


z*DumbDBMTestCase.test_dumbdbm_creation_modecCs6t�t�}d|d<|�|dd�|��|��dS)Nrr)r r!rr"r.�r'r(rrr�test_close_twiceAs

z DumbDBMTestCase.test_close_twicecCs�|��t�t�td���)}d|jd<|d<|�|�|�|�	dd�d�|�|dd�Wd�dS1s9wYdS)N�wsindentedr�xxx�foo)
�init_dbrrr r!rr%r&r"�
setdefaultr7rrr�test_dumbdbm_modificationHs
"�z)DumbDBMTestCase.test_dumbdbm_modificationc	Cs2|��t�t�td����}|�|�|�tjd��d|d<Wd�n1s)wY|�tjd��|d=Wd�n1sCwY|�	|�
d�|jd�|�	|�
dd�d�|�|�
d��|�
t��|dWd�n1szwYWd�dSWd�dS1s�wYdS)N�rz'The database is opened for reading only�xrrr:r;)r<rrr r!rr&�assertRaisesRegex�errorr"�getr%�assertIsNone�assertRaises�KeyErrorr7rrr�test_dumbdbm_readQs,
�
���
��"�z!DumbDBMTestCase.test_dumbdbm_readcCsH|��t�t�t���}|�|�}Wd�dS1swYdS�N)r<rrr r!r�keys_helper)r'r(r$rrr�test_dumbdbm_keysbs"�z!DumbDBMTestCase.test_dumbdbm_keyscCsJt�t�t���}d|d<|�d|�Wd�dS1swYdS)N�hello�1)rrr r!r�assertInr7rrr�test_write_containsgs"�z#DumbDBMTestCase.test_write_containscCs�t�t�t���}d|d<d|d<Wd�n1swYt�t�t���}|�|dd�Wd�dS1s<wYdS)NrKrL�hello2)rrr r!rr"r7rrr�test_write_write_readls
�"�z%DumbDBMTestCase.test_write_write_readcCs\|��t�t�td���}|�|d|jd�d��Wd�dS1s'wYdS)Nr?rr)	r<rrr r!rr"r%�encoder7rrr�
test_str_readts"�zDumbDBMTestCase.test_str_readcCs�|��t�t�t���}d|d<d|d<Wd�n1swYt�t�td���(}|�d|�|�|d�d�|j	d�d��|�|dd�Wd�dS1sXwYdS)	Nrr�a�1r?rrLr)
r<rrr r!rrMr"rQr%r7rrr�test_str_write_containsys
��"�z'DumbDBMTestCase.test_str_write_containscCst�t�t���}d|d<d|d<Wd�n1swYt�tdd��}|��}Wd�n1s7wYtjdkrH|�	dd	�}n|�	d	d�}t�tdd
��
}|�
|�Wd�n1sfwYt�t�}|�|dd�|�|dd�dS)NrKrLrO�2r�rb�
�
s
�wb)rrr r!r�io�readr	�linesep�replace�writer")r'r(�file�datarrr�test_line_endings�s 
�
�
�
z!DumbDBMTestCase.test_line_endingscCs0|�|�}|jD]
}|�|j|||�qdSrH)rIr%r")r'r(r$r)rrrr&�s

�zDumbDBMTestCase.read_helpercCsRt�t�td���}|jD]	}|j|||<q
Wd�dS1s"wYdS�N�n)rrr r!rr%�r'r(�krrrr<�s

�"�zDumbDBMTestCase.init_dbcCs*t|���}t|j���}|�||�|SrH)�sortedr$r%r")r'r(r$�dkeysrrrrI�szDumbDBMTestCase.keys_helperc		Csddl}i}td�D]�}t�t�t���?}td�D]2}|�d�}|��dkr1||vr0||=||=q|�d�|�d�}|||<|||<|�	|||�qWd�n1sVwYt�t�t���}t
dd	�|��D��}t
|���}|�	||�Wd�n1s�wYq
dS)
Nr��d�
abcdefghijklmg�������?)rrri'css"�|]\}}|�d�|fVqdS)zlatin-1N)rQ)�.0rf�vrrr�	<genexpr>�s� z.DumbDBMTestCase.test_random.<locals>.<genexpr>)�random�rangerrr r!r�choice�	randranger"rg�items)	r'ro�d�dummyr(rfrm�expected�gotrrr�test_random�s0
���
���zDumbDBMTestCase.test_randomcCs�t�td��}d|d<Wd�n1swYt�td��}|�t|���dg�Wd�n1s6wY|�tj��
|��Wd�dS1sQwYdS)Nrzcontext managerzdumbdbm context managerr?sdumbdbm context manager)r r!rr"r#r$rErB)r'�dbrrr�test_context_manager�s
��
"�z$DumbDBMTestCase.test_context_managerc	Cs�t�td�}|��ttj|�ttj|d�ttj|�ttj	|�fD]%}|�
tj��}|d�Wd�n1s8wY|�t
|j�d�q!t�d�t�d�t�d�tfD]%}|�
tj��}||�Wd�n1smwY|�t
|j�d�qVdS)Nr�b�testz"DBM object has already been closedr$�iterkeysrs)r r!rr.r�operator�delitem�setitem�getitem�containsrErBr"�str�	exception�methodcaller�len)r'r(�meth�cmrrr�test_check_closed�s2


�
���
���z!DumbDBMTestCase.test_check_closedcCs�t�td��}|jD]	}|j|||<q
Wd�n1swYt�td��}|�|��g�Wd�dS1s=wYdSrc)r r!rr%r"r$rerrr�test_create_new�s
��"�zDumbDBMTestCase.test_create_newc
Cs�ttdddd��
}|�d�Wd�n1swYt���;}|�t��t�t��}Wd�n1s9wYWd�n1sHwY|�|�	�d�Wd�dS1s`wYdS)Nrr9r)�encodingzstr(print('Hacked!')), 0
�)
r!rr_r�captured_stdoutrE�
ValueErrorr r"�getvalue)r'�stream�stdoutr(rrr�	test_eval�s�
���"�zDumbDBMTestCase.test_evalc	CsvdD]6}t�|�t��t�t|�Wd�n1swY|�tj�	td��|�tj�	td��qdS)N�r?r9rr)
rrE�FileNotFoundErrorr r!r�assertFalser	�path�exists)r'�valuerrr�test_missing_data�s��z!DumbDBMTestCase.test_missing_datac	Cs�t�td��}Wd�n1swYt�td�dD]3}|�t��t�t|�Wd�n1s7wY|�tj�	td��|�tj�	td��qdS)Nrdrr�r)
r r!rr	r
rEr�r�r�r�)r'r(r�rrr�test_missing_index�s���z"DumbDBMTestCase.test_missing_indexc	CsFdD]}|�td��t�t|�Wd�n1swYqdS)N)�x�rfNz)Flag must be one of 'r', 'w', 'c', or 'n')rAr�r r!r)r'�flagrrr�test_invalid_flags����z!DumbDBMTestCase.test_invalid_flagc	Cs,t����}tj�|d�}t�|d��}|�t|�	��g�|j
D]	}|j
|||<q Wd�n1s4wYt�|dtj
�t�|dtj
�t�|tj
tjB�t�|d��}|�t|�	��t|j
��|��Wd�n1swwYWd�dSWd�dS1s�wYdS)Nryrdrrr?)r�temp_dirr	r��joinr r!r"r#r$r%�chmodr0�S_IRUSR�S_IXUSRrgr.)r'�dir�fnamer(r)rrr�test_readonly_filess$

��
��	"�z#DumbDBMTestCase.test_readonly_filesz*requires OS support of non-ASCII encodingscCs�tj}dD]}|�tj||�qt�|d��}d|d<Wd�n1s&wY|�tj�	|d��|�tj�	|d��t�|d��#}|�
t|���dg�|�d|v�|�
|dd�Wd�dS1smwYdS)Nrrsvalueskeyrrr?)
r�TESTFN_NONASCII�
addCleanupr
r r!�
assertTruer	r�r�r"r#r$)r'�filename�suffixryrrr�test_nonascii_filenames
�"�z&DumbDBMTestCase.test_nonascii_filenamecC�
t�dSrH�r�r'rrr�tearDown)�
zDumbDBMTestCase.tearDowncCr�rHr�r�rrr�setUp,r�zDumbDBMTestCase.setUpN)%�__name__�
__module__�__qualname__rQr%r*�unittest�
skipUnless�hasattrr	r6r8r>rGrJrNrPrRrUrbr&r<rIrxrzr�r�r�r�r�r�r�rr�r�r�r�rrrrrsP
�

	
	
�

r�__main__)�__doc__rr[r~r	r0r��dbm.dumb�dumbr r|r�test.supportr�	functoolsr�TESTFNrr�TestCaserr��mainrrrr�<module>s&�

Youez - 2016 - github.com/yon3zu
LinuXploit