U _4Sc@sddlZddlZddlmZddlmZmZdddddd d d d d eejejfde fdde fde fde fde fde fgZ Gddde Z Gdddej ZedkredS)N)support)VALID_UNDERSCORE_LITERALSINVALID_UNDERSCORE_LITERALS)0r)Z1)Z9 )10 )Z99ic)100d)Z314:)z 314r )z314 r )z 314 r z 1x)z 1 rz 1   uȀc@ eZdZdS) IntSubclassN__name__ __module__ __qualname__rr%/usr/lib64/python3.8/test/test_int.pyrrc@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)Nr gQ @gQ ig333333@g333333g @g z-3z -3 u -3 r)r z+-)r r z rrrg}Ô%ITg}Ô%IAX111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111i Z0o123riSZ0x123i#Z0xZ0oZ0bZ!100000000000000000000000000000000lZ102002022201221111211Z10000000000000000Z32244002423141Z 1550104015504iZ 211301422354Z 40000000000Z 12068657454rZ 4294967296rZ 1904440554i Z 9ba461594Z 535a79889i Z 2ca5b7464iZ 1a20dcd81iZ 100000000Za7ffda91iZ704he7g4iZ4f5aff66iZ3723ai4gZ281d55i4iZ1fj8b184iZ1606k7icZmb994agiZhek2mgliZdnchbnmiZb28jpdmiZ8pfgih4iZ76beiggiZ5qmcpqgiZ4q0jto4iZ4000000 Z3aokq94i!Z2qhxjlii"Z2br45qbi#Z1z141z4$z 0o123 Z000Z0b100z 0O123 z 0X123 z 0B100 Z0123i{Z0X123Z0O123Z0B100Z0b2Z0b02Z0B2Z0B02Z0o8Z0o08Z0O8Z0O08Z0xgZ0x0gZ0XgZ0X0gZ!100000000000000000000000000000001lZ102002022201221111212Z10000000000000001Z32244002423142Z 1550104015505Z 211301422355Z 40000000001Z 12068657455Z 4294967297Z 1904440555Z 9ba461595Z 535a7988aZ 2ca5b7465Z 1a20dcd82Z 100000001Za7ffda92Z704he7g5Z4f5aff67Z3723ai4hZ281d55i5Z1fj8b185Z1606k7idZmb994ahZhek2mgmZdnchbnnZb28jpdnZ8pfgih5Z76beighZ5qmcpqhZ4q0jto5Z4000001Z3aokq95Z2qhxjljZ2br45qcZ1z141z5) assertEqualintL ValueErrorreprsysmaxsizeZassertIsInstance assertRaises TypeError)selfsZvZsignZprefixZssZvvxrrr test_basic"s        zIntTestCases.test_basicc stD]RtfdddDr q|tdt|tdtdddqtD],tfdddDrxq\|ttdq\|tdd d |td d |td d |ttd|ttd|ttd|ttddS)Nc3|]}|kVqdSNrZ.0ZchZlitrr z0IntTestCases.test_underscores..z.eEjJrZ_r c3r3r4rr5r6rrr7r8Z1_00rrZ0_100r s1_00Z_100z+_100Z1__00Z100_) rZanyr&r'ZevalZreplacerr-r)r/rr6rtest_underscoress "zIntTestCases.test_underscorescCsD|tdd|tdd|tdd|tdddS)Nrrz-1rs10s-1)assertIsr'r9rrrtest_small_intsszIntTestCases.test_small_intscCs|tddS)Nrr&r'r9rrr test_no_argszIntTestCases.test_no_argsc Cs~|tdddd|tdtddW5QRX|tdtdddW5QRX|jttd d|jttd ddS) Nr rbaserzkeyword argumentg333333?)r1)r1rArr)r&r'assertRaisesRegexr.r-r9rrrtest_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%isrir@N)r&r'r-r)Zrange)r/rArrrtest_int_base_limitss     z!IntTestCases.test_int_base_limitsc CsD|ttddW5QRX|ttddW5QRXdS)z2Not integer types are not valid bases; issue16772.rg@g@N)r-r.r'r9rrrtest_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@eZdZddZddZdS)z9IntTestCases.test_int_base_indexable..MyIndexablecSs ||_dSr4value)r/rIrrr__init__r?zBIntTestCases.test_int_base_indexable..MyIndexable.__init__cSs|jSr4rHr9rrr __index__r?zCIntTestCases.test_int_base_indexable..MyIndexable.__index__N)rrrrJrKrrrr MyIndexablerLrr rrDZ43Z101r@r rier%i)objectr-r)r'r&)r/rLrArrrtest_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@r)z.CustomStrNrrrrr CustomStr-rPc@r)z>IntTestCases.test_non_numeric_input_types..CustomBytesNrrrrr CustomBytes.rQrRc@r)zBIntTestCases.test_non_numeric_input_types..CustomByteArrayNrrrrrCustomByteArray/rQrScs |Sr4)ZdecodeZb)rPrr4z;IntTestCases.test_non_numeric_input_types..rarraycs d|S)NZBrrTrWrrrU>rVs100r rrzcan't convert non-stringzinvalid literalsAAAAAAAAAAAAAAAA)strZbytesZ bytearray memoryviewrXZ ImportErrorZappendZsubTesttyper&r'Z isinstancerBr.r))r/rRrSZ factoriesZfr1msgr)rPrXrtest_non_numeric_input_types*s4 z)IntTestCases.test_non_numeric_input_typescCs|ttdddd|ttdddd|ttdddd|ttdddd|ttdddddS) Ns123rrr#123s123 s123As1234)r&r'rZr9rrrtest_int_memoryviewMs z IntTestCases.test_int_memoryviewcCs|ttddS)Nz1.2)r-r)r'r9rrrtest_string_floatTr?zIntTestCases.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@r)z>IntTestCases.test_intconversion..ClassicMissingMethodsNrrrrrClassicMissingMethodsYrrac@r)z7IntTestCases.test_intconversion..MissingMethodsNrrrrrMissingMethods]rrbc@eZdZddZdS)z-IntTestCases.test_intconversion..Foo0cSdSN*rr9rrr__int__br?z5IntTestCases.test_intconversion..Foo0.__int__NrrrrgrrrrFoo0arrirfc@r)z0IntTestCases.test_intconversion..ClassicNrrrrrClassicgrrjc@rG)z:IntTestCases.test_intconversion..IntOverridesTrunccSrdrerr9rrrrgkr?zBIntTestCases.test_intconversion..IntOverridesTrunc.__int__cSrd)Nirr9rrr __trunc__mr?zDIntTestCases.test_intconversion..IntOverridesTrunc.__trunc__N)rrrrgrkrrrrIntOverridesTruncjrMrlc@rc)z2IntTestCases.test_intconversion..JustTrunccSrdrerr9rrrrkrr?z.JustTrunc.__trunc__Nrrrrkrrrr JustTruncqrrnc@rc)z9IntTestCases.test_intconversion..ExceptionalTrunccSs dddS)Nrrrr9rrrrkwr?zCIntTestCases.test_intconversion..ExceptionalTrunc.__trunc__NrmrrrrExceptionalTruncvrroc@rc)z.IntTestCases.test_intconversion..IndexcSrdrerr9rrrrK~r?z8IntTestCases.test_intconversion..Index.__index__NrrrrKrrrrIndex}rrqceZdZfddZdS)z;IntTestCases.test_intconversion..TruncReturnsNonIntcSr4rr9rqrrrkr?zEIntTestCases.test_intconversion..TruncReturnsNonInt.__trunc__NrmrrtrrTruncReturnsNonIntrruc@rc)z0IntTestCases.test_intconversion..IntablecSrdrerr9rrrrgr?z8IntTestCases.test_intconversion..Intable.__int__NrhrrrrIntablerrvcrr)z=IntTestCases.test_intconversion..TruncReturnsNonIndexcrsr4rr9rvrrrkr?zGIntTestCases.test_intconversion..TruncReturnsNonIndex.__trunc__NrmrrwrrTruncReturnsNonIndexrrxcrr)z4IntTestCases.test_intconversion..NonIntegralcrsr4rr9 NonIntegralrrrksz>IntTestCases.test_intconversion..NonIntegral.__trunc__Nrmrryrrrzrrzcrr)z@IntTestCases.test_intconversion..TruncReturnsNonIntegralcrsr4rr9ryrrrkr?zJIntTestCases.test_intconversion..TruncReturnsNonIntegral.__trunc__NrmrryrrTruncReturnsNonIntegralrr{z2__trunc__ returned non-Integral (type NonIntegral)z!Failed to raise TypeError with %sc@rc)z/IntTestCases.test_intconversion..BadIntcSrdNgE@rr9rrrrgr?z7IntTestCases.test_intconversion..BadInt.__int__NrhrrrrBadIntrr}crr)z;IntTestCases.test_intconversion..TruncReturnsBadIntcrsr4rr9r}rrrkr?zEIntTestCases.test_intconversion..TruncReturnsBadInt.__trunc__Nrmrr~rrTruncReturnsBadIntrr)r-r.r'rNr&ZZeroDivisionErrorrYZfail)r/rarbrirjrArlrnroZtrunc_result_baserurxr{Zerr)r}rqrvrzrtest_intconversionWsJ   zIntTestCases.test_intconversioncCsZGdddt}Gdddt}|d}||d|t|d|t|ddS)Nc@rc)z:IntTestCases.test_int_subclass_with_index..MyIndexcSrdrerr9rrrrKr?zDIntTestCases.test_int_subclass_with_index..MyIndex.__index__NrprrrrMyIndexrrc@rc)z;IntTestCases.test_int_subclass_with_index..BadIndexcSrdr|rr9rrrrKr?zEIntTestCases.test_int_subclass_with_index..BadIndex.__index__NrprrrrBadIndexrrr!r)r'r&)r/rrmy_intrrrtest_int_subclass_with_indexs  z)IntTestCases.test_int_subclass_with_indexcCsjGdddt}Gdddt}|d}||d|t|d|d}||d|tt|dS)Nc@rc)z6IntTestCases.test_int_subclass_with_int..MyIntcSrdrerr9rrrrgr?z>IntTestCases.test_int_subclass_with_int..MyInt.__int__NrhrrrrMyIntrrc@rc)z7IntTestCases.test_int_subclass_with_int..BadIntcSrdr|rr9rrrrgr?z?IntTestCases.test_int_subclass_with_int..BadInt.__int__Nrhrrrrr}rr}r!rf)r'r&r-r.)r/rr}rrrrtest_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@rc)z.BadIndexcSrdNTrr9rrrrKr?zFIntTestCases.test_int_returns_int_subclass..BadIndex.__index__Nrprrrrrrrc@rc)z=IntTestCases.test_int_returns_int_subclass..BadIndex2cSrdrrr9rrrrKr?zGIntTestCases.test_int_returns_int_subclass..BadIndex2.__index__Nrprrrr BadIndex2rrc@rc)z:IntTestCases.test_int_returns_int_subclass..BadIntcSrdrrr9rrrrgr?zBIntTestCases.test_int_returns_int_subclass..BadInt.__int__Nrhrrrrr}rr}c@rc)z;IntTestCases.test_int_returns_int_subclass..BadInt2cSrdrrr9rrrrgr?zCIntTestCases.test_int_returns_int_subclass..BadInt2.__int__NrhrrrrBadInt2rrcrr)zHIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIndexcrsr4rr9rrrrkr?zRIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIndex.__trunc__NrmrrrrTruncReturnsBadIndexrrcrr)zFIntTestCases.test_int_returns_int_subclass..TruncReturnsBadIntcrsr4rr9r~rrrkr?zPIntTestCases.test_int_returns_int_subclass..TruncReturnsBadInt.__trunc__Nrmrr~rrrrrc@rc)zKIntTestCases.test_int_returns_int_subclass..TruncReturnsIntSubclasscSrdrrr9rrrrkr?zUIntTestCases.test_int_returns_int_subclass..TruncReturnsIntSubclass.__trunc__NrmrrrrTruncReturnsIntSubclassrrrr)r'Z assertWarnsZDeprecationWarningr&r;r[r) r/rrrrrZbad_intZnZgood_intr)rr}rtest_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))r\rz*invalid literal for int() with base %d: %rr)r-r)r'r&Z exceptionZargs)r0rAZcmr9rrchecks  z.IntTestCases.test_error_message..checku½u123½z 123 456 z123rz123 245r"rz123245r^s123u123r4r)r/rrr9rtest_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_1riUUUUZ1_2_3_4_5_6_7_0_1_2_3riSpSZ1_2_3_4_5_6_7_8_9rlgFZ 1_2_3_4_5_6_7r$i2Dr=r9rrrtest_issue316196s  zIntTestCases.test_issue31619N)rrrr2r:rZ cpython_onlyr<r>rCrErFrOr]r_r`rrrrrrrrrrr s&8  #VH!rZ__main__)r+ZunittestZtestrZtest.test_grammarrrr*r,r)r(r'rZTestCaserrZmainrrrrZs< "