U _4S@sddlZddlZddlmZddlmZmZdddddd d d d d eejejfde fdde fde fde fde fde fgZ Gddde Z Gdddej ZedkredS)N)support)VALID_UNDERSCORE_LITERALSINVALID_UNDERSCORE_LITERALS)0r)1)9 )10 )Z99c)100d)Z314:)z 314r)z314 r)z 314 rz 1x)z 1 rz 1   uȀc@s eZdZdS) IntSubclassN__name__ __module__ __qualname__rr%/usr/lib64/python3.8/test/test_int.pyrsrc@seZdZddZddZejddZddZd d Z d d Z d dZ ddZ ddZ ddZddZddZddZddZddZdd Zd!d"Zd#S)$ IntTestCasesc CsH |tdd|tdd|tdd|tdd|tdd|tdd|td d|td d|td d|td d|td ddtD]n\}}dD]`}dD]V}|||}|}|dkr|tk r| }z|t||Wqtk rYqXqqqtdtj}t|}||dtj ||t|t|ddtjdtd}||ttd}||tdtj}||d?|dtd}||t|t tdd|tddd|tddd|ttdd|ttdd|ttdd |ttdd|ttd!d|ttd!d|td"dd#|td$dd#|td%d&d#|td'd(d#|td)d*d#|td+d,d#|td-d d#|td.d/d#|td0d1d#|td2d3d#|td4dd#|td5d6d#|td7d8d#|td9d:d#|td;dd#|tdd?d#|td@dAd#|tdBdCd#|tdDdEd#|tdFdGd#|tdHdId#|tdJdKd#|tdLdMd#|tdNdOd#|tdPdQd#|tdRdSd#|tdTdUd#|tdVdWd#|tdXdYd#|tdZd[d#|td\d]d#|td^d_d#|td`dad#|tdbdcd#|tdddd|tdddd|tdedd|tddd|tddd|tdfdd&|tdgdd|tdhdd|tdidd&|tdjdk|tdjd1dk|tddd|tdd d|tdfdd&|tdldd|tdmd d|tdndd&|ttdod|ttdpd|ttdqd|ttdrd|ttdsd |ttdtd |ttdud |ttdvd |ttdwd|ttdxd|ttdyd|ttdzd|td{dd||td}dd||td~d&d||tdd(d||tdd*d||tdd,d||tdd d||tdd/d||tdd1d||tdd3d||tddd||tdd6d||tdd8d||tdd:d||tddd||tdd=d||tdd?d||tddAd||tddCd||tddEd||tddGd||tddId||tddKd||tddMd||tddOd||tddQd||tddSd||tddUd||tddWd||tddYd||tdd[d||tdd]d||tdd_d||tddad||tddcd|dS)NrgQ @gQ g333333@g333333g @g z-3z -3 u -3 r )r+-)rr rrrg}Ô%ITg}Ô%IAX111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 Z0o123rSZ0x123i#0xZ0oZ0bZ!100000000000000000000000000000000lZ102002022201221111211Z10000000000000000Z32244002423141Z 1550104015504Z 211301422354Z 40000000000Z 12068657454r Z 4294967296r Z 1904440554 Z 9ba461594Z 535a79889 Z 2ca5b7464Z 1a20dcd81Z 100000000Za7ffda91Z704he7g4Z4f5aff66Z3723ai4gZ281d55i4Z1fj8b184Z1606k7icZmb994agZhek2mglZdnchbnmZb28jpdmZ8pfgih4Z76beiggZ5qmcpqgZ4q0jto4Z4000000 Z3aokq94!Z2qhxjli"Z2br45qb#Z1z141z4$z 0o123 Z000Z0b100z 0O123 z 0X123 z 0B100 Z0123{Z0X123Z0O123Z0B100Z0b2Z0b02Z0B2Z0B02Z0o8Z0o08Z0O8Z0O08Z0xgZ0x0gZ0XgZ0X0gZ!100000000000000000000000000000001lZ102002022201221111212Z10000000000000001Z32244002423142Z 1550104015505Z 211301422355Z 40000000001Z 12068657455Z 4294967297Z 1904440555Z 9ba461595Z 535a7988aZ 2ca5b7465Z 1a20dcd82Z 100000001Za7ffda92Z704he7g5Z4f5aff67Z3723ai4hZ281d55i5Z1fj8b185Z1606k7idZmb994ahZhek2mgmZdnchbnnZb28jpdnZ8pfgih5Z76beighZ5qmcpqhZ4q0jto5Z4000001Z3aokq95Z2qhxjljZ2br45qcZ1z141z5) assertEqualintL ValueErrorreprsysmaxsizeZassertIsInstance assertRaises TypeError)selfsvsignprefixssZvvxrrr test_basic"s        zIntTestCases.test_basicc stD]RtfdddDr q|tdt|tdtdddqtD],tfdddDrxq\|ttdq\|tdd d |td d |td d |ttd|ttd|ttd|ttddS)Nc3s|]}|kVqdSNr.0ZchZlitrr sz0IntTestCases.test_underscores..z.eEjJr_rc3s|]}|kVqdSrUrrVrXrrrYsZ1_00rr Z0_100rs1_00Z_100z+_100Z1__00Z100_) ranyrDrEevalreplacerrKrGrMrrXrtest_underscoress "zIntTestCases.test_underscorescCsD|tdd|tdd|tdd|tdddS)Nr r z-1r!s10s-1)assertIsrEr^rrrtest_small_intsszIntTestCases.test_small_intscCs|tddS)NrrDrEr^rrr test_no_argsszIntTestCases.test_no_argsc Cs~|tdddd|tdtddW5QRX|tdtdddW5QRX|jttd d|jttd ddS) Nr r"baser'zkeyword argumentg333333?)rS)rSrer r)rDrEassertRaisesRegexrLrKr^rrrtest_keyword_argsszIntTestCases.test_keyword_argsc Cs|tddd|ttddW5QRX|ttddW5QRX|ttddW5QRX|ttddddd W5QRX|ttdddd W5QRXtddD]}|td|d dqd S) z9Testing the supported limits of the int() base parameter.rr(rr%isr"rdN)rDrErKrGrange)rMrerrrtest_int_base_limitss     z!IntTestCases.test_int_base_limitsc CsD|ttddW5QRX|ttddW5QRXdS)z2Not integer types are not valid bases; issue16772.rg@g@N)rKrLrEr^rrrtest_int_base_bad_typess  z$IntTestCases.test_int_base_bad_typesc CsGdddt}dddd ddfD]$}|ttd|W5QRXq&|td|dd d |td|d d d |td|d d ddS)Nc@seZdZddZddZdS)z9IntTestCases.test_int_base_indexable..MyIndexablecSs ||_dSrUvalue)rMrnrrr__init__szBIntTestCases.test_int_base_indexable..MyIndexable.__init__cSs|jSrUrmr^rrr __index__szCIntTestCases.test_int_base_indexable..MyIndexable.__index__N)rrrrorprrrr MyIndexablesrqr"rrrhZ43Z101rdr(r erBi)objectrKrGrErD)rMrqrerrrtest_int_base_indexables z$IntTestCases.test_int_base_indexablec s.GdddtGdddt}Gdddt}ttfdd||tg}zd d lmWntk rlYnX|fd d|D]}|d }|t|| t |d t |tttfr| t |ddn&d}| t |t |dW5QRX| tdt |dW5QRXW5QRXqdS)Nc@s eZdZdS)z.CustomStrNrrrrr CustomStr-sruc@s eZdZdS)z>IntTestCases.test_non_numeric_input_types..CustomBytesNrrrrr CustomBytes.srvc@s eZdZdS)zBIntTestCases.test_non_numeric_input_types..CustomByteArrayNrrrrrCustomByteArray/srwcs |SrU)decodeb)rurr4z;IntTestCases.test_non_numeric_input_types..rarraycs d|S)NBrryr}rrr{>r|s100rr"r'zcan't convert non-stringzinvalid literalsAAAAAAAAAAAAAAAA)strbytes bytearray memoryviewr~ ImportErrorappendZsubTesttyperDrE isinstancerfrLrG)rMrvrwZ factoriesfrSmsgr)rur~rtest_non_numeric_input_types*s4 z)IntTestCases.test_non_numeric_input_typescCs|ttdddd|ttdddd|ttdddd|ttdddd|ttdddddS) Ns123rrr5123s123 s123As1234)rDrErr^rrrtest_int_memoryviewMs z IntTestCases.test_int_memoryviewcCs|ttddS)Nz1.2)rKrGrEr^rrrtest_string_floatTszIntTestCases.test_string_floatc s4Gddd}|tt|Gdddt}|tt|Gddd}|t|dGdd d }t|fD]}Gd d d |}|t|dGd d d |}|t|dGddd|}|tt|W5QRXt|fD]4} Gddd| Gfddd|} |t| dGddd| Gfddd|} |t| dGfddd| Gfddd|} zt| Wn4tk r} z|t| dW5d} ~ XYnX|d|| ffGddd| Gfd d!d!|}|tt|W5QRXqqtdS)"Nc@s eZdZdS)z>IntTestCases.test_intconversion..ClassicMissingMethodsNrrrrrClassicMissingMethodsYsrc@s eZdZdS)z7IntTestCases.test_intconversion..MissingMethodsNrrrrrMissingMethods]src@seZdZddZdS)z-IntTestCases.test_intconversion..Foo0cSsdSN*rr^rrr__int__bsz5IntTestCases.test_intconversion..Foo0.__int__NrrrrrrrrFoo0asrrc@s eZdZdS)z0IntTestCases.test_intconversion..ClassicNrrrrrClassicgsrc@seZdZddZddZdS)z:IntTestCases.test_intconversion..IntOverridesTrunccSsdSrrr^rrrrkszBIntTestCases.test_intconversion..IntOverridesTrunc.__int__cSsdS)Nirr^rrr __trunc__mszDIntTestCases.test_intconversion..IntOverridesTrunc.__trunc__N)rrrrrrrrrIntOverridesTruncjsrc@seZdZddZdS)z2IntTestCases.test_intconversion..JustTrunccSsdSrrr^rrrrrsz.JustTrunc.__trunc__Nrrrrrrrr JustTruncqsrc@seZdZddZdS)z9IntTestCases.test_intconversion..ExceptionalTrunccSs dddS)Nrrrr^rrrrwszCIntTestCases.test_intconversion..ExceptionalTrunc.__trunc__NrrrrrExceptionalTruncvsrc@seZdZddZdS)z.IntTestCases.test_intconversion..IndexcSsdSrrr^rrrrp~sz8IntTestCases.test_intconversion..Index.__index__NrrrrprrrrIndex}srcseZdZfddZdS)z;IntTestCases.test_intconversion..TruncReturnsNonIntcsSrUrr^rrrrszEIntTestCases.test_intconversion..TruncReturnsNonInt.__trunc__NrrrrrTruncReturnsNonIntsrc@seZdZddZdS)z0IntTestCases.test_intconversion..IntablecSsdSrrr^rrrrsz8IntTestCases.test_intconversion..Intable.__int__NrrrrrIntablesrcseZdZfddZdS)z=IntTestCases.test_intconversion..TruncReturnsNonIndexcsSrUrr^rrrrszGIntTestCases.test_intconversion..TruncReturnsNonIndex.__trunc__NrrrrrTruncReturnsNonIndexsrcseZdZfddZdS)z4IntTestCases.test_intconversion..NonIntegralcsSrUrr^ NonIntegralrrrsz>IntTestCases.test_intconversion..NonIntegral.__trunc__NrrrrrrsrcseZdZfddZdS)z@IntTestCases.test_intconversion..TruncReturnsNonIntegralcsSrUrr^rrrrszJIntTestCases.test_intconversion..TruncReturnsNonIntegral.__trunc__NrrrrrTruncReturnsNonIntegralsrz2__trunc__ returned non-Integral (type NonIntegral)z!Failed to raise TypeError with %sc@seZdZddZdS)z/IntTestCases.test_intconversion..BadIntcSsdSNgE@rr^rrrrsz7IntTestCases.test_intconversion..BadInt.__int__NrrrrrBadIntsrcseZdZfddZdS)z;IntTestCases.test_intconversion..TruncReturnsBadIntcsSrUrr^rrrrszEIntTestCases.test_intconversion..TruncReturnsBadInt.__trunc__NrrrrrTruncReturnsBadIntsr)rKrLrErsrDZeroDivisionErrorrZfail)rMrrrrrerrrZtrunc_result_baserrrerr)rrrrrtest_intconversionWsJ   zIntTestCases.test_intconversioncCsZGdddt}Gdddt}|d}||d|t|d|t|ddS)Nc@seZdZddZdS)z:IntTestCases.test_int_subclass_with_index..MyIndexcSsdSrrr^rrrrpszDIntTestCases.test_int_subclass_with_index..MyIndex.__index__NrrrrrMyIndexsrc@seZdZddZdS)z;IntTestCases.test_int_subclass_with_index..BadIndexcSsdSrrr^rrrrpszEIntTestCases.test_int_subclass_with_index..BadIndex.__index__NrrrrrBadIndexsrr*r)rErD)rMrrmy_intrrrtest_int_subclass_with_indexs  z)IntTestCases.test_int_subclass_with_indexcCsjGdddt}Gdddt}|d}||d|t|d|d}||d|tt|dS)Nc@seZdZddZdS)z6IntTestCases.test_int_subclass_with_int..MyIntcSsdSrrr^rrrrsz>IntTestCases.test_int_subclass_with_int..MyInt.__int__NrrrrrMyIntsrc@seZdZddZdS)z7IntTestCases.test_int_subclass_with_int..BadIntcSsdSrrr^rrrrsz?IntTestCases.test_int_subclass_with_int..BadInt.__int__Nrrrrrrsrr*r)rErDrKrL)rMrrrrrrtest_int_subclass_with_ints  z'IntTestCases.test_int_subclass_with_intc s*GdddGdddt}GdddGdddt}Gfd d d }Gfd d d }Gd dd}}|tt|}W5QRX||d|t|t|}t|}||d|t|t}|tt|}W5QRX||d|t|t|}|tt|}W5QRX||d|t|t|}|tt|}W5QRX||d|t|t|}|tt|}W5QRX||d|t|t|}t|}||d|t|tt|}||d|t|tdS)Nc@seZdZddZdS)z.BadIndexcSsdSNTrr^rrrrpszFIntTestCases.test_int_returns_int_subclass..BadIndex.__index__Nrrrrrrsrc@seZdZddZdS)z=IntTestCases.test_int_returns_int_subclass..BadIndex2cSsdSrrr^rrrrpszGIntTestCases.test_int_returns_int_subclass..BadIndex2.__index__Nrrrrr BadIndex2src@seZdZddZdS)z:IntTestCases.test_int_returns_int_subclass..BadIntcSsdSrrr^rrrrszBIntTestCases.test_int_returns_int_subclass..BadInt.__int__Nrrrrrrsrc@seZdZddZdS)z;IntTestCases.test_int_returns_int_subclass..BadInt2cSsdSrrr^rrrrszCIntTestCases.test_int_returns_int_subclass..BadInt2.__int__NrrrrrBadInt2srcseZdZfddZdS)zHIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIndexcsSrUrr^rrrrszRIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIndex.__trunc__NrrrrrTruncReturnsBadIndexsrcseZdZfddZdS)zFIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIntcsSrUrr^rrrrszPIntTestCases.test_int_returns_int_subclass..TruncReturnsBadInt.__trunc__Nrrrrrrsrc@seZdZddZdS)zKIntTestCases.test_int_returns_int_subclass..TruncReturnsIntSubclasscSsdSrrr^rrrrszUIntTestCases.test_int_returns_int_subclass..TruncReturnsIntSubclass.__trunc__NrrrrrTruncReturnsIntSubclasssrrr)rEZ assertWarnsDeprecationWarningrDr`rr) rMrrrrrZbad_intnZgood_intr)rrrtest_int_returns_int_subclasssV             z*IntTestCases.test_int_returns_int_subclasscsdfdd }|d|d|d|d|dd|dd |dd |d d |d d |d |d d|d |d d|d|dddS)Nc sjjtd||fd"}|dkr*t|n t||W5QRX|jjdd|dkrZdn||fdS)Nz int(%r, %r))rrz*invalid literal for int() with base %d: %rr )rKrGrErD exceptionargs)rNrecmr^rrchecks  z.IntTestCases.test_error_message..check½u123½z 123 456 z123r z123 245r2rz123245rs123u123)Nr)rMrrr^rtest_error_messages         zIntTestCases.test_error_messagecCsL|tddd|tddd|tddd |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&iSpSZ1_2_3_4_5_6_7_8_9rlgFZ 1_2_3_4_5_6_7r>i2Drbr^rrrtest_issue316196s  zIntTestCases.test_issue31619N)rrrrTr_rZ cpython_onlyrarcrgrkrlrtrrrrrrrrrrrrrr s&8  #VH!r__main__)rIZunittesttestrZtest.test_grammarrrrHrJrGrFrErZTestCaserrmainrrrrs< "