Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_struct.cpython-38.pyc
U

>��g���@s�ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ej
dkZdZdZ
e
fdd�Zd	d
�Zdd�ZGd
d�dej�ZGdd�dej�Zedkr�e��dS)�)�abcN)�support�big)�b�B�h�H�i�I�l�L�q�Q�n�N)��@�=�<�>�!ccs4tD]*}|D] }|dkr"|dkr"q||fVqqdS)N�rr)rr)�
integer_codes)�
byteorders�code�	byteorder�r�//opt/cppython/lib/python3.8/test/test_struct.py�iter_integer_formatss
rcCs|ddd�S)N���r)�srrr�string_reversesr!cCstr|St|�SdS�N)�ISBIGENDIANr!)�valuerrr�bigendian_to_nativesr%c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zejd'd(��Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5S)6�
StructTestcCs |�t�dd�ddkt�dS)Nz=i�r)�assertEqual�struct�packr#��selfrrr�test_isbigendian!szStructTest.test_isbigendiancCs|�tjtjd�t�d�}|�|dt�d��d}d}t�|�}t�|�}|�|d|�|�tjtjdd�|�tjtjdddd�|�ttjftjdd�|�ttjftjdd�|�tjtjd	d
�t�ddd
�}|�tjtjd|�|�tjtjd|�dS)N�Zr	�Ziiizcbxxxxxxhhhhiillffd?z3c3b18x12h6i6l6f3d3?Zfoo�P�dsflap�iir'�)�assertRaisesr)�error�calcsizer(r*�	TypeError�unpack)r,Zsz�fmtZfmt3Zsz3r rrr�test_consistence$s 


zStructTest.test_consistencec
Cs�d}d}d}d}d}d}d}d}dD]�}	d	D]�}
|	|
}
t�|
||||||||�	}t�|
|�\}}
}}}}}}|�||�|�|
|�|�||�|�||�|�||�|�td
|�td
|��|�td
|�td
|��|�||�q,q$dS)N�ar'�i��igo���!	@T)rrrrrr)z	xcbhilfd?z	xcBHILfd?�d)r)r*r8r(�int)r,�crrr	r�fr1�t�prefix�formatr ZcpZbpZhpZipZlp�fpZdp�tprrr�test_transitiveness9s*zStructTest.test_transitivenessc&Cs�ddddddddd	d
ddd
ddddddddddddddddddd d!d"gd#d#d$fd%g#}|D]�\}}}}}d&||fd'||fd(||fd)|tr�|p�|ffD]X\}}t�||�}	|�|	|�|�t�|�t|	��t�||	�d*}
|
|kr�|�|�q�qXdS)+N)r?r;r;r;r)Zxcr;�arGr)Zcxr;�arHr)r r;r;r;r)�0s�
helloworld�rKr')Z1srJ�hrLr')Z9srJ�	helloworlrMr')Z10srJrJrJr)Z11srJ�helloworldrNr')Z20srJ�helloworldrOr')r��rQr)ri������rRr)rrPrQrQr)r�rRrRr)r�����r)riD�����D�D�r)rrTrUrVr)riD�rWrXr)r	�,�,���,r)r	�����������r)r
rYrZr[r)r
��b�wr]r^r)rrYrZr[r)rr\r]r^r)rrYrZr[r)rr_r]r^r)r@�@s@s@r)r1r`s@s@r)r@��s�s�r)r1ras�s�r)�?r�rcr)rbr/�rdr')rbTrdrdrrbrcr')rb)r'rdrdr'rrrrr)r#r)r*r(r6�lenr8�
assertTrue)r,Ztestsr9�argrZlilZasyZxfmt�exp�resZrevrrr�test_new_featuresQs\�(�zStructTest.test_new_featuresc
CsZddddddddddd�
}td�D]*\}}||}t�|�}|�|||�q"d}|D]>}dD]4}t�||d	�}t�||d�}	|�||	�q^qV|�t�d
�d�|�dt�d��|�dt�d��|�t�d�t�d
��|�t�d
�t�d��|�dt�d��|�t�d�t�d��|�t�d�t�d
��|�t�d�t�d��dS)Nr'r3��)
rrrrr	r
rrr
r�rrrr)ZbBZhHZiIZlL�nNZqQrrrrrr	r
rr0)rr)r6r(ZassertLessEqual�assertGreaterEqual)
r,Z
expected_sizerrrC�sizeZnative_pairsZformat_pairZsigned_sizeZ
unsigned_sizerrr�
test_calcsize�s<�	
zStructTest.test_calcsizecsNddl�G���fdd�dtj��t�D] \}}||����}|��q(dS)Nrcs@eZdZ��fdd�Zejej�jfdd�Z�fdd�Z	�Z
S)z+StructTest.test_integers.<locals>.IntTestercs�t�|�jdd�||_|d|_|dd�|_|jtkrHtd|j��t�|�|_	|j	d|_
|jtd�kr�d|_d|j
d	|_
d|j
d	d	|_n:|jtd
�kr�d|_d|_
d|j
d	|_ntd
|j��dS)N�test_one)Z
methodNamerz"unrecognized packing byteorder: %srlZbhilqnTr3r'ZBHILQNFrzunrecognized format code: %s)�super�__init__rCrrr�
ValueErrorr)r6�bytesize�bitsize�tuple�signed�	min_value�	max_value)r,rC)�	IntTester�	__class__rrrt�s*

��z4StructTest.test_integers.<locals>.IntTester.__init__c	Ss.|j}|j|kr |jk�rnn�|}|jrD|dkrD|d|j>7}|�|d�d|}t|�d@rld|}|�d�}||�}d|jt|�|}|j	dks�|j	dkr�t
s�t|�}|�t|�|j�|||�}|�||�|||�d}|�||�|�
tjtf||d	|�n|�
tttjf|||�dS)
Nrr'z%x�0�asciircr)rrrrd)rCrzr{ryrwrore�encodervrr#r!r(r4r)r5r7�
OverflowErrorru)	r,�xr*r8�	unhexlifyrC�expected�gotZ	retrievedrrrrr�sB
�
��
��z4StructTest.test_integers.<locals>.IntTester.test_onecsddlm}g}t|jd�D]}|�d|>�qt|j�D]2}d}t|j�D]}|d>|d�B}qN|�|�q<|�ddtjd	g�|D]0}||fD] }d
D]}||}	|�	|	�q�q�q�Gdd�d�}
Gd
d�dt
�}Gdd�dt
�}|�tt
jft
j|jd�|�tt
jft
j|j|�|�tt
jft
j|jd�|�tt
jft
j|j|
��|�tt
jft
j|j|��|d�|d�|d�|d�|d�|d�fD].}
zt
��|
�Wn|�d�YnX�q�|d�|d�|d�|ddi�|dddg�fD] }
|�tt
jft
j|j|
��q�dS)Nr)�	randranger/r'rl�i,i`�
rk)rrr'c@seZdZdd�ZdS)zAStructTest.test_integers.<locals>.IntTester.run.<locals>.NotAnIntcSsdS�N�*rr+rrr�__int__szIStructTest.test_integers.<locals>.IntTester.run.<locals>.NotAnInt.__int__N)�__name__�
__module__�__qualname__r�rrrr�NotAnIntsr�c@seZdZdd�Zdd�ZdS)zBStructTest.test_integers.<locals>.IntTester.run.<locals>.IndexablecSs
||_dSr"��_value)r,r$rrrrtszKStructTest.test_integers.<locals>.IntTester.run.<locals>.Indexable.__init__cSs|jSr"r�r+rrr�	__index__szLStructTest.test_integers.<locals>.IntTester.run.<locals>.Indexable.__index__N)r�r�r�rtr�rrrr�	Indexable
sr�c@seZdZdd�Zdd�ZdS)zAStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndexcSst�dSr")r7r+rrrr�szKStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndex.__index__cSsdSr�rr+rrrr�szIStructTest.test_integers.<locals>.IntTester.run.<locals>.BadIndex.__int__N)r�r�r�r�r�rrrr�BadIndexsr�za stringy@E@�
�r�r=�z:integer code pack failed on object with '__index__' methodr;r�ar3)�randomr��rangerw�appendrv�extend�sys�maxsizerr�objectr4r7r)r5r*rC�fail)r,r��valuesrhr	�val�j�baseZincrr�r�r�r��obj)rCrr�run�sz	������
��z/StructTest.test_integers.<locals>.IntTester.run)r�r�r�rtr)r*r8r�rrr��
__classcell__r�r|�binasciirC)r}rr|�s�
&r|)r��unittest�TestCaserr�)r,rrrArr�r�
test_integers�szStructTest.test_integerscsT�fdd�}dD]>}dD]4}||}|tj|�|tj|d�|tj|d�qqdS)Nc	s8��tj��}|||�W5QRX��dt|j��dS)Nzbad char in struct format)r4r)r5ZassertIn�str�	exception)�func�args�kwargs�cmr+rr�assertStructErrorDsz2StructTest.test_nN_code.<locals>.assertStructErrorrnrmrrK)r)r6r*r8)r,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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxs�xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)r)r*r(r8)r,r�inputr�Zexpectedbackr�rrr�test_p_codeOs
	zStructTest.test_p_codecCs�tdd�D]�}d}||d|kr,|d}q||}t�d|�}t�d|�d}|�||�t�d|�}|�|t|��t�d|�d}|�||�q
d}t�|d	�}t�d|�}t�d|�d}|�||�d
}t�|d�}|�t	tjd|�dS)Nr'�!g�?r`z<frz>fi����hi����g)
r�r)r*r8r(r!�math�ldexpr4r�)r,r�ZdeltaZsmaller�packedZunpackedZ	bigpackedrrrr�test_705836_s(
zStructTest.test_705836cCslt�D]8\}}||}|�tjtj|d�|�tjtj|d�q|�tjtjdd�|�tjtjdd�dS)N��?g�?r0)rr4r)r5r*)r,rrrCrrr�test_1530559�szStructTest.test_1530559c	Cs�d}d}t�|�}ttfD]�}||�}|�|�|�d�|�|�|d�d�|�|�|d�d�td�D]&}|�|�||�|||d�f�qhtdt|�d	�D]}|�tj	|j||�q�qttfD]�}||�}|�t�||�d�|�t�||d�d�|�t�||d�d�td�D]*}|�t�|||�|||d�f��qtdt|�d	�D]}|�tj	tj|||��qXq�|�|j|dd
�d�dS)Ns	abcd01234Z4s)sabcdr3)scd01rk)s0123�r')�buffer�offset)
r)�Struct�bytes�	bytearrayr(�unpack_fromr�rer4r5)r,�test_stringr9r �cls�datar	rrr�test_unpack_from�s0
$(�zStructTest.test_unpack_fromcCs�d}t�dd�}d}t�|�}|�|d|�|��dt|��}|�||�|�|d|�|��dt|�d�}|�||dd�|�t�dd�}|�ttj	f|j|d|�|�ttj	f|j|d|�|}|�t
tj	ftjd	|d�dS)
N�Reykjavik rocks, eow!r�d                                                                                                    �21srr��
          r3rK)�arrayr)r��	pack_into�tobytesrer(r4rur5r7)r,r��writable_bufr9r �from_buf�	small_bufZsbrrr�test_pack_into�s*
���zStructTest.test_pack_intocs�d}t�dd�}d��fdd�}||d|�|��dt|��}|�||�||d|�|��dt|�d�}|�||dd�|�t�dd	�}|�ttjf||d|�|�ttjf||d
|�dS)Nr�rr�r�cstj�f|��Sr")r)r�)r��r9rr�<lambda>�rKz.StructTest.test_pack_into_fn.<locals>.<lambda>rr�r�r3)r�r�rer(r4rur)r5)r,r�r�r�r�r�rr�r�test_pack_into_fn�s"��zStructTest.test_pack_into_fncCs@t�dd�}td�}||fD]}t�d|�\}|�|d�qdS)Nrs4Vxz>IixV4)r��
memoryviewr)r8r()r,Zdata1Zdata2r�r$rrr�test_unpack_with_buffer�s
z"StructTest.test_unpack_with_bufferc	Cs�Gdd�dt�}td�dD�]V}dggddf}dgd	d
ddd
f}|dt|�}tj|f|��}t�||�}|dt|�}tj|f|��}	t�||	�}
|�t|�t|
��|�t|�t|��|D]}|�|�q�|
D]}|�|�q�t�|dd�}|�t|�t�	|d��t|�dk�r4|j|d|d�zt�|d|��Wnt
k
�r`YqX|�d|d�qdD]}
|�t�d|
�d��qzdS)Nc@seZdZdd�ZdS)z+StructTest.test_bool.<locals>.ExplodingBoolcSst�dSr")�OSErrorr+rrr�__bool__�sz4StructTest.test_bool.<locals>.ExplodingBool.__bool__N)r�r�r�r�rrrr�
ExplodingBool�sr�z<>!=)rrrrr'�test�rlg���Arbz encoded bool is not one byte: %r)�msgz2Expected OSError: struct.pack(%r, ExplodingBool()))rd������z>?)r�rxrer)r*r8r(ZassertFalserfr6r�r�)r,r�rBZfalse�trueZfalseFormatZpackedFalseZ
unpackedFalseZ
trueFormatZ
packedTrueZunpackedTruerAr�r?rrr�	test_bool�s>��zStructTest.test_boolcCsPd�tjd�}|�tjtj|�d�tjdtjd�}|�tjtj|�dS)Nz{}br'z{}b{}Hr3)rCr�r�r4r)r5r6)r,Z	hugecountZ
hugecount2rrr�test_count_overflow	szStructTest.test_count_overflowcCst�dd�}|�tjtjd�|�tjtjdd�|�tjtjd|d�|�tjtjd|d�|�tjtjdd�|�tjtjdd�|�tjtjd|dd�|�tjtjd|d�|�tjtjd	d
�|�tjtjd	d�|�tjtjd	|dd
�|�tjtjd	|d�dS)Nrr�Z12345rKrZc12345r��xZ14s42z
spam and eggss
spam and eggs)r�r4r)r5r*r8r�r�)r,�storerrr�test_trailing_counters*����z StructTest.test_trailing_countercCst�d�}|�d�dS)Nr	r2)r)r�rt�r,r rrr�test_Struct_reinitialization)s
z'StructTest.test_Struct_reinitializationcCs8t�d�}|t�d�|d7}t�|t�|�|�dS)NZ2n3PZP3n0Pr')rZcalcobjsizer)r6�check_sizeofr�)r,Z
format_strZnumber_of_codesZ	totalsizerrrr�0s
zStructTest.check_sizeofcCs�tD]}|�|d�q|�dd�|�dd�|�dd�|�dd	�|�d
d�|�dd�|�dd�|�d
d�|�dd	�dS)Nr'Z	BHILfdspP�	A�BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB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least 6 bytes for packing 1 bytes at offset 5 \(actual buffer size is 1\)rr'r�zounpack_from requires a buffer of at least 6 bytes for unpacking 1 bytes at offset 5 \(actual buffer size is 1\))�assertRaisesRegexr)r5r�r�r��r,Zregex1Zregex2rrr�test_boundary_error_messageEs��z&StructTest.test_boundary_error_messagec	Cs�td�}|�tjd��t�d|dd�W5QRX|�tjd��t�d|dd�W5QRX|�tjd	��t�d|d�W5QRX|�tjd��t�d|d�W5QRXdS)
Nr�z%no space to pack 4 bytes at offset -2�<I����{z*offset -11 out of range for 10-byte bufferz<Bi����z.not enough data to unpack 4 bytes at offset -2)r�r�r)r5r�r�)r,Z	byte_listrrr�0test_boundary_error_message_with_negative_offsetVs*����z;StructTest.test_boundary_error_message_with_negative_offsetc	Cs�dttjd�dttj�d}|�tj|��t�dtd�tjd�W5QRXdttjd�d	ttj�d}|�tj|��t�dtd�tj�W5QRXdS)
Nz(pack_into requires a buffer of at least rkz% bytes for packing 4 bytes at offset z \(actual buffer size is 10\)r�r�r'z*unpack_from requires a buffer of at least z' bytes for unpacking 4 bytes at offset )	r�r�r�r�r)r5r�r�r�r�rrr�-test_boundary_error_message_with_large_offsetls(���� ����z8StructTest.test_boundary_error_message_with_large_offsetc	Cs:|�t��t�dd�W5QRX|�t�dd�d�dS)Nrrr;)�a)r4r7r)r8r(r+rrr�test_issue29802~szStructTest.test_issue29802cCs<t�d�}|�|jd�t�|j���}|�|j|j�dS)Nz=i2H)r)r�r(rCr�)r,r �s2rrr�test_format_attr�s
zStructTest.test_format_attrc
Cs2dD](}|�tjd��t�|�W5QRXqdS)N)�z2irczembedded null character)r�r)r5r6r�rrr�test_issue35714�s
�zStructTest.test_issue35714N)r�r�r�r-r:rFrjrqr�r�r�r�r�r�r�r�r�r�r�r�r�r�rZcpython_onlyr�r�r�r�r�r�r�rrrrr& s85"
!+

	r&c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�UnpackIteratorTestzD
    Tests for iterative unpacking (struct.Struct.iter_unpack).
    c	s��fdd�}t�d�}|�d�}||�|�d�}||���tj��|�d�W5QRX��tj��|�d�W5QRXt�d�}��tj��|�d�W5QRX��tj��|�d	�W5QRXdS)
Ncs ��|tj���|tj�dSr")ZassertIsInstancer�Iterator�Iterable)�itr+rr�_check_iterator�sz:UnpackIteratorTest.test_construct.<locals>._check_iteratorz>ibcprKs1234567s123456s12345678rs12)r)r��iter_unpackr4r5)r,rr rrr+r�test_construct�s



z!UnpackIteratorTest.test_constructcCsrt�d�}ttdd��}|�|�}|�t|�d�|�t|�d�|�t|�d�|�tt|�|�tt|�dS)N�>IBr'��ir��i	r�)i
�)	r)r�r�r�rr(�nextr4�
StopIteration�r,r rrrrr�test_iterate�s

zUnpackIteratorTest.test_iteratecCsft�d�}ttdd��}|�t|��}|�t|�d�|�t|�d�|�t	t|�|�t	t|�dS�Nrr'�r	r
)
r)r�r�r�rr�r(rr4r
rrrr�test_arbitrary_buffer�s
z(UnpackIteratorTest.test_arbitrary_buffercCs�tj}t�d�}ttdd��}|�|�}|�||�d�t|�|�||�d�t|�|�||�d�t|�|�||�d�|�	t
t|�|�||�d�dS)Nrr'rr/r3r)�operator�length_hintr)r�r�r�rr(rr4r
)r,Zlhr rrrrr�test_length_hint�s

z#UnpackIteratorTest.test_length_hintcCsVt�dttdd���}|�t|�d�|�t|�d�|�tt|�|�tt|�dSr)r)rr�r�r(rr4r
)r,rrrr�test_module_func�s
z#UnpackIteratorTest.test_module_funccCsfddddddddtd	�fd
td�fdg
}|D]�\}}|ddd
�}|�|t�d|�d�|�|t�d|��|�|t�d|�d�|�|t�d|��tjdkr�|�|t�d|�d�|�|t�d|��q,|�|t�d|�d�|�|t�d|��q,ddddddg}|D]L\}}|�t�	t�d|�d��|�t�	t�d|ddd
��d���qt�dtj
�}|�|dd@d�t�dtj
�}|�|dd@d�dddddd d!d"d#d$d%d&d'd(d)d*d+d,d-g}	|	D] \}}}|�|t�||���q�d.d/d0d1d2d3d4d5d6d7d8d9g}
|
D]\}}|�ttj||��qd:g}|D] \}}}|�|t�||���q@dS);N)s<r�)s�ra)s�{g��@)s�?)sgp>)�g)s�g�s|z+infs�z-inf)sU5gT�?r�<er�>e�little�e)rs�)rs�)rs��)rs|)rs~)rs�r'�~)rsg`>)rrg`>)rrgP>)r��g�?)rrg������?)r�g�?)rrr)rs<g�?)r�<g�?)rr g�?)r�{�i�)rr!i�)rs�g`�)r��g`�)rr"gP�)rs�g�)r��g�)rr#g�)rs��i��)r���@)r��@)r�u�<�7~)r���)r��)r�u�<�7�)rr$)rr%)rr&)rr')rr()rr))rsg�g�����@)
�floatr(r)r8r*r�rrfr��isnan�nanr4r�)r,Z&format_bits_float__cleanRoundtrip_listZle_bitsr@Zbe_bitsZformat_bits__nan_listZ
formatcode�bitsr�Z format_bits_float__rounding_listZ%format_bits_float__roundingError_listZ+format_bits_float__doubleRoundingError_listrrr�test_half_float�s�

�

�	*���z"UnpackIteratorTest.test_half_floatN)
r�r�r��__doc__rrrrrr.rrrrr�s
	r�__main__)�collectionsrr�r�rr�r)r�r�rrr#rrrr!r%r�r&rr��mainrrrr�<module>s,
{.

F1le Man4ger