403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.5
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_memoryview.cpython-36.pyc
3

�w2_�E�@sPdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
Gdd�d�ZGdd�de�ZGdd�de�Z
Gd	d
�d
�ZGdd�d�ZGd
d�d�ZGdd�dejee�ZGdd�dejee
�ZGdd�dejee�ZGdd�dejee
�ZGdd�dejee�ZGdd�dejee
�ZGdd�dej�Zedk�rLej�dS)z�Unit tests for the memoryview

   Some tests are in test_bytes. Many tests that require _testbuffer.ndarray
   are in test_buffer.
�Nc@s�eZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6S)7�AbstractMemoryTestssabcdefcCs|jS)N)�source_bytes)�self�r�9/opt/alt/python36/lib64/python3.6/test/test_memoryview.py�_sourceszAbstractMemoryTests._sourcecCstd|j|jg�S)N)�filter�ro_type�rw_type)rrrr�_typesszAbstractMemoryTests._typescs$||j�}tj|�}|j|��|j�dtd��|j�dt�|j�dtd��|j�dtd��|j�dtd��|jt	�fdd��|jt	�fd	d��|jt	�fd
d��|jt	�fdd��|jt
�fdd��|jt
�fd
d��|jt
�fdd��d�|jtj|�|�dS)Nr�a��f��cs�dS)Nrrr)�mrr�<lambda>'sz=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>cs�dS)N�i����rr)rrrr(scs
�tjS)N)�sys�maxsizer)rrrr)scs�tjS)N)rrr)rrrr*scs�dS)Nrr)rrrr,scs�dS)Ngrr)rrrr-scs�dS)N�arr)rrrr.s���i����)rr�getrefcount�_view�assertEqual�ord�assertIsInstance�int�assertRaises�
IndexError�	TypeError)r�tp�b�oldrefcountr)rr�check_getitem_with_types"


z+AbstractMemoryTests.check_getitem_with_typecCsx|jD]}|j|�qWdS)N)rr$)rr!rrr�test_getitem2sz AbstractMemoryTests.test_getitemcsNxH|jD]>}||j�}|j|��|jt���fdd�tt���D��qWdS)Ncsg|]}�|�qSrr)�.0�i)rrr�
<listcomp>:sz1AbstractMemoryTests.test_iter.<locals>.<listcomp>)rrrr�list�range�len)rr!r"r)rr�	test_iter6s

zAbstractMemoryTests.test_itercs�|js|jd�|j|j�}tj|�}|j|���fdd�}|jt|d�|jt|d�|jt|td��d�|j	tj|�|�dS)Nzno read-only type to testcs|�d<dS)Nrr)�value)rrr�setitemBsz:AbstractMemoryTests.test_setitem_readonly.<locals>.setitemr�A)
r	�skipTestrrrrrr �
memoryviewr)rr"r#r.r)rr�test_setitem_readonly<s


z)AbstractMemoryTests.test_setitem_readonlycs�|js|jd�|j�|j|j�}tj|�}|j|��td��d<|j�|d��d��dd�<|j�|d��d��dd	�<|j�|d
��d��dd�<|j�|d
��d��dd�<|j�|d��d
d��dd	�<|j�|d��d��dd�<�dd	��d
d�<|j�|d���fdd�}|jt	|dd�|jt	|dd�|jt	|tj
d�|jt	|tj
d�|jt|dd�|jt|dd�|jt|tddd�dfd�|jt|dtddd�fd�|jt|dd�|jt|dd�tddd�tddd
�f}|jt
||d��jdk�r tnt}|j||dd�|j||dd�|jt|tdd�d�|jt|tdd
�d�d�|jtj|�|�dS)Nzno writable type to test�1rs1bcdef�0rs0bcdefs12�s012def�sabcdef�r
scdedefsababcfcs�|��|<dS)Nr)�keyr-)rr!rrr.csz:AbstractMemoryTests.test_setitem_writable.<locals>.setitemrrrgr�csabi����)r)r)r
r0rrrrr�_check_contentsrrrr �slice�NotImplementedError�format�
ValueErrorr)rr"r#r.Zslices�excr)rr!r�test_setitem_writableJsR


z)AbstractMemoryTests.test_setitem_writablecCsdx^|jD]T}||j�}|j|�}|jt��|d=WdQRX|jt��|dd�=WdQRXqWdS)Nr�)rrrrr )rr!r"rrrr�test_delitem~s

z AbstractMemoryTests.test_delitemcs\xV�jD]L}�j|�j��}|j�}dj�fdd�dD��}�j||��j|t�qWdS)Nr6c3s|]}�jt|g��VqdS)N)�getitem_type�bytes)r&r9)rrr�	<genexpr>�sz3AbstractMemoryTests.test_tobytes.<locals>.<genexpr>sabcdef)rrr�tobytes�joinrrrD)rr!rr"Zexpectedr)rr�test_tobytes�sz AbstractMemoryTests.test_tobytescCs<x6|jD],}|j||j��}|j�}|j|td��qWdS)Nsabcdef)rrr�tolistrr))rr!r�lrrr�test_tolist�szAbstractMemoryTests.test_tolistcs��x�|jD�]�}|j||j���xz|jD]p}|j�|d�k�|j�|d�k�|j�|d�k�|j�|d�k�|j�|d�k�|j�|d�k�q(W|j��k�|j��dd�k�|j�dd��dd�k�|j�dd��k�|j�dk�|j�dk�|jd�k�|jd�k�xj�dfD]^�|jt��fdd	��|jt��fd
d	��|jt��fdd	��|jt��fdd	���q6Wq
WdS)
Nsabcdefsabcdesabcde1rrr
Zabcdefcs��kS)Nrr)r9rrrr�sz2AbstractMemoryTests.test_compare.<locals>.<lambda>cs��kS)Nrr)r9rrrr�scs��kS)Nrr)r9rrrr�scs��kS)Nrr)r9rrrr�s)rrr�
assertTrueZassertFalserr )rr!Ztp_compr)r9rr�test_compare�s,z AbstractMemoryTests.test_comparecCs�|j||j��}|j|j|j�|j|j|j�|j|jd�|j|jd�|jt|�d�|j|j|jf�|j|j	f�|S)Nrr)r)
rrrr=�itemsize�ndim�shaper+�strides�
suboffsets)rr!rrrr�check_attributes_with_type�sz.AbstractMemoryTests.check_attributes_with_typecCs.|js|jd�|j|j�}|j|jd�dS)Nzno read-only type to testT)r	r0rSr�readonly)rrrrr�test_attributes_readonly�s
z,AbstractMemoryTests.test_attributes_readonlycCs.|js|jd�|j|j�}|j|jd�dS)Nzno writable type to testF)r
r0rSrrT)rrrrr�test_attributes_writable�s
z,AbstractMemoryTests.test_attributes_writablecCs�x||jD]r}||j�}tj|�}|j|�}tj|�}t|d�}|j|||jd��|jtj|�|�d}|jtj|�|�qWdS)Nzutf-8)	rrrrr�strr:�encoder)rr!r"r#rZoldviewrefcount�srrr�test_getbuffer�s




z"AbstractMemoryTests.test_getbufferc	Cs�x�|jD]�}t|t�sqGdd�d�}Gdd�d|�}Gdd�d�}||d��}|j|�}|�}||_||_tj|�}d}}}tj	�|j
|�dk|��||d��}|�}||_||_tj|�}d}}tj	�|j
|�dk|��qWdS)Nc@seZdZdd�ZdS)z+AbstractMemoryTests.test_gc.<locals>.MyViewcSst|�|_dS)N)r1r)r�baserrr�__init__�sz4AbstractMemoryTests.test_gc.<locals>.MyView.__init__N)�__name__�
__module__�__qualname__r\rrrr�MyView�sr`c@seZdZdS)z-AbstractMemoryTests.test_gc.<locals>.MySourceN)r]r^r_rrrr�MySource�srac@seZdZdS)z-AbstractMemoryTests.test_gc.<locals>.MyObjectN)r]r^r_rrrr�MyObject�srbsabc)r�
isinstance�typerr�o�weakref�ref�gcZcollectrL�x)	rr!r`rarbr"rre�wrrrr�test_gc�s.



zAbstractMemoryTests.test_gccgCs�|jtd�}|�t|�WdQRX|�|j�WdQRX|�|j�WdQRX|�|dWdQRX|�d|d<WdQRX|�t|�WdQRX|�|jWdQRX|�|jWdQRX|�|jWdQRX|�|j	WdQRX|�|j
WdQRX|�|jWdQRX|�|�WdQRXWdQRX|jdt
|��|jdt|��|j||�|j|t||j���|j|||j��dS)NZreleasedr�xzreleased memory)ZassertRaisesRegexr>rDrFrIr+r=rNrOrTrPrQZassertInrW�reprrZassertNotEqualr1r)rrr!Zcheckrrr�_check_released�sBz#AbstractMemoryTests._check_releasedcCsrxl|jD]b}||j�}|j|�}|�}|j||�WdQRX|j||�|j|�}|�|j�WdQRXqWdS)N)rrr�assertIsrn�release)rr!r"r�cmrrr�test_contextmanagers


z'AbstractMemoryTests.test_contextmanagercCsPxJ|jD]@}||j�}|j|�}|j�|j||�|j�|j||�qWdS)N)rrrrprn)rr!r"rrrr�test_release#s

z AbstractMemoryTests.test_releasecCsJ|j}|dkr|jd�||j�}|j|�}tjd�}|jt|j|�dS)Nzno read-only type to testsZZZZ)	r	r0rr�io�BytesIOrr �readinto)rr!r"rr'rrr�test_writable_readonly-s



z*AbstractMemoryTests.test_writable_readonlycCs|jt|ji�dS)N)rr r)rrrr�test_getbuf_fail8sz$AbstractMemoryTests.test_getbuf_failcCs�|j}|dkr|jd�||j�}|j|�}|jt|�td��|j�|jt|�td��|j|�}|j�|jtt|�dS)Nzno read-only type to testsabcdef)	r	r0rrr�hashrprr>)rr!r"rrrr�	test_hash;s



zAbstractMemoryTests.test_hashcCs>|j}|dkr|jd�||j�}|j|�}|jtt|�dS)Nzno writable type to test)r
r0rrrr>ry)rr!r"rrrr�test_hash_writableMs


z&AbstractMemoryTests.test_hash_writablecs�xz|jD]p}||j�}|j|�}g�|f�fdd�	}tj||�}|j|�|�~tjj�|j|�d�|j�d|�qWdS)Ncs�j|�dS)N)�append)rjr")�Lrr�callback\sz2AbstractMemoryTests.test_weakref.<locals>.callbackr)	rrrrfrgro�test�supportZ
gc_collect)rr!r"rr~rjr)r}r�test_weakrefVs


z AbstractMemoryTests.test_weakrefcCsnxh|jD]^}||j�}|j|�}tt|j���}|jtt|��|�|jtt|��t|ddd���qWdS)Nrr)rrrr)�reversedrIr)rr!r"rZaslistrrr�
test_reversedes

z!AbstractMemoryTests.test_reversedcCs�tjdddddg�}t|�}|jd�}|jd�}|dd�}t|�}~|j|dd�|j|dd�|j|jd�|j|jd�|jd�}|j|dd�|j|dd�|j|jd�|j|jd�dS)N�H��Brr7�I)�arrayr1�castrr=)rrrirr"r9�d�_rrr�test_issue22668ms 


z#AbstractMemoryTests.test_issue22668N)r]r^r_r�propertyrrr$r%r,r2r@rBrHrKrMrSrUrVrZrkrnrrrsrwrxrzr{r�r�r�rrrrrs64	

&
	rc@s eZdZeZeZeZdZdZ	dS)�BaseBytesMemoryTestsrr�N)
r]r^r_rDr	�	bytearrayr
rCrNr=rrrrr��s
r�c@sTeZdZdZdd�Zdd�Zejd�jZdZe	j
d�dd��Ze	j
d	�d
d��ZdS)�BaseArrayMemoryTestsNcCstjdt|��S)Nr')r�r))rr"rrrr�szBaseArrayMemoryTests.<lambda>cCstjdt|��j�S)Nr')r�r)rF)rr"rrrr�sr'z/XXX test should be adapted for non-byte bufferscCsdS)Nr)rrrrrZ�sz#BaseArrayMemoryTests.test_getbufferz:XXX NotImplementedError: tolist() only supports byte viewscCsdS)Nr)rrrrrK�sz BaseArrayMemoryTests.test_tolist)
r]r^r_r	r
rCr�rNr=�unittest�skiprZrKrrrrr��sr�c@seZdZdd�Zdd�ZdS)�BaseMemoryviewTestscCst|�S)N)r1)r�objrrrr�szBaseMemoryviewTests._viewcCs|j|||��dS)N)r)rr!r��contentsrrrr:�sz#BaseMemoryviewTests._check_contentsN)r]r^r_rr:rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BaseMemorySliceTestssXabcdefYcCst|�}|dd�S)Nrr)r1)rr�rrrrr�szBaseMemorySliceTests._viewcCs|j|dd�||��dS)Nrr)r)rr!r�r�rrrr:�sz$BaseMemorySliceTests._check_contentscCsJxD|jD]:}t||j��}tj|�}|dd�|jtj|�|�qWdS)Nrr7)rr1rrrr)rr!rr#rrr�	test_refs�s

zBaseMemorySliceTests.test_refsN)r]r^r_rrr:r�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�BaseMemorySliceSliceTestssXabcdefYcCst|�}|dd�dd�S)Nrr)r1)rr�rrrrr�szBaseMemorySliceSliceTests._viewcCs|j|dd�||��dS)Nrr)r)rr!r�r�rrrr:�sz)BaseMemorySliceSliceTests._check_contentsN)r]r^r_rrr:rrrrr��sr�c@seZdZdd�ZdS)�BytesMemoryviewTestcCszxt|jD]j}||j�}|jt|��|jt|d��|jtt�|jtt||�|jtt|d�|jtt|dd�qWdS)N)�object)ZargumentT)rrrLr1rr )rr!�obrrr�test_constructor�s
z$BytesMemoryviewTest.test_constructorN)r]r^r_r�rrrrr��sr�c@seZdZdd�ZdS)�ArrayMemoryviewTestcCsHtjdtd��}t|�}tjdtddd��}||dd�<|j||�dS)Nr'�
�	rrr)r�r*r1r)rrrZnew_arrr�test_array_assign�s
z%ArrayMemoryviewTest.test_array_assignN)r]r^r_r�rrrrr��sr�c@seZdZdS)�BytesMemorySliceTestN)r]r^r_rrrrr��sr�c@seZdZdS)�ArrayMemorySliceTestN)r]r^r_rrrrr��sr�c@seZdZdS)�BytesMemorySliceSliceTestN)r]r^r_rrrrr��sr�c@seZdZdS)�ArrayMemorySliceSliceTestN)r]r^r_rrrrr��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	OtherTestcCs�tjjd�}t|jd��}|j�}t|�jd�}|dd�|dd�<|dd�|dd�<|j|jd�x�dD]z}|j	|��f|j�}t|�j|�}t|�j|�dd�|dd�<t|�j|�dd�|dd�<|j|jd�WdQRXqlWdS)N�ctypesg333333�?r�r7ZBbc)
rr��
import_modulerDZc_doubler1r�rr-ZsubTest)rr�Zp6r�rr=rrr�test_ctypes_cast�s
zOtherTest.test_ctypes_castcCs6dd}t|�}|ddd�}|j|j�dd�dS)Nr4i@
rZ30r)r1r�hex)rri�m1�m2rrr�test_memoryview_hexszOtherTest.test_memoryview_hexc	Cs,td�}|jt��tj|�WdQRXdS)Nsabc)r1rr �copy)rrrrr�	test_copyszOtherTest.test_copycCsFtd�}x8ttjd�D]&}|jt��tj||�WdQRXqWdS)Nsabcr)r1r*�pickleZHIGHEST_PROTOCOLrr �dumps)rr�protorrr�test_pickleszOtherTest.test_pickleN)r]r^r_r�r�r�r�rrrrr��sr��__main__)�__doc__r�Ztest.supportrrrhrfr�rtr�r�rr�r�r�r�r�ZTestCaser�r�r�r�r�r�r�r]�mainrrrr�<module>s@w
'


Youez - 2016 - github.com/yon3zu
LinuXploit