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_int.cpython-38.pyc
U

>��g�q�@s�ddlZddlZddlZddlmZddlmZmZdddddd	d
ddd
eej	�ej	fde
fdde
fde
fde
fde
fde
fgZGdd�de�Z
Gdd�dej�ZGdd�dej�ZGdd�de�Zedkr�e��dS)�N)�support)�VALID_UNDERSCORE_LITERALS�INVALID_UNDERSCORE_LITERALS)�0r)�1�)�9�	)�10�
)Z99�c)�100�d)Z314�:)z 314r)z314 r)z  		  314  		  rz  1x)z  1  rz  1  �� �  		  uȀc@seZdZdS)�IntSubclassN��__name__�
__module__�__qualname__�rr�,/opt/cppython/lib/python3.8/test/test_int.pyrsrc@s�eZdZdd�Zdd�Zejdd��Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�IntTestCasescCsH	|�td�d�|�td�d�|�td�d�|�td�d�|�td�d�|�td�d�|�td	�d�|�td
�d�|�td�d�|�td�d�|�td
d�d�tD]n\}}dD]`}dD]V}|||}|}|dkr�|tk	r�|}z|�t|�|�Wq�tk
�rYq�Xq�q�q�tdtj�}t|�}|�|dtj�|�|t�|�t|dd��tjd�td�}|�|t�td�}|�|t�dtj}|�|d?|d�td�}|�|t�|�t	tdd�|�tdd�d�|�tdd�d�|�ttdd�|�ttdd�|�ttdd �|�ttdd�|�ttd!d�|�ttd!d�|�td"d�d#�|�td$d�d#�|�td%d&�d#�|�td'd(�d#�|�td)d*�d#�|�td+d,�d#�|�td-d �d#�|�td.d/�d#�|�td0d1�d#�|�td2d3�d#�|�td4d�d#�|�td5d6�d#�|�td7d8�d#�|�td9d:�d#�|�td;d�d#�|�td<d=�d#�|�td>d?�d#�|�td@dA�d#�|�tdBdC�d#�|�tdDdE�d#�|�tdFdG�d#�|�tdHdI�d#�|�tdJdK�d#�|�tdLdM�d#�|�tdNdO�d#�|�tdPdQ�d#�|�tdRdS�d#�|�tdTdU�d#�|�tdVdW�d#�|�tdXdY�d#�|�tdZd[�d#�|�td\d]�d#�|�td^d_�d#�|�td`da�d#�|�tdbdc�d#�|�tddd�d�|�tddd�d�|�tded�d�|�tdd�d�|�tdd�d�|�tdfd�d&�|�tdgd�d�|�tdhd�d�|�tdid�d&�|�tdj�dk�|�tdjd1�dk�|�tdd�d�|�tdd �d�|�tdfd�d&�|�tdld�d�|�tdmd �d�|�tdnd�d&�|�ttdod�|�ttdpd�|�ttdqd�|�ttdrd�|�ttdsd �|�ttdtd �|�ttdud �|�ttdvd �|�ttdwd�|�ttdxd�|�ttdyd�|�ttdzd�|�td{d�d|�|�td}d�d|�|�td~d&�d|�|�tdd(�d|�|�td�d*�d|�|�td�d,�d|�|�td�d �d|�|�td�d/�d|�|�td�d1�d|�|�td�d3�d|�|�td�d�d|�|�td�d6�d|�|�td�d8�d|�|�td�d:�d|�|�td�d�d|�|�td�d=�d|�|�td�d?�d|�|�td�dA�d|�|�td�dC�d|�|�td�dE�d|�|�td�dG�d|�|�td�dI�d|�|�td�dK�d|�|�td�dM�d|�|�td�dO�d|�|�td�dQ�d|�|�td�dS�d|�|�td�dU�d|�|�td�dW�d|�|�td�dY�d|�|�td�d[�d|�|�td�d]�d|�|�td�d_�d|�|�td�da�d|�|�td�dc�d|�dS)�Nrg��Q�	@�g��Q�	����g333333@g333333�g@g�z-3z -3 u -3 r
�)r�+�-)rr�	rr���rg}Ô%�I�Tg}Ô%�I���AX111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111�Z0o123r�SZ0x123i#�0xZ0o�Z0bZ!100000000000000000000000000000000lZ102002022201221111211Z10000000000000000�Z32244002423141�Z
1550104015504�Z211301422354�Z40000000000Z12068657454r	Z
4294967296rZ
1904440554�Z	9ba461594Z	535a79889�
Z	2ca5b7464�Z	1a20dcd81�Z	100000000Za7ffda91�Z704he7g4�Z4f5aff66�Z3723ai4g�Z281d55i4�Z1fj8b184�Z1606k7ic�Zmb994ag�Zhek2mgl�Zdnchbnm�Zb28jpdm�Z8pfgih4�Z76beigg�Z5qmcpqg�Z4q0jto4�Z4000000� Z3aokq94�!Z2qhxjli�"Z2br45qb�#Z1z141z4�$z 0o123  Z000Z0b100z	 0O123   z 0X123  z 0B100 Z0123�{Z0X123Z0O123Z0B100Z0b2Z0b02Z0B2Z0B02Z0o8Z0o08Z0O8Z0O08Z0xgZ0x0gZ0XgZ0X0gZ!100000000000000000000000000000001lZ102002022201221111212Z10000000000000001Z32244002423142Z
1550104015505Z211301422355Z40000000001Z12068657455Z
4294967297Z
1904440555Z	9ba461595Z	535a7988aZ	2ca5b7465Z	1a20dcd82Z	100000001Za7ffda92Z704he7g5Z4f5aff67Z3723ai4hZ281d55i5Z1fj8b185Z1606k7idZmb994ahZhek2mgmZdnchbnnZb28jpdnZ8pfgih5Z76beighZ5qmcpqhZ4q0jto5Z4000001Z3aokq95Z2qhxjljZ2br45qcZ1z141z5)
�assertEqual�int�L�
ValueError�repr�sys�maxsizeZassertIsInstance�assertRaises�	TypeError)�self�s�v�sign�prefix�ssZvv�xrrr�
test_basic#s
zIntTestCases.test_basicc	s�tD]R�t�fdd�dD��r q|�t�d�t���|�t�d�t��dd�d��qtD],�t�fdd�dD��rxq\|�tt�d�q\|�tdd	�d
�|�td�d�|�td
�d�|�ttd�|�ttd�|�ttd�|�ttd�dS)Nc3s|]}|�kVqdS�Nr��.0Zch�Zlitrr�	<genexpr>�sz0IntTestCases.test_underscores.<locals>.<genexpr>z.eEjJr�_rc3s|]}|�kVqdSrUrrVrXrrrY�sZ1_00rr	Z0_100rs1_00Z_100z+_100Z1__00Z100_)	r�anyrDrE�eval�replacerrKrG�rMrrXr�test_underscores�s "zIntTestCases.test_underscorescCsD|�td�d�|�td�d�|�td�d�|�td�d�dS)Nr
rz-1r!s10s-1)�assertIsrEr^rrr�test_small_ints�szIntTestCases.test_small_intscCs|�t�d�dS)Nr�rDrEr^rrr�test_no_args�szIntTestCases.test_no_argsc	Cs~|�tddd�d�|�td��tdd�W5QRX|�td��tddd�W5QRX|jttd	d�|jttd
d�dS)Nr
r"��baser'zkeyword argumentg333333�?)rS)rSrerr)rDrE�assertRaisesRegexrLrKr^rrr�test_keyword_args�szIntTestCases.test_keyword_argsc	Cs�|�tdd�d�|�t��tdd�W5QRX|�t��tdd�W5QRX|�t��tdd�W5QRX|�t��tddddd	�W5QRX|�t��tdddd	�W5QRXtdd�D]}|�td|d	�d�q�d
S)z9Testing the supported limits of the int() base parameter.rr(rr�%is���r"��rdN)rDrErKrG�range�rMrerrr�test_int_base_limitssz!IntTestCases.test_int_base_limitsc	CsD|�t��tdd�W5QRX|�t��tdd�W5QRXdS)z2Not integer types are not valid bases; issue16772.rg@g@N)rKrLrEr^rrr�test_int_base_bad_typessz$IntTestCases.test_int_base_bad_typesc
Cs�Gdd�dt�}ddddddfD]$}|�t��td|�W5QRXq&|�td|d�d	�d
�|�td|d�d	�d�|�td|d
�d	�d�dS)Nc@seZdZdd�Zdd�ZdS)z9IntTestCases.test_int_base_indexable.<locals>.MyIndexablecSs
||_dSrU��value)rMrorrr�__init__szBIntTestCases.test_int_base_indexable.<locals>.MyIndexable.__init__cSs|jSrUrnr^rrr�	__index__szCIntTestCases.test_int_base_indexable.<locals>.MyIndexable.__index__N)rrrrprqrrrr�MyIndexablesrrr"rrrhZ43Z101rdr(r�erBi)�objectrKrGrErD)rMrrrerrr�test_int_base_indexablesz$IntTestCases.test_int_base_indexablecs.Gdd�dt��Gdd�dt�}Gdd�dt�}tt�fdd�||tg}zd	d
lm�Wntk
rlYnX|��fdd��|D]�}|d�}|�t|����|�	t
|�d
�t|tttf�r�|�	t
|d�d�n&d}|�t
|��t
|d�W5QRX|�td��t
|d��W5QRXW5QRXq�dS)Nc@seZdZdS)z<IntTestCases.test_non_numeric_input_types.<locals>.CustomStrNrrrrr�	CustomStr.srvc@seZdZdS)z>IntTestCases.test_non_numeric_input_types.<locals>.CustomBytesNrrrrr�CustomBytes/srwc@seZdZdS)zBIntTestCases.test_non_numeric_input_types.<locals>.CustomByteArrayNrrrrr�CustomByteArray0srxcs�|���SrU)�decode��b)rvrr�<lambda>5�z;IntTestCases.test_non_numeric_input_types.<locals>.<lambda>r��arraycs
�d|�S)N�Brrzr~rrr|?r}s100rr"r'zcan't convert non-stringzinvalid literalsAAAAAAAAAAAAAAAA)�str�bytes�	bytearray�
memoryviewr�ImportError�append�subTest�typerDrE�
isinstancerfrLrG)rMrwrxZ	factories�frS�msgr)rvrr�test_non_numeric_input_types+s4
�z)IntTestCases.test_non_numeric_input_typescCs�|�ttd�dd��d�|�ttd�dd��d�|�ttd�dd��d�|�ttd�dd��d�|�ttd�dd��d�dS)	Ns123rrr5�123s123 s123As1234)rDrEr�r^rrr�test_int_memoryviewNs
z IntTestCases.test_int_memoryviewcCs|�ttd�dS)Nz1.2)rKrGrEr^rrr�test_string_floatUszIntTestCases.test_string_floatcs4Gdd�d�}|�tt|��Gdd�dt�}|�tt|��Gdd�d�}|�t|��d�Gdd	�d	�}t|fD�]�}Gd
d�d|�}|�t|��d�Gdd
�d
|�}|�t|��d�Gdd�d|�}|�t��t|��W5QRXt|fD�]4}	Gdd�d|	��G�fdd�d|�}
|�t|
��d�Gdd�d|	��G�fdd�d|�}|�t|
��d�G�fdd�d|	��G�fdd�d|�}zt|��Wn4tk
�r�}
z|�t|
�d�W5d}
~
XYnX|�d||	ff�Gdd�d|	��G�fd d!�d!|�}|�t��t|��W5QRXq�qtdS)"Nc@seZdZdS)z>IntTestCases.test_intconversion.<locals>.ClassicMissingMethodsNrrrrr�ClassicMissingMethodsZsr�c@seZdZdS)z7IntTestCases.test_intconversion.<locals>.MissingMethodsNrrrrr�MissingMethods^sr�c@seZdZdd�ZdS)z-IntTestCases.test_intconversion.<locals>.Foo0cSsdS�N�*rr^rrr�__int__csz5IntTestCases.test_intconversion.<locals>.Foo0.__int__N�rrrr�rrrr�Foo0bsr�r�c@seZdZdS)z0IntTestCases.test_intconversion.<locals>.ClassicNrrrrr�Classichsr�c@seZdZdd�Zdd�ZdS)z:IntTestCases.test_intconversion.<locals>.IntOverridesTrunccSsdSr�rr^rrrr�lszBIntTestCases.test_intconversion.<locals>.IntOverridesTrunc.__int__cSsdS)Ni�rr^rrr�	__trunc__nszDIntTestCases.test_intconversion.<locals>.IntOverridesTrunc.__trunc__N)rrrr�r�rrrr�IntOverridesTruncksr�c@seZdZdd�ZdS)z2IntTestCases.test_intconversion.<locals>.JustTrunccSsdSr�rr^rrrr�ssz<IntTestCases.test_intconversion.<locals>.JustTrunc.__trunc__N�rrrr�rrrr�	JustTruncrsr�c@seZdZdd�ZdS)z9IntTestCases.test_intconversion.<locals>.ExceptionalTrunccSsdddS)Nrrrr^rrrr�xszCIntTestCases.test_intconversion.<locals>.ExceptionalTrunc.__trunc__Nr�rrrr�ExceptionalTruncwsr�c@seZdZdd�ZdS)z.IntTestCases.test_intconversion.<locals>.IndexcSsdSr�rr^rrrrqsz8IntTestCases.test_intconversion.<locals>.Index.__index__N�rrrrqrrrr�Index~sr�cseZdZ�fdd�ZdS)z;IntTestCases.test_intconversion.<locals>.TruncReturnsNonIntcs��SrUrr^�r�rrr��szEIntTestCases.test_intconversion.<locals>.TruncReturnsNonInt.__trunc__Nr�rr�rr�TruncReturnsNonInt�sr�c@seZdZdd�ZdS)z0IntTestCases.test_intconversion.<locals>.IntablecSsdSr�rr^rrrr��sz8IntTestCases.test_intconversion.<locals>.Intable.__int__Nr�rrrr�Intable�sr�cseZdZ�fdd�ZdS)z=IntTestCases.test_intconversion.<locals>.TruncReturnsNonIndexcs��SrUrr^�r�rrr��szGIntTestCases.test_intconversion.<locals>.TruncReturnsNonIndex.__trunc__Nr�rr�rr�TruncReturnsNonIndex�sr�cseZdZ�fdd�ZdS)z4IntTestCases.test_intconversion.<locals>.NonIntegralcs��SrUrr^��NonIntegralrrr��sz>IntTestCases.test_intconversion.<locals>.NonIntegral.__trunc__Nr�rr�rrr��sr�cseZdZ�fdd�ZdS)z@IntTestCases.test_intconversion.<locals>.TruncReturnsNonIntegralcs��SrUrr^r�rrr��szJIntTestCases.test_intconversion.<locals>.TruncReturnsNonIntegral.__trunc__Nr�rr�rr�TruncReturnsNonIntegral�sr�z2__trunc__ returned non-Integral (type NonIntegral)z!Failed to raise TypeError with %sc@seZdZdd�ZdS)z/IntTestCases.test_intconversion.<locals>.BadIntcSsdS�NgE@rr^rrrr��sz7IntTestCases.test_intconversion.<locals>.BadInt.__int__Nr�rrrr�BadInt�sr�cseZdZ�fdd�ZdS)z;IntTestCases.test_intconversion.<locals>.TruncReturnsBadIntcs��SrUrr^�r�rrr��szEIntTestCases.test_intconversion.<locals>.TruncReturnsBadInt.__trunc__Nr�rr�rr�TruncReturnsBadInt�sr�)rKrLrErtrD�ZeroDivisionErrorr�Zfail)rMr�r�r�r�rer�r�r�Ztrunc_result_baser�r�r��er�r)r�r�r�r�r�test_intconversionXsJ
��zIntTestCases.test_intconversioncCsZGdd�dt�}Gdd�dt�}|d�}|�|d�|�t|�d�|�t|��d�dS)Nc@seZdZdd�ZdS)z:IntTestCases.test_int_subclass_with_index.<locals>.MyIndexcSsdSr�rr^rrrrq�szDIntTestCases.test_int_subclass_with_index.<locals>.MyIndex.__index__Nr�rrrr�MyIndex�sr�c@seZdZdd�ZdS)z;IntTestCases.test_int_subclass_with_index.<locals>.BadIndexcSsdSr�rr^rrrrq�szEIntTestCases.test_int_subclass_with_index.<locals>.BadIndex.__index__Nr�rrrr�BadIndex�sr�r*r)rErD)rMr�r��my_intrrr�test_int_subclass_with_index�sz)IntTestCases.test_int_subclass_with_indexcCsjGdd�dt�}Gdd�dt�}|d�}|�|d�|�t|�d�|d�}|�|d�|�tt|�dS)Nc@seZdZdd�ZdS)z6IntTestCases.test_int_subclass_with_int.<locals>.MyIntcSsdSr�rr^rrrr��sz>IntTestCases.test_int_subclass_with_int.<locals>.MyInt.__int__Nr�rrrr�MyInt�sr�c@seZdZdd�ZdS)z7IntTestCases.test_int_subclass_with_int.<locals>.BadIntcSsdSr�rr^rrrr��sz?IntTestCases.test_int_subclass_with_int.<locals>.BadInt.__int__Nr�rrrrr��sr�r*r�)rErDrKrL)rMr�r�r�rrr�test_int_subclass_with_int�sz'IntTestCases.test_int_subclass_with_intc		s*Gdd�d��Gdd�dt�}Gdd�d��Gdd�dt�}G�fd	d
�d
�}G�fdd�d�}Gd
d�d�}��}|�t��t|�}W5QRX|�|d�|�t|�t�|�}t|�}|�|d�|�t|�t���}|�t��t|�}W5QRX|�|d�|�t|�t�|�}|�t��t|�}W5QRX|�|d�|�t|�t�|�}|�t��t|�}W5QRX|�|d�|�t|�t�|�}|�t��t|�}W5QRX|�|d�|�t|�t�|�}t|�}|�|d�|�t|�t�t|�}|�|d�|�t|�t�dS)Nc@seZdZdd�ZdS)z<IntTestCases.test_int_returns_int_subclass.<locals>.BadIndexcSsdS�NTrr^rrrrq�szFIntTestCases.test_int_returns_int_subclass.<locals>.BadIndex.__index__Nr�rrrrr��sr�c@seZdZdd�ZdS)z=IntTestCases.test_int_returns_int_subclass.<locals>.BadIndex2cSsdSr�rr^rrrrq�szGIntTestCases.test_int_returns_int_subclass.<locals>.BadIndex2.__index__Nr�rrrr�	BadIndex2�sr�c@seZdZdd�ZdS)z:IntTestCases.test_int_returns_int_subclass.<locals>.BadIntcSsdSr�rr^rrrr��szBIntTestCases.test_int_returns_int_subclass.<locals>.BadInt.__int__Nr�rrrrr��sr�c@seZdZdd�ZdS)z;IntTestCases.test_int_returns_int_subclass.<locals>.BadInt2cSsdSr�rr^rrrr��szCIntTestCases.test_int_returns_int_subclass.<locals>.BadInt2.__int__Nr�rrrr�BadInt2�sr�cseZdZ�fdd�ZdS)zHIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIndexcs��SrUrr^�r�rrr��szRIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIndex.__trunc__Nr�rr�rr�TruncReturnsBadIndex�sr�cseZdZ�fdd�ZdS)zFIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIntcs��SrUrr^r�rrr��szPIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadInt.__trunc__Nr�rr�rrr��sr�c@seZdZdd�ZdS)zKIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsIntSubclasscSsdSr�rr^rrrr��szUIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsIntSubclass.__trunc__Nr�rrrr�TruncReturnsIntSubclass�sr�rr)rEZassertWarns�DeprecationWarningrDr`r�r)	rMr�r�r�r�r�Zbad_int�nZgood_intr)r�r�r�test_int_returns_int_subclass�sVz*IntTestCases.test_int_returns_int_subclasscs�d�fdd�	}|d�|d�|d�|d�|dd�|dd	�|dd
�|dd	�|dd
�|d�|dd�|d
�|d
d�|d�|dd�dS)Nc	sj�jtd||fd��"}|dkr*t|�n
t||�W5QRX��|jjdd|dkrZdn||f�dS)Nzint(%r, %r))r�rz*invalid literal for int() with base %d: %rr)rKrGrErD�	exception�args)rNre�cmr^rr�checks
�
��z.IntTestCases.test_error_message.<locals>.check�½u123½z  123 456  z123rz123 245r2rz123245r�s123�u123�)Nr)rMr�rr^r�test_error_messages 






zIntTestCases.test_error_messagecCsL|�tdd�d�|�tdd�d�|�tdd�d	�|�td
d�d�dS)
NZ=1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1r"iUUUUZ1_2_3_4_5_6_7_0_1_2_3r&iSp�SZ1_2_3_4_5_6_7_8_9rl�g�FZ
1_2_3_4_5_6_7r>i�2Drbr^rrr�test_issue316197s�zIntTestCases.test_issue31619N)rrrrTr_rZcpython_onlyrarcrgrlrmrur�r�r�r�r�r�r�r�r�rrrrr!s&8

#VH!rcs�eZdZeZ�fdd�Z�fdd�Zdd�Zdd�Zdd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�ZS)�IntStrDigitLimitsTestscs"t���t��|_t�d�dS)Ni)�super�setUprI�get_int_max_str_digits�_previous_limit�set_int_max_str_digitsr^��	__class__rrr�Cs

zIntStrDigitLimitsTests.setUpcst�|j�t���dSrU)rIr�r�r��tearDownr^r�rrr�HszIntStrDigitLimitsTests.tearDownc	Csp|�t��d�|�t��d�t�d��,|�t��d�|�dd�}t|�W5QRX|�t��d�dS)Nri Nr)	Z
assertGreaterrIr��
assertLessr�adjust_int_max_str_digitsrD�	int_classr�)rM�irrr�test_disabled_limitLsz*IntStrDigitLimitsTests.test_disabled_limitcCsz|j}t��}|d|�|dd|�|d|d�|dd|�|dd|�|�ttd|d��|�dS)z&Ignore the +/- sign and space padding.rrrrrrN)r�rIr�rD�lenr�)rMr��	maxdigitsrrr�test_max_str_digits_edge_casesUsz5IntStrDigitLimitsTests.test_max_str_digits_edge_casesNc	Cs:|�t��&|dkr |�|�n|�||�W5QRXdSrU)rKrGr�)rMr�rerrrr�aszIntStrDigitLimitsTests.checkc	Cs�t��}|�d|d�|�dd|d�|�d|dd�|�dd|d�|�dd|d�|�d|d�d|}|�t��t|�W5QRXdS)Nrrrrrr)rIr�r�rKrGr�)rMr�r�rrr�test_max_str_digitshsz*IntStrDigitLimitsTests.test_max_str_digitsc
Csxt��}|dkst|��tj}|�dkr.tj}tddd��dd�}d}t�|��|�}t	|�}W5QRX|�|}|�
t|�|�|d	kr�t�
d
|�d���t�td|���4|�t��}|�}t	|�W5QRX|�|}	W5QRX|�d
t	|j��|�|	|d�tddd��dd�}
|�t��}|�}t	|
�W5QRX|�|}|�d
t	|j��|�||d�dS)�?Regression test: ensure we fail before performing O(N**2) work.iP�rr%�ci�rrdi�1��?�"slow" conversion took only �	 seconds.gףp=
��?�
conversionr"i �N)rIr��AssertionError�time�process_time�	monotonicrErr�r�rDr��unittest�SkipTestrKrG�assertInr��assertLessEqualr�)rMr��get_timeZhuge_int�digits�startZhuge_decimal�seconds_to_convert�err�seconds_to_fail_hugeZextra_huge_int�seconds_to_fail_extra_hugerrr�+test_denial_of_service_prevented_int_to_strvs8


zBIntStrDigitLimitsTests.test_denial_of_service_prevented_int_to_strc
CsHt��}|dkst|��tj}|�dkr.tj}d}d|}t�|��|�}t|�W5QRX|�|}|dkr�t	�
d|�d���t�|d��4|�t��}|�}t|�W5QRX|�|}W5QRX|�
d	t|j��|�||d
�dd}	|�t��}|�}t|	�W5QRX|�|}
|�
d	t|j��|�|
|d
�d
S)r�順riD
�8r�r�r�rr�r"�7i�ON)rIr�r�r�r�r�rr�rEr�r�rKrGr�r�r�r�)rMr�r�r�Zhuger�r�r�r�Z
extra_huger�rrr�+test_denial_of_service_prevented_str_to_int�s6


zBIntStrDigitLimitsTests.test_denial_of_service_prevented_str_to_intc
Cs^t��}dD]L}|j|d��6|�d|d|�|dks>t�|�dd|�W5QRXqdS)z-The limit does not apply to power of 2 bases.)r"r'r&rr>rdrrr�N)rIr�r�r�r�)rMr�rerrr�!test_power_of_two_bases_unlimited�sz8IntStrDigitLimitsTests.test_power_of_two_bases_unlimitedcCsXt��}|d}d|}d|}|�|�|�|�|�|�d��|�|�d��dS)NrZ111Z1_11Z_111)rIr�r�r�)rMr�ZtriplesrNZs_rrr�test_underscores_ignored�s

z/IntStrDigitLimitsTests.test_underscores_ignoredcCsh|j}t��}d|}||�}|d|���}||ks8t�|d|���}||ksTt�t|�t|�dS)N�5rr)r�rIr�r�r�)rMr��
max_digitsrNr�Zpos_iZneg_irrr�test_sign_not_counted�sz,IntStrDigitLimitsTests.test_sign_not_countedc	Cs�|j}t��}d|}|||�}|dkrH|�t��t|�W5QRXn|dkrXt|�|�t��}||�d�|�W5QRXdS)N�2rr)r�rIr�rKrGr�)rMrer�r�rNr�r�rrr�_other_base_helper�s
z)IntStrDigitLimitsTests._other_base_helperc	CsPd}|j|d��|�|�W5QRXd}|j|d��|�|�W5QRXdS)NrrdrB)r�r�rkrrr�test_int_from_other_bases�sz0IntStrDigitLimitsTests.test_int_from_other_bases)N)rrrrEr�r�r�r�r�r�r�r�r�r�r�r�r�r��
__classcell__rrr�rr�?s	
+(

r�c@seZdZeZdS)�IntSubclassStrDigitLimitsTestsN)rrrrr�rrrrr�sr��__main__)rIr�r��testrZtest.test_grammarrrrHrJrGrFrErZTestCaserr�r�r�mainrrrr�<module>sD�"B

F1le Man4ger