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.7/test/__pycache__/test_memoryview.cpython-37.opt-2.pyc
B

��g�E�@sLddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	Gdd�d�Z
Gdd�de
�ZGdd�de
�ZGdd	�d	�Z
Gd
d�d�ZGdd
�d
�ZGdd�deje
e�ZGdd�deje
e�ZGdd�dejee�ZGdd�dejee�ZGdd�dejee�ZGdd�dejee�ZGdd�dej�Zedk�rHe��dS)�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�0/usr/local/lib/python3.7/test/test_memoryview.py�_sourceszAbstractMemoryTests._sourcecCstd|j|jg�S)N)�filter�ro_type�rw_type)rrrr�_typesszAbstractMemoryTests._typescs$||j�}t�|�}|�|��|��dtd��|��dt�|��dtd��|��dtd��|��dtd��|�t	�fdd��|�t	�fd	d��|�t	�fd
d��|�t	�fdd��|�t
�fdd��|�t
�fd
d��|�t
�fdd��d�|�t�|�|�dS)Nr�a��f���i����cs�dS)N�rr)�mrr�<lambda>'�z=AbstractMemoryTests.check_getitem_with_type.<locals>.<lambda>cs�dS)Ni����rr)rrrr(rcs
�tjS)N)�sys�maxsizer)rrrr)rcs�tjS)N)rrr)rrrr*rcs�dS)Nrr)rrrr,rcs�dS)Ngrr)rrrr-rcs�dS)N�arr)rrrr.r)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]}|�|�qWdS)N)rr#)rr rrr�test_getitem2sz AbstractMemoryTests.test_getitemcsNxH|jD]>}||j�}|�|��|�t���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|�d�|�|j�}t�|�}|�|���fdd�}|�t|d�|�t|d�|�t|td��d�|�	t�|�|�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_readonlyc	s�|js|�d�|j�|�|j�}t�|�}|�|��td��d<|��|d��d��dd�<|��|d��d��dd	�<|��|d
��d��dd�<|��|d
��d��dd�<|��|d��d
d��dd	�<|��|d��d��dd�<�dd	��d
d�<|��|d���fdd�}|�t	|dd�|�t	|dd�|�t	|tj
d�|�t	|tj
d�|�t|dd�|�t|dd�|�t|tddd�dfd�|�t|dtddd�fd�|�t|dd�|�t|dd�tddd�tddd
�f}|�t
||d��jdk�r tnt}|�||dd�|�||dd�|�t|tdd�d�|�t|tdd
�d�d�|�t�|�|�dS)Nzno writable type to test�1rs1bcdef�0�s0bcdefs12�s012defrsabcdef�r
scdedefsababcfcs�|��|<dS)Nr)�keyr,)rr rrr-csz:AbstractMemoryTests.test_setitem_writable.<locals>.setitemrri����g)rr�csab)r
r/rrrrr�_check_contentsrrrr�slice�NotImplementedError�format�
ValueErrorr)rr!r"r-Zslices�excr)rr r�test_setitem_writableJsR


z)AbstractMemoryTests.test_setitem_writablec
Csdx^|jD]T}||j�}|�|�}|�t��|d=WdQRX|�t��|dd�=WdQRXqWdS)Nr4�)rrrrr)rr r!rrrr�test_delitem~s

z AbstractMemoryTests.test_delitemcs\xV�jD]L}��|�j��}|��}d��fdd�dD��}��||���|t�qWdS)Nrc3s|]}��t|g��VqdS)N)�getitem_type�bytes)r%r8)rrr�	<genexpr>�sz3AbstractMemoryTests.test_tobytes.<locals>.<genexpr>sabcdef)rrr�tobytes�joinrrrC)rr rr!Zexpectedr)rr�test_tobytes�sz AbstractMemoryTests.test_tobytescCs<x6|jD],}|�||j��}|��}|�|td��qWdS)Nsabcdef)rrr�tolistrr()rr r�lrrr�test_tolist�szAbstractMemoryTests.test_tolistcs��x�|jD�]�}|�||j���xz|jD]p}|��|d�k�|��|d�k�|��|d�k�|��|d�k�|��|d�k�|��|d�k�q(W|���k�|���dd�k�|��dd��dd�k�|��dd��k�|��dk�|��dk�|�d�k�|�d�k�xj�dfD]^�|�t��fdd	��|�t��fd
d	��|�t��fdd	��|�t��fdd	���q6Wq
WdS)
Nsabcdefsabcdesabcde1rrr
Zabcdefcs��kS)Nrr)r8rrrr�rz2AbstractMemoryTests.test_compare.<locals>.<lambda>cs��kS)Nrr)r8rrrr�rcs��kS)Nrr)r8rrrr�rcs��kS)Nrr)r8rrrr�r)rrr�
assertTrueZassertFalserr)rr Ztp_compr)r8rr�test_compare�s,z AbstractMemoryTests.test_comparecCs�|�||j��}|�|j|j�|�|j|j�|�|jd�|�|jd�|�t|�d�|�|j|jf�|�|j	d�|S)Nr4)rrr)
rrrr<�itemsize�ndim�shaper*�strides�
suboffsets)rr rrrr�check_attributes_with_type�sz.AbstractMemoryTests.check_attributes_with_typecCs.|js|�d�|�|j�}|�|jd�dS)Nzno read-only type to testT)r	r/rRr�readonly)rrrrr�test_attributes_readonly�s
z,AbstractMemoryTests.test_attributes_readonlycCs.|js|�d�|�|j�}|�|jd�dS)Nzno writable type to testF)r
r/rRrrS)rrrrr�test_attributes_writable�s
z,AbstractMemoryTests.test_attributes_writablecCs�x||jD]r}||j�}t�|�}|�|�}t�|�}t|d�}|�|||�d��|�t�|�|�d}|�t�|�|�qWdS)Nzutf-8)	rrrrr�strr9�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��}|�|�}|�}||_||_t�|�}d}}}t�	�|�
|�dk|��||d��}|�}||_||_t�|�}d}}t�	�|�
|�dk|��qWdS)Nc@seZdZdd�ZdS)z+AbstractMemoryTests.test_gc.<locals>.MyViewcSst|�|_dS)N)r0r)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�sr`c@seZdZdS)z-AbstractMemoryTests.test_gc.<locals>.MyObjectN)r\r]r^rrrr�MyObject�srasabc)r�
isinstance�typerr�o�weakref�ref�gcZcollectrK�x)	rr r_r`rar!rrd�wrrrr�test_gc�s.



zAbstractMemoryTests.test_gcc
Cs�|�td�}|�t|�WdQRX|�|��WdQRX|�|��WdQRX|�|dWdQRX|�d|d<WdQRX|�t|�WdQRX|�|jWdQRX|�|jWdQRX|�|jWdQRX|�|j	WdQRX|�|j
WdQRX|�|jWdQRX|�|�WdQRXWdQRX|�dt
|��|�dt|��|�||�|�|t||j���|�|||j��dS)NZreleasedr�xzreleased memory)ZassertRaisesRegexr=rCrErHr*r<rMrNrSrOrPZassertInrV�reprrZassertNotEqualr0r)rrr Zcheckrrr�_check_released�sBz#AbstractMemoryTests._check_releasedc
Csrxl|jD]b}||j�}|�|�}|�}|�||�WdQRX|�||�|�|�}|�|��WdQRXqWdS)N)rrr�assertIsrm�release)rr r!r�cmrrr�test_contextmanagers

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

z AbstractMemoryTests.test_releasecCsJ|j}|dkr|�d�||j�}|�|�}t�d�}|�t|j|�dS)Nzno read-only type to testsZZZZ)	r	r/rr�io�BytesIOrr�readinto)rr r!rr&rrr�test_writable_readonly-s



z*AbstractMemoryTests.test_writable_readonlycCs|�t|ji�dS)N)rrr)rrrr�test_getbuf_fail8sz$AbstractMemoryTests.test_getbuf_failcCs�|j}|dkr|�d�||j�}|�|�}|�t|�td��|��|�t|�td��|�|�}|��|�tt|�dS)Nzno read-only type to testsabcdef)	r	r/rrr�hashrorr=)rr r!rrrr�	test_hash;s



zAbstractMemoryTests.test_hashcCs>|j}|dkr|�d�||j�}|�|�}|�tt|�dS)Nzno writable type to test)r
r/rrrr=rx)rr r!rrrr�test_hash_writableMs


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


z AbstractMemoryTests.test_weakrefc	Csnxh|jD]^}||j�}|�|�}tt|����}|�tt|��|�|�tt|��t|ddd���qWdS)Nr)rrrr(�reversedrHr)rr r!rZaslistrrr�
test_reversedes

z!AbstractMemoryTests.test_reversedcCs�t�dddddg�}t|�}|�d�}|�d�}|dd�}t|�}~|�|dd�|�|dd�|�|jd�|�|jd�|�d�}|�|dd�|�|dd�|�|jd�|�|jd�dS)N�H��Brr6�I)�arrayr0�castrr<)rrrhrr!r8�d�_rrr�test_issue22668ms 


z#AbstractMemoryTests.test_issue22668N)r\r]r^r�propertyrrr#r$r+r1r?rArGrJrLrRrTrUrYrjrmrqrrrvrwryrzr�r�r�rrrrrs64	

&
	rc@s eZdZeZeZeZdZdZ	dS)�BaseBytesMemoryTestsr4r�N)
r\r]r^rCr	�	bytearrayr
rBrMr<rrrrr��s
r�c@sTeZdZdZdd�Zdd�Ze�d�jZdZe	�
d�dd��Ze	�
d	�d
d��ZdS)�BaseArrayMemoryTestsNcCst�dt|��S)Nr&)r�r()rr!rrrr�rzBaseArrayMemoryTests.<lambda>cCst�dt|����S)Nr&)r�r(rE)rr!rrrr�rr&z/XXX test should be adapted for non-byte bufferscCsdS)Nr)rrrrrY�sz#BaseArrayMemoryTests.test_getbufferz:XXX NotImplementedError: tolist() only supports byte viewscCsdS)Nr)rrrrrJ�sz BaseArrayMemoryTests.test_tolist)
r\r]r^r	r
rBr�rMr<�unittest�skiprYrJrrrrr��sr�c@seZdZdd�Zdd�ZdS)�BaseMemoryviewTestscCst|�S)N)r0)r�objrrrr�szBaseMemoryviewTests._viewcCs|�|||��dS)N)r)rr r��contentsrrrr9�sz#BaseMemoryviewTests._check_contentsN)r\r]r^rr9rrrrr��sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�BaseMemorySliceTestssXabcdefYcCst|�}|dd�S)Nr4�)r0)rr�rrrrr�szBaseMemorySliceTests._viewcCs|�|dd�||��dS)Nr4r�)r)rr r�r�rrrr9�sz$BaseMemorySliceTests._check_contentscCsJxD|jD]:}t||j��}t�|�}|dd�|�t�|�|�qWdS)Nr4r6)rr0rrrr)rr rr"rrr�	test_refs�s

zBaseMemorySliceTests.test_refsN)r\r]r^rrr9r�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�BaseMemorySliceSliceTestssXabcdefYcCst|�}|dd�dd�S)Nr�r4)r0)rr�rrrrr�szBaseMemorySliceSliceTests._viewcCs|�|dd�||��dS)Nr4r�)r)rr r�r�rrrr9�sz)BaseMemorySliceSliceTests._check_contentsN)r\r]r^rrr9rrrrr��sr�c@seZdZdd�ZdS)�BytesMemoryviewTestcCszxt|jD]j}||j�}|�t|��|�t|d��|�tt�|�tt||�|jtt|d�|jtt|dd�qWdS)N)�object)�argumentT)rrrKr0rr)rr Zobrrr�test_constructor�s
z$BytesMemoryviewTest.test_constructorN)r\r]r^r�rrrrr��sr�c@seZdZdd�ZdS)�ArrayMemoryviewTestcCsHt�dtd��}t|�}t�dtddd��}||dd�<|�||�dS)Nr&�
�	r)r�r)r0r)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�tj�d�}t|�d��}|��}t|��d�}|dd�|dd�<|dd�|dd�<|�|jd�x�dD]z}|�	|��f|��}t|��|�}t|��|�dd�|dd�<t|��|�dd�|dd�<|�|jd�WdQRXqlWdS)N�ctypesg333333�?r�r6ZBbc)
r~r�
import_modulerCZc_doubler0r�rr,ZsubTest)rr�Zp6r�rr<rrr�test_ctypes_cast�s
zOtherTest.test_ctypes_castcCs6dd}t|�}|ddd�}|�|��dd�dS)Nr3i@
rZ30)r0r�hex)rrhZm1Zm2rrr�test_memoryview_hexszOtherTest.test_memoryview_hexc	Cs,td�}|�t��t�|�WdQRXdS)Nsabc)r0rr�copy)rrrrr�	test_copyszOtherTest.test_copyc
CsFtd�}x8ttjd�D]&}|�t��t�||�WdQRXqWdS)Nsabcr4)r0r)�pickleZHIGHEST_PROTOCOLrr�dumps)rr�protorrr�test_pickleszOtherTest.test_pickleN)r\r]r^r�r�r�r�rrrrr��sr��__main__)r�Ztest.supportr~rrgrer�rsr�r�rr�r�r�r�r�ZTestCaser�r�r�r�r�r�r�r\�mainrrrr�<module>s>w
'