asda?‰PNG  IHDR ? f ??C1 sRGB ??é gAMA ±? üa pHYs ? ??o¨d GIDATx^íüL”÷e÷Y?a?("Bh?_ò???¢§?q5k?*:t0A-o??¥]VkJ¢M??f?±8\k2íll£1]q?ù???T a bYhDE"@s4dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z mZmZmZmZmZmZmZmZmZddlZddlZddlZejdkrededdgdZeddgd ZddlZed d gdZeej d<ed d gdZ!eej d<eeee!iZ"eej d<eer6e#e$j%&ndee#e$j%&iZ'eer~ej(ej)ej*ej+ej,ej-ej.ej/ej0g ndeej(ej)ej*ej+ej,ej-ej.ej/ej0g iZ1d d Z2ej3Z3ej4Z4ej5Z5ej6Z6ej7Z7ej8Z8ej9Z9ej:Z:e3e4e5e6e7e8e9e:gZ;eer e$ndee$iZe?dkr@ej@dZAneBZAejCDeApVejEZFeFejGe>ejGZHejCIeH aJdZKeLedrdndZMeNeMdZOePeMdZQGdddejRZSGdddeSZTGdddeSZUGdddejRZVGdddeVZWGd d!d!eVZXGd"d#d#ejRZYGd$d%d%eYZZGd&d'd'eYZ[Gd(d)d)ejRZ\Gd*d+d+e\Z]Gd,d-d-e\Z^Gd.d/d/ejRZ_Gd0d1d1e_Z`Gd2d3d3e_Zad4d5Zbd6d7ZcGd8d9d9ejRZdGd:d;d;edZeGdd?d?ejRZgGd@dAdAegZhGdBdCdCegZiGdDdEdEejRZjGdFdGdGejZkGdHdIdIejZlGdJdKdKejRZmGdLdMdMemZnGdNdOdOemZoGdPdQdQejRZpGdRdSdSepZqGdTdUdUepZrGdVdWdWejRZsGdXdYdYesZtGdZd[d[esZuGd\d]d]ejRZvGd^d_d_evZwGd`dadaevZxGdbdcdcejRZyGdddedeeyZzGdfdgdgeyZ{GdhdidiejRZ|Gdjdkdke|Z}Gdldmdme|Z~eQGdndodoejRZGdpdqdqejRZGdrdsdseZGdtdudueZGdvdwdwejRZGdxdydyejRZGdzd{d{ejRZGd|d}d}ejRZeeNed~GdddejRZeWeXeZe[e]e^e`eaeeefeheiekeleneoeqereteuewexeze{e}e~eeeeeeeTeUg"ZesedddZnedeededddZe?dkr0ddlZedZejdddddejddddde\ZZejr edddn&er$eddeejdn eddddS)ag These are the test cases for the Decimal module. There are two groups of tests, Arithmetic and Behaviour. The former test the Decimal arithmetic using the tests provided by Mike Cowlishaw. The latter test the pythonic behaviour according to PEP 327. Cowlishaw's tests can be downloaded from: http://speleotrove.com/decimal/dectest.zip This test module can be called from command line with one parameter (Arithmetic or Behaviour) to test each part, or without parameter to test both parts. If you're working through IDLE, you can import this test module and call test_main() with the corresponding argument. N) run_unittest run_doctestis_resource_enabledrequires_IEEE_754requires_docstringsimport_fresh_module TestFailedrun_with_locale cpython_onlydarwin_malloc_err_warningcheck_sanitizerdarwinZ test_decimaldecimalZ_decimal)Zfresh)Zblocked fractionscs,t|||tfddDdS)Nc3s(|] }|vr|n| VqdSN.0sdexpectedr-/usr/local/lib/python3.9/test/test_decimal.py Qz!assert_signals..)getattr assertTrueall)clscontextattrrrrrassert_signalsOs r!cCs2|sdS|jdttt|dd}||dS)N r)precroundingtraps)ContextROUND_HALF_EVENdictfromkeysSignals setcontext)mZDefaultTestContextrrriniths r-Zdecimaltestdata__main__F DecClampedTz.test requires build with -DEXTRA_FUNCTIONALITYztest requires regular buildc@speZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS) IBMTestCasesz?Class which tests the Decimal class against the IBM test cases.c&Csx|j|_|j|_dg|_tgd|_|jtkr|jd|jd|jd|jd|jd|jd|jd |jd |j |j |j |j |j d |_d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1%|_ttttttttd2|_|jj|jj|jj|jj|jj|jj|jj|jj|jj|jj|jj|jj d3 |_!d4|_"dS)5N#)Zscbx164Zscbx165Zexpx901Zexpx902Zexpx903Zexpx905Zlnx901Zlnx902Zlnx903Zlnx905Zlogx901Zlogx902Zlogx903Zlogx905Zpowx1183Zpowx1184Zpowx4001Zpowx4002Zpowx4003Zpowx4005Zpowx4008Zpowx4010Zpowx4012Zpowx4014Zpwsx803Zpwsx805Zpowx4302Zpowx4303Zpowx4342Zpowx4343Zpwmx325Zpwmx326)Z precisionr$Z maxexponentZ minexponentclamp logical_and_apply number_classcompare_signal compare_totalcompare_total_mag copy_decimalcopy_abs copy_negate copy_sign divide_intlogical_invert is_canonical is_finite is_infiniteis_nan is_normalis_qnan is_signedis_snan is_subnormalis_zeromax_magmin_mag next_minus next_plus next_toward logical_or normalizeremainder_near same_quantumsqrt to_eng_stringto_integral_valueto_integral_exact to_sci_string logical_xor)%andZapplyclassZ comparesigZ comparetotalZ comparetotmagcopyZcopyabsZ copynegatecopysignZ divideintinvertZ iscanonicalisfiniteZ isinfiniteisnanZisnormalZisqnanZissignedZissnanZ issubnormalZiszeroZmaxmagZminmagZ nextminusZnextplusZ nexttowardorreduceZ remaindernearZ samequantumZ squarerootZtoengZ tointegralZ tointegralxZtoscixor)ZceilingZdownfloorZ half_downZ half_evenZhalf_upZupZ05up) ZclampedZconversion_syntaxZdivision_by_zeroZdivision_impossibleZdivision_undefinedZinexactZinvalid_contextZinvalid_operationZoverflowZroundedZ subnormalZ underflow) r?r@rArBrCrDrErFrGrHrQ)#rr&r readcontext ignore_listsetskipped_test_idsCaddchange_precisionchange_rounding_methodchange_max_exponentchange_min_exponent change_clamp ChangeDict NameAdapter ROUND_CEILING ROUND_DOWN ROUND_FLOORROUND_HALF_DOWNr' ROUND_HALF_UPROUND_UP ROUND_05UP RoundingDictClampedInvalidOperationDivisionByZeroInexactOverflowRounded Subnormal Underflow ErrorNamesLogicalFunctionsselfrrrsetUps  $         ' zIBMTestCases.setUpcCsX|jtkrF|jjdkrF|jd|jd|jd|j|S|j||SdS)a2Work around the limitations of the 32-bit _decimal version. The guaranteed maximum values for prec, Emax etc. are 425000000, but higher values usually work, except for rare corner cases. In particular, all of the IBM tests pass with maximum values of 1070000000.@Ti?i9N) rrgMAX_EMAXrc_unsafe_setprec_unsafe_setemax_unsafe_setemincreate_decimalDecimal)rvrrrrread_unlimiteds     zIBMTestCases.read_unlimitedc Cstr tjt|}|D]j}|dddd}z||}Wq|jjy}z&|d|j j d|WYd}~qd}~00qWdn1s0YdS)Nz  z Exception "z" raised on line ) skip_expectedunittestZSkipTestopenreplace eval_linerDecimalExceptionfail __class____name__)rfileflinet exceptionrrr eval_file#s zIBMTestCases.eval_filecCs|ddkrX|dddkrX|dsX|ddd|dddd}n|dd}|jD]}||dkrpdSqp|sdSd|vr||S||SdS) Nz -> r--z --->:)find startswithsplitstriprdeval_directive eval_equation)rrignorerrrr2s(   zIBMTestCases.eval_linecCsjdd|dD\}}|dkr,|j|}n z t|}WntyJYn0|j|dd}||dS)Ncss|]}|VqdSr)rlowerrxrrrrErz.IBMTestCases.eval_directive..rr$cWsdSrr)argsrrrNrz-IBMTestCases.eval_directive..)rrwint ValueErrorrnget)rrfunctvaluerrrrDs   zIBMTestCases.eval_directivec ststdkrdSjzt|d}|d}|d}trTtd|dd|d}|dd}|d}|d}|dd}Wn t t t fyj j Yn0d d } |jvrdSj||} | d krdStj| }g} d } d} fd d|Dtj D]}djj|<qD]}djj|<q0t|D]&\}}|dddkrrd| } | r| d|} qLn | |}d } | |}| dvrZtrLD]}djj|<z|j|WnR|yYnRtj y(}z d|||fWYd}~nd}~00d||fdjj|<qj|}n|j}| |qL| |}tr| dvrD]}djj|<z || WnR|yYnRtj y}z d|||fWYd}~nd}~00d||fdjj|<qfddtj D}|D]}djj|<z || WnV|ypYnVtj y}z$dt|||fWYd}~nd}~00d||fq@|D]}djj|<qtrtdjz,t|| }| jvrttt |}WnTtj y^}zd||fWYd}~n d}~0td|Yn0!}|j"t#dj"t#d$||d|d|$|d|dt|dS)Ng?rrzTest  )endrrcSs@|dddd}|dddd}|dddd}|S)Nz''Z SingleQuotez""Z DoubleQuote'r")r)valrrr FixQuotesesz-IBMTestCases.eval_equation..FixQuotesZrescalercsg|]}j|qSr)rrrrrr urz.IBMTestCases.eval_equation..r)rVrSz Raised %s in %s when %s disabledzDid not raise %s in %scsg|]}|vr|qSrrre)theirexceptionsrrrrzRaised %s in %s; expected %srzRaised %s in %szERROR:keyzIncorrect answer for z -- got zIncorrect flags set in )%TEST_ALLrandomr clear_flagsrrDEBUGprintr TypeErrorAttributeError IndexErrorrryrfrorrr*r% enumeratecountEXTENDEDERRORTESTrrrappendOrderedSignalstypestrrreval getexceptionssortrepr assertEqual)rrZSidesLidrZvalstempans exceptionsrZfnameZvalsZ conglomeratequoterirrerrorrZordered_errorsresultZ myexceptionsr)rrrrQs                 &   zIBMTestCases.eval_equationcsfddtjDS)Ncsg|]}jj|r|qSr)rflagsrrrrrrz.IBMTestCases.getexceptions..)r*rrrrrrszIBMTestCases.getexceptionscCs0|jtkr$|jjdkr$|j|n||j_dSNr)rrgMAX_PRECrrr#)rr#rrrriszIBMTestCases.change_precisioncCs ||j_dSr)rr$)rr$rrrrjsz#IBMTestCases.change_rounding_methodcCs0|jtkr$|jjdkr$|j|n||j_dSr)rrgrrrEminrexprrrrlsz IBMTestCases.change_min_exponentcCs0|jtkr$|jjdkr$|j|n||j_dSr)rrgrrrEmaxrrrrrksz IBMTestCases.change_max_exponentcCs ||j_dSr)rr2)rr2rrrrmszIBMTestCases.change_clampN)r __module__ __qualname____doc__rrrrrrrrirjrlrkrmrrrrr0s r0c@seZdZeZdS) CIBMTestCasesNrrrrgrrrrrrsrc@seZdZeZdS)PyIBMTestCasesNrrrPrrrrrrsrc@seZdZdZddZddZddZdd Zed d Z d d Z ddZ ddZ ddZ eddZddZddZddZdS)ExplicitConstructionTestz6Unit tests for Explicit Construction cases of Decimal.cCs|jj}|||ddS)N0rrrrrrrrtest_explicit_emptysz,ExplicitConstructionTest.test_explicit_emptycCs|jj}|t|ddSr)rr assertRaisesrrrrrtest_explicit_from_Nonesz0ExplicitConstructionTest.test_explicit_from_NonecCs|jj}|d}|t|d|d}|t|d|d}|t|d|d}|t|dtdd D]J}d D]@}td d D]0}|d ||}||}|t|t|qqzqrdS)N-45{e 500000123-45rr rr)rrrrrange)rrrnsignrrrrrtest_explicit_from_intsz/ExplicitConstructionTest.test_explicit_from_intcCs|jj}|jj}|jj}|t|dd|t|dd|t|dd|t|dd|t|dd|t|dd |t|d d |t|d d |t|dd|t|dddD]*}dD] }|t||d|dqq|}d|j|<|||d|t|ddd|||d|||d|||d|||d|||d|||dWdn1s0YdS)NrNaNr45.34Z45e2z4.5E+3uglyz1.3E4 z1.3E+4z -7.89z-7.89z 3.45679 z3.45679z 1_3.3e4_0z1.33E+41Z1_0_0_01000)rr u z 9.311E+28Txyz1234ryu1 2 3u 1 2 ru  z123z1_2_3) rrry localcontextrrr%rr)rrryr Zleadtrailcrrrtest_explicit_from_strings8 z2ExplicitConstructionTest.test_explicit_from_stringcCsRddl}|jj}|j}|d}|t||d|t||ddS)Nr9.999999) _testcapirrr&unicode_legacy_stringrrr)rrrrrrrrtest_from_legacy_stringsMs   z1ExplicitConstructionTest.test_from_legacy_stringscCs6|jj}|d}|t|d|d}|t|d|d}|t|d|d}|t|d|d }|t|d |t|d |t|d |t|d |t||dddf|t|d|t|d|t|d|t|d|t|d|t|d|t|d|t|ddS)Nrrrrr)rrrrrrrrr rrrr"rrrrr-4.34913534E-17)rrFInfinity)rrrrr"r)r r)r rrr r)rr zwrong!)rr r")rr 1)rrr)r)rrrNrr)r)rrr"rr)r)r rr"rr)r)rrrarr)rrrrrrrrrrrrtest_explicit_from_tuplesWs.z2ExplicitConstructionTest.test_explicit_from_tuplescCs|jj}|ddgdg}|t|d|dgddg}|t|d|gd}|t|d|dgddf}|t|ddS)Nrrrrrrrrrrrr'rrrtest_explicit_from_lists z0ExplicitConstructionTest.test_explicit_from_listcCs\|jj}|t|dd|t|dd||d|d||d|ddS)NrFrT)rrassertIsboolrrrrrtest_explicit_from_bools z0ExplicitConstructionTest.test_explicit_from_boolcCs|jj}|d}||}|t|d|d}||}|t|d|d}||}|t|d|d}||}|t|ddS) Nrrrrrrrrr)rrrrrrrtest_explicit_from_Decimalsz3ExplicitConstructionTest.test_explicit_from_DecimalcCs2|jj}|d}|t|||t|d||td||td||td|t|tdt|d|t|tdt|d|t|tdt|d|t|td t|d t d D]2}t d t d d}||t||qdS)N皙?90.1000000000000000055511151231257827021181583404541015625naninf-infrr -Infinity-0.0-0{Gz?@?) rrrrrrfloatrDrArr expovariate)rrrrrrrrtest_explicit_from_floats0      z1ExplicitConstructionTest.test_explicit_from_floatcCs|jj}|jj}|jj}t|j}d|_|}|t|d| }|t|d| t |j d| d}| |||| d| d|d}|t|d| d}|t|d|t| dd |d }|t|d | d }|t|d |d }||}|t|d| |}|t|dd|_d|j |<dD]0}| |}|t|||t||qbd|_d|j |<| ||j dd|_|t| dd|t| dd|t| dd|t| dd| ||j d| t|j d| t |j dd| ||j d| ||j dd|_| ||j d | ||j |d d!|j |<|t| d d ||j|d!|j|<|t| |d d ||j|dS)"Nrrinz457E+2Z456789z4.57E+5z3.14 rrrz -4.35E-17rrz5.00E+8T) lllirlz0E-017z0E-17r-Infr5NaN123r)rrrrZ5678z 1234Z12_34ZNaN12345F)rrryr}rZ getcontextr#rrrrrassertIsInstancer%r isinstancerrr)rrryr}ncrZprevdecrrrr$test_explicit_context_create_decimalsv            z=ExplicitConstructionTest.test_explicit_context_create_decimalcCs^|jj}|j}|d}|t|||t|d||td ||td ||td |t|tdt|d|t|tdt|d|t|tdt|d|t|td t|d d |_ t d D]6}t d t dd}||t||q"dS)Nr0z0.1000000000000000055511151231r2r3r4rrr5r6r7dr8r9r:r;)rrr&rrrrrr<rDrAr#rrr=)rrrKr>rrrrr'test_explicit_context_create_from_float!s0       z@ExplicitConstructionTest.test_explicit_context_create_from_floatcCs>|jj}dddd}|D]\}}|t|||qdS)Nr#z 0.0000372z-NaN2400)u1u٠.٠٣٧٢e-٣u-nan౨౪౦౦)rritemsrr)rr test_valuesinputrrrrtest_unicode_digits9sz,ExplicitConstructionTest.test_unicode_digitsN)rrrrrrrr r rr(r*r-r/rr?rLrNrRrrrrrs 8 + Yrc@seZdZeZdS)CExplicitConstructionTestNrrrrrrSDsrSc@seZdZeZdS)PyExplicitConstructionTestNrrrrrrTFsrTc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)ImplicitConstructionTestz6Unit tests for Implicit Construction cases of Decimal.cCs|jj}|ttdtdS)NzDecimal(5) + Nonerrrrrlocalsrrrrtest_implicit_from_NoneLsz0ImplicitConstructionTest.test_implicit_from_NonecCs<|jj}|t|ddd||dd|ddS)NrrZ50l2}rr)rrrrtest_implicit_from_intPsz/ImplicitConstructionTest.test_implicit_from_intcCs|jj}|ttdtdS)NzDecimal(5) + "3"rVrrrrtest_implicit_from_stringXsz2ImplicitConstructionTest.test_implicit_from_stringcCs|jj}|ttdtdS)NzDecimal(5) + 2.2rVrrrrtest_implicit_from_float\sz1ImplicitConstructionTest.test_implicit_from_floatcCs(|jj}||d|d|ddS)Nrr2rrrrrtest_implicit_from_Decimal`sz3ImplicitConstructionTest.test_implicit_from_Decimalcs*|jj}Gddd}|t||dd|t|d|d|tdd|tdd |td d |td d |tdd|tddgd}|D]r\}t|fddt|fdd|td|ddd|td|dddqdS)Nc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)z,ImplicitConstructionTest.test_rop..EcSs dt|S)Nzdivmod rrotherrrr __divmod__isz7ImplicitConstructionTest.test_rop..E.__divmod__cSs t|dS)Nz rdivmodr^r_rrr __rdivmod__ksz8ImplicitConstructionTest.test_rop..E.__rdivmod__cSs dt|S)Nzlt r^r_rrr__lt__msz3ImplicitConstructionTest.test_rop..E.__lt__cSs dt|S)Nzgt r^r_rrr__gt__osz3ImplicitConstructionTest.test_rop..E.__gt__cSs dt|S)Nzle r^r_rrr__le__qsz3ImplicitConstructionTest.test_rop..E.__le__cSs dt|S)Nzge r^r_rrr__ge__ssz3ImplicitConstructionTest.test_rop..E.__ge__cSs dt|S)Nzeq r^r_rrr__eq__usz3ImplicitConstructionTest.test_rop..E.__eq__cSs dt|S)Nzne r^r_rrr__ne__wsz3ImplicitConstructionTest.test_rop..E.__ne__N) rrrrarbrcrdrerfrgrhrrrrEhsrir%z divmod 10z 10 rdivmodzDecimal(10) < E()zgt 10zDecimal(10) > E()zlt 10zDecimal(10) <= E()zge 10zDecimal(10) >= E()zle 10zDecimal(10) == E()zeq 10zDecimal(10) != E()zne 10))+__add____radd__)-__sub____rsub__)*__mul____rmul__)/ __truediv__ __rtruediv__)%__mod____rmod__)z// __floordiv__ __rfloordiv__)z**__pow____rpow__csdt|SNrr^r_)loprrrrz3ImplicitConstructionTest.test_rop..cst|dSr}r^r_)roprrrrzE()z Decimal(10)r10)rrrdivmodrsetattr)rrriZoplistZsymr)r~rrtest_ropds(   z!ImplicitConstructionTest.test_ropN) rrrrrXrYrZr[r]rrrrrrUIsrUc@seZdZeZdS)CImplicitConstructionTestNrrrrrrsrc@seZdZeZdS)PyImplicitConstructionTestNrrrrrrsrc@s:eZdZdZddZddZedddd Zd d Zd S) FormatTestz#Unit tests for the format function.cCsN|jj}gd}|D] \}}}|t||||q|t|djddS)N))r0E-15z0e-15)rz2.3E-15z2.3e-15)rz2.30E+2z2.30e+2)rz 2.30000E-15z 2.30000e-15)rz1.23456789123456789e40z1.23456789123456789e+40)r1.5z1.5e+0)rz0.15z1.5e-1)rz0.015z1.5e-2)rz0.0000000000015z1.5e-12)rz15.0z1.50e+1)r-15z-1.5e+1)rrz0e+0)r0E10e+1)r0.0z0e-1)r0.000e-2).6erz 0.000000e-9)rrz 0.000000e+6)rrz 9.999999e+0)rz 9.9999999z 1.000000e+1)rz-1.23e5z -1.230000e+5)rz 1.23456789e-3z 1.234568e-3)rrr)rrr)r0E-2r)rz0.00E-8z 0.0000000000)rrr)rz3.2E132)rz3.2E2320)rz3.20E2r)rz3.200E2z320.0)rz3.2E-6z 0.0000032).6fr0.000000)rrr)rrr).0frr)rrr)r 3.141592653)z.1fr3.1)z.4fr3.1416)rr3.141593)z.7fr 3.1415926)z.8frr)z.9frz 3.141592650)grr)rrr)rrr)Grz0E+1)rz0E-5z0.00000)rz0E-6r)rz0E-7z0e-7)rz-0E2z-0e+2).0grr)z.0nrr)z.1grr)z.2grr)z.5grr)z.7grr)z.8grr)z.9grr)z.10grr)rvr0%)rvZ0E0r)rvz0E-1r)rvrr)rvz0E-3z0.0%)rvz0E-4z0.00%).3%r0.000%)r0E10r)rz0E-10r)rz2.34z234.000%)rz1.234567z123.457%).0%1.23z123%)rrr)r-NaN123r)z+gZNaN456z+NaN456)z.3eInfr)z.16frFr5)r-sNaNr)r1.00r)6123 123)z<6rz123 )z>6rr)z^6rz 123 )z=+6rz+ 123)#<10rz NaN#######)rz-4.3z -4.3######)z#<+100.0130z +0.0130###)z#< 10rz 0.0130###)z@>10rFz @-Infinity)z#>5rFr5)z?^5rz?123?)z%^6rz%123%%)z ^6-45.6z-45.6 )z/=10rz -/////45.6)z/=+1045.6z +/////45.6)z/= 10rz /////45.6)z=10r4z -Infinity)z^16r4z-Infinity)z>101.2345z 1.2345)z<10rz 1.2345),Z1234567z 1,234,567)r123456123,456)rZ1234512,345)rrz1,234)rrr)r12r)rr#r#)rrr)rz-1234567z -1,234,567)r-123456-123,456)z7,rr)z8,r 123,456)08,rz 0,123,456)z+08,rz+123,456)z 08,rr)rrr)z+09,rz +0,123,456)z07,1234.561,234.56)rrr)z09,rz 01,234.56)z010,rz 001,234.56)z011,r 0,001,234.56)z012,rr)z08,.1fz1234.5z01,234.5)r 1.23456789r)z,%z 123.456789z 12,345.6789%)z,erz 1.23456e+5)z,Erz 1.23456E+5)za=-7.0z0.12345zaaaa0.1)z <^+15.20%r3z<<+Infinity%<<<)z>,%Z sNaN1234567z sNaN1234567%)z=10.10%rGz NaN123%rs-020)rrrformatrr __format__)rrrPfmtrrrrrtest_formattings zFormatTest.test_formattingc s8jjzddlm}Wnty4dYn0fdd}dAfdd }d |gd d d }d ||gd d }d |gd dd }d|ddd|gdd }dd|gd ddd }|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|d d!|d|d d"|d|d d"|d|d d#|d$|d%d&|d$|d'd&|d$|d(d)|d$|d*d+|d,|d(d-|d,|d*d-|d,|d.d/|d,|d0d1|d,|d2d1|d,|d3d4|d5|d*d6|d5|d.d6|d5|d0d6|d5|d2d7|d5|d3d8|d5|d9d8|d5|d:d;|d5|d<d=|d>|d?d@dS)BNrCHAR_MAXlocale.CHAR_MAX not availablecs"jtkrddd|DS|S)NrcSsg|] }t|qSrchrrrrrrErzCFormatTest.test_n_format..make_grouping..)rrgjoinZlstrrr make_groupingDsz/FormatTest.test_n_format..make_groupingrcs0jtkr|||S|j||dSdS)N) _localeconv)rrgrroverriderrrrrget_fmtGs z)FormatTest.test_n_format..get_fmt.rrrr decimal_pointgrouping thousands_seprr&rrrrms¿zutf-8s´z12.7z12,7z1-2&7i[z 123,456,789Z 123456789z 123 456 789lc}z123456-78-9012-3z.6nz 1.23457e+8z 1,23457e+8z 1&23457e+8rEZ03nrZ04nZ05nZ01234Z06nZ00123490rZ07nz012,345Z08nz 0,012,345Z09nZ010nz 00,012,345i@z1-2345-6z 01-2345-6z 0-01-2345-6Z011nZ012nz 00-01-2345-6Z013nz 000-01-2345-6-1.5Z020nu-0´000´000´000´001¿5)Nr)rrlocaler ImportErrorskipTestdecoder) rrrren_USfr_FRru_RUZcrazyZ dotsep_widerrr test_n_format<sx     zFormatTest.test_n_formatLC_ALLps_AFcCsn|jj}td}td}|dkr:|d|d|dkrT|d|d|t|ddd dS) Nrru٫z5inappropriate decimal point separator ({!a} not {!a})u٬z1inappropriate thousands separator ({!a} not {!a})z 100000000.123ru100٬000٬000٫123)rrr localeconvrrr)rrrrrrr&test_wide_char_separator_decimal_points  z1FormatTest.test_wide_char_separator_decimal_pointcCsPGddd|jj}|d}||jj|j|d}||jj|jdS)Nc@seZdZddZdS)z;FormatTest.test_decimal_from_float_argument_type..AcSst||_dSr)ra_type)rr&rrr__init__szDFormatTest.test_decimal_from_float_argument_type..A.__init__NrrrrrrrrAsrg@E@*)rr from_floatrr)rrr&rrr%test_decimal_from_float_argument_types   z0FormatTest.test_decimal_from_float_argument_typeN) rrrrrrr rrrrrrrs Y rc@seZdZeZdS) CFormatTestNrrrrrrsrc@seZdZeZdS) PyFormatTestNrrrrrrsrc@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)ArithmeticOperatorsTestz:Unit tests for all arithmetic operators, binary and unary.cCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||7}|||d|d7}|||ddS)N-11.122.2z11.1rz-6.116.1rrrrrrd1d2r rrr test_additionsz%ArithmeticOperatorsTest.test_additioncCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||8}|||d|d8}|||ddS) Nrrz-33.3z33.3rz-16.1rz-38.3rrrrrtest_subtractionsz(ArithmeticOperatorsTest.test_subtractioncCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||9}|||d|d9}|||ddS)N-5rrrz-25z-75rrrrrtest_multiplicationsz+ArithmeticOperatorsTest.test_multiplicationcCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||}|||d|d}|||ddS) Nr2-2.5z-0.4rz-1.25z-0.8z-0.625rrrrr test_division sz%ArithmeticOperatorsTest.test_divisioncCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||}|||d|d}|||ddS)N5rrrr#rrrrrrtest_floor_division(sz+ArithmeticOperatorsTest.test_floor_divisioncCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||C}|||d|dC}|||d dS) NrrZ25rrZ625rZ16807Z390625rrrrr test_poweringDsz%ArithmeticOperatorsTest.test_poweringcCs|jj}|d}|d}||||d||||d|d}|||d|t|t|d|}|||d|t|t|||;}|||d|d;}|||ddSNrrr#rrrrrrr test_module`sz#ArithmeticOperatorsTest.test_modulecCs|jj}|d}|d}t||\}}|||d|||d|t|t||t|t|t|d\}}|||d|||d|t|t||t|t|td|\}}|||d|||d|t|t||t|t|dSr)rrrrr)rrrrpqrrrtest_floor_div_module|s$z-ArithmeticOperatorsTest.test_floor_div_modulecCsT|jj}||d |d||d |d|t|dt|ddS)Nrr)rrrabsrrrrtest_unary_operatorssz,ArithmeticOperatorsTest.test_unary_operatorscCs|jj}|jj}|jj}|d}|d}|d}|d}||f||f||f||f||ff}||f||f||f||f||f||f||ff} tjtjtjtjf} tj tj f} || D]P\} } | | D]>}|| | }|tj urdnd}| ||d ||j | | |qq|}d|j|<|D]R\} } | D]B}|| | }|tj urBdnd}| ||d ||j | | |q$q| D]:\} } | D]*}||tj | | ||tj | | q|qp|| D]&\} } | D]}|||| | qqWdn1s0YdS) NrsNaNrrTFz8expected {0!r} for operator.{1}({2!r}, {3!r}); got {4!r}r)rrryr operatorltlegtgeeqner+rrr%r)rrryr rrrrZ qnan_pairsZ snan_pairsZ order_opsZ equality_opsrr opZgotrctxrrrtest_nan_comparisonssL".          z,ArithmeticOperatorsTest.test_nan_comparisonscCsH|jj}|d|d}||dd||t|djddS)Nrr-2)rrr<rrrr'rrrtest_copy_signsz&ArithmeticOperatorsTest.test_copy_signN)rrrrrrrrrrrrrrrrrrrrs7rc@seZdZeZdS)CArithmeticOperatorsTestNrrrrrrsrc@seZdZeZdS)PyArithmeticOperatorsTestNrrrrrrsrc Cs|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|d} |d} | | } |j |j | | } |} | | j|||| j| d| | j||X}| |j|| |j||||j| |d| |j|~Wdn1s0Y|| j|~ Wdn1sF0Y|| |d|| |d|}| |j|||||fD]}||j|qdS)Nrrrr0.333333333333333333333333)rrryrzr|rr{rHr finish1resynchrowaitrrrdividecompare assertFalser)rrryrzr|rr{rHr rd3test1test2c2c3c1sigrrrthfunc1s@  ""r$c Cs|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|d} |d} | | } |} d| _ | | } |}| |j || ||j |dd| |j ||| b}| |j |||j |d|j|<| ||j|dd| |j |~Wdn1s0Y||j |||j|~Wdn1s^0Y|j|j|| |d|| |d || j|| | j |||||fD]}|| j |qdS) NrrZ 1e425000000Tz 1e-425000000rz0.333333333333333333)rrryrzr|rr{rHr r#rrrmultiplyrr%rrrefinish2r)rrryrzr|rr{rHr rrrZ thiscontextrr r!r#rrrthfunc2 sH  ""  r)c@seZdZdZddZdS) ThreadingTestz0Unit tests for thread local contexts in Decimal.cCs|jj}|jtkr$|jjs$|d|j}|j}|j}d|_d|_d|_t |_ t |_ t |_ tj t|fd}tj t|fd}|||j |j t|jD]}||j|q||||_||_||_dS)Nzcompiled without threadingr)targetr)rDefaultContextrg HAVE_THREADSrr#rr threadingEventrrr(Threadr$r)startrr*rrr)rr.Z save_precZ save_emaxZ save_eminZth1Zth2r#rrrtest_threading<s2      zThreadingTest.test_threadingN)rrrrr4rrrrr*6sr*c@seZdZeZdS)CThreadingTestNrrrrrr5csr5c@seZdZeZdS)PyThreadingTestNrrrrrr6fsr6c@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(S)) UsabilityTestz*Unit tests for Usability cases of Decimal.cCs|jj}|d}|d}|d}||||||||||||||||||||||||||d|d|||d||d||d||t||tt t |t d}|dd}t |||||dS)Nz23.42rrrgY@@rM)rr assertGreaterassertGreaterEqual assertLessassertLessEqualrassertNotEqualobjectlistmaprrshuffler)rrdadbdcr&brrrtest_comparison_operatorsls0                z'UsabilityTest.test_comparison_operatorscCs|jj}|d}|d}||d||d||d||d||d||d|d||d||d||d||d||d||d|ddS)N0.253.0@?g?r00.1)rrr;r<r9r:r=rrrrBrCrrrtest_decimal_float_comparisons             z+UsabilityTest.test_decimal_float_comparisoncCs|jj}|d}|d}||d|d|||d|d||d|||d||d|d|||dt||dt||dt||dtdS)NrGrHy?y?y@y@?) rrr=rr+rcNotImplementedrerdrLrrrtest_decimal_complex_comparisons        z-UsabilityTest.test_decimal_complex_comparisonc Cs|jj}t|jj}|jj}|jj}|jj}tr6tjnd}trDtj nd}trRtj nd}|||d} || || _ | |d|dd| |dd|d| |dd|d t || |d t ||dd| |dd |d t || |d t ||dd ||d |dd ||dd |d d| _ ||dd|dd||dd|dd||dd|dt |||dt ||dd||d|dd||d|dd| |d|dd| |d|dd|||dj|dd|t|dd|d||d|dd||dd|dWdn1s0YdS)Nɚ;6eilʈrrrrl ZmH;5BrZ1ez-1el!0QYrKr%i,ri6lc( Z9er3lg]{lg]r4r2i)rrrZFractionr&r ryrgrMIN_EMIN MIN_ETINYr#r;rrr=r<r:r9rrdr+rNrc) rDrr&r ryemaxeminZetinyr rrr test_decimal_fraction_comparisons@   z.UsabilityTest.test_decimal_fraction_comparisoncCsP|jj}|d}t|}|t|t|t|}|t|t|dS)Nz43.24)rrrZrrdeepcopy)rrrr rDrrrtest_copy_and_deepcopy_methodss   z,UsabilityTest.test_copy_and_deepcopy_methodscsjjjj}fdd}|d|d|d|d|dfdd d D}|d d d dddddddddddddg|D]}|||t|q؈|d|dttd |d |dgd}|D]*}t |}|}||||qP|} d} d | _ || } d!| _ || } d"| _ || } | | | | d#| _ d$d%} || || Wdn1s 0YdS)&Ncs t|}|}|||Sr)hash__hash__r)rr&rErrrhashits z.UsabilityTest.test_hash_method..hashitr8rr5Znan123-NaNcs:g|]2}tddD]"}dD]}|d||qqqS)r%rr)r)rr,rrrrrrsz2UsabilityTest.test_hash_method..)rr!=>?@AB-1r7rz-0.000rz-0E1210.0z -23.00000Z1230E100z -4.5678E50lz 1.634E100z 90.697E100z 188.83E100z 1652.9E100Z 56531E100rrrF)r3rFrz-.0e1z34.02.5z 112390.625z -0.515625z 123456789.1r%rd'iLi) rrr extendrrrrr\rr<r#)rr r^rPrZ test_stringsrrrr rZh1Zh2Zh3rrrtest_hash_methodsj         zUsabilityTest.test_hash_methodcCs|jj}|d}|d}d}d}|t||||t||||t||||t||||t||||t||||t||||t|||dS)N15.32z28.5rcrA)rrr+minmax)rrrrl1l2rrrtest_min_and_max_methods>sz&UsabilityTest.test_min_and_max_methodscCs(|jj}||d||ddS)Nrz0.372)rrrrrrrrtest_as_nonzeroRszUsabilityTest.test_as_nonzerocCs4|jj}|d}|t|d|t|ddS)NrvzDecimal('15.32'))rrrrrr'rrrtest_tostring_methodsZsz#UsabilityTest.test_tostring_methodsc Cs6|jj}|d}|d}|t|d|t|d|t|d|t|dgd}|D]\}}|t|||qd|ttj|d|ttj|d|ttj|d |t tj|d |t tj|d gd }|D]\}}|t |||q|ttj |d|ttj |d|ttj |d |t tj |d |t tj |d gd }|D]\}}|t |||q|tt |d|tt |d|tt |d |t t |d |t t |d gd}|D]&\}}} |t t |||| q dS)NZ66rvrnrcgp= ף.@) z123.00rS3.2r)3.54r)3.899r)-2.3r$z-11.0irrz-0E3r)89891211712379812736.1l{#'s{Mr_rrGrrF) r~)rrrrrrrrrrr)rl{#'s{M)r~rrrrrrr)z-3.5)rr)rr)-0.5r)0.5r)rr)rqr)z3.5r))123.456rz0E+4)rr$z0E+3)rrz1E+2)rrz1.2E+2)rrr)rrz123.5)rr123.46)rrr)rrz123.4560)z123.455rr)z123.445rz123.44)rrr)rFir)ZsNaN314rZNaN314) rrrrr<mathrbrr OverflowErrorceilroundr) rrrrZ test_pairsrrZ test_triplesrr>rrrtest_tonum_methodsbsD   z UsabilityTest.test_tonum_methodscCsX|jj}dD]F}t||}|t|td|}|||drLdndq dS)N)r2Znan1234-nanz-nan2468r;rmg) rrr<rrr^r[rr)rrrrrrrrtest_nan_to_floats   zUsabilityTest.test_nan_to_floatcCs,|jj}dD]}||}|tt|q dS)N)snanz-snanZsnan1357z -snan1234)rrrrr<)rrrrrrrtest_snan_to_floatsz UsabilityTest.test_snan_to_floatcCs||jj}|d}||tt||d}||tt||d}||tt||d}||tt|dS)Nrrrr)rrrrrr'rrrtest_eval_round_tripsz"UsabilityTest.test_eval_round_tripcCsD|jj}|d}||d|d}||d|d}||d|d}||d|d }||d |d }||d |d }||d |d}||d|d}||d|d}||d|d}||d|d}||d|d}||ddS)Nrrrrrrr)rrr)rrrrrrrrr)rrrrrrr)rrrr%)rrr)rrr)rrr)rrr)rrNrrr)rrr)rrr)r)rrrrr)rrr)rrras_tupler'rrr test_as_tuples6zUsabilityTest.test_as_tuplec Cs|jj}|t|j|d|t|j|d|t|j|d|t|j|dtddD]}tdD]}dD]}|d |||f}|}|\}}||t||t ||t | |d | t ||d | |||||qvqnqbdS) Nr3r4rZsnan123rr)rjrmz%s%dE%drr)rrrras_integer_ratiorrrItuplerr9rrgcd) rrrZcoeffrrZpqrrrrrtest_as_integer_ratios2         z#UsabilityTest.test_as_integer_ratiocCsd|jj}Gddd|}|d}|d}||}|t||||}|t||t|}|t|||||t|}|t||||||d}||}|t|||||||}|t|||||||jd||}|t|||||d|_||}|t|||||||jddS)Nc@seZdZdZdS)z1UsabilityTest.test_subclassing..MyDecimalN)rrrr rrrr MyDecimal>srrr1.0r") rrr+rrxrZrrZr )rrrrrrrr,rrrtest_subclassing:s<         zUsabilityTest.test_subclassingcCs@|jj}|jj}|}|t|dt||ddSNr)rrrHrrrRrrrHr rrrtest_implicit_contextis z#UsabilityTest.test_implicit_contextc Cs |jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj } |jj } |jj } || } d| _ d| _ d| _|d} |d}|d}| |t| jddd|| j| || j| | |j||jdd|| j|||jddd ||jddd | |t| jddd || j| || j| | |j||d jdd|| j|| |t| jddd || j| || j| | |j||d jdd|| j|| |t| jddd|j||djdd|| j|| |t| jddd|j||jdd|| j|| |t|jddd|j||djdd|| j|| |t|jddd|j||djdd|| j|| |t|jddd|j||jdd|| j||t|j ddd| |t|j!ddd|| j| || j| || j| || j||| j|| |j||j!dd|| j|d| _"|t|j#dddd| _"| t| j$|ddd}||d|j|| j$|ddd|| j|| t| j%ddd}||d|j|| j%|ddd|| j|| t| j&ddd}||d|j|| j&ddd|| j|| t| j'ddd}||d|j|| j'ddd|| j|| t| j(ddd}||d |j|| j(ddd|| j|| t| j)ddd}||d|j|| j)|ddd|| j|| t| j*ddd}||d|j|| j*|ddd|| j|| t| j+ddd}||d|j|| j+|ddd|| j|| t| j,ddd}||d|j|| j,|ddd|| j|| t| j-ddd}||d |j||j-ddd|| j|| t| j.d!dd}||d"|j|| j.ddd|| j|| t| j/ddd}||d#|j|| j/d$dd|| j|| t| j0d!dd}||d"|j|| j0d$dd|| j|| t| j1d!d%dd}||d&|j|| j1|dd%dd|| j|t2| _3t|d'j4ddd(}||dt5| _3t|d'j4ddd(}||d)t|d'j4t6dd(}||d| |j||dj4dd|| j|t2| _3t|d'j7ddd(}||dt5| _3t|d'j7ddd(}||d)t|d'j7t6dd(}||d| |j||dj7dd|| j|t2| _3t|d'j8ddd(}||dt5| _3t|d'j8ddd(}||d)t|d'j8t6dd(}||d| |j||dj8dd|| j|t6| _3t|d*j9|d+ddd,}||d-t5| _3t|d*j9|d+ddd,}||d.t|d*j9|d+t6dd,}||d-| |j||j9|d/t6dd(|| j|Wdn1 s0Y||x}d|_ d|_ d|_|dd0:} || j d|| j d|| jdWdn1 sz0YWdn1 s0YdS)1Nrr&iZ111Z1e9999z1e-9999rz 1.609487E+48FTz4.709530rz2.045323rrZ1111000z 9.999999E+999rrr +Subnormalz0E-1005rZ Nan891287828Z NaN1287828i roreZ101rSrrZ11100z1.11E+9rsrZ225rr$rr#z1.50001z1e-3)rr$rz1.501z1.500z1e-10)r):rrr&r ryrzr|rr~r{r}rxr#rrrrrrrrrr+rCrGlnlog10logbr>rKrLrOr5rRcapitalsrSrr6r3rNrWrxrIrwrJrProtatescalebshiftfmar'r$ to_integralrqrurTrUquantize)rrr&r ryrzr|rr~r{r}rxr rr zrrrrrtest_none_argsrs                          0  zUsabilityTest.test_none_argscCs |jj}||dd|d|d||dd|d|d||dd|d|d||dd|d|d||dd|d|d||dd|d|d||d d|d |d||d d|d |d||d d|d |d||d d|d |d||d d|d |d||dd|d|d||dd|d|d||d d|d |d||dd |d|d ||dd |d|d ||d d |d |d ||dd|d|d||d|dd|d|d|d||ddd|d|d|d||dd|d|d|d|ddS)Nrriu'i7rSrErMirrz9.123r@rirC)rrrrr6r7r8r3rNrWrxrIrwrJrMrrPrrQrrrrrrrtest_conversions_from_inta sz'UsabilityTest.test_conversions_from_intN)rrrrrFrMrOrYr[rur{r|r}rrrrrrrrrrrrrrr7is*$* Tg -!/ pr7c@seZdZeZdS)CUsabilityTestNrrrrrr srcs,eZdZeZfddZfddZZS)PyUsabilityTestcs"tt|_tddSNiXsuperrsysget_int_max_str_digits_previous_int_limitset_int_max_str_digitsrrrrr s  zPyUsabilityTest.setUpcst|jtdSrrrrrtearDownrrrrr s zPyUsabilityTest.tearDownrrrrrrr __classcell__rrrrr s rc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)PythonAPItestscCsT|jj}|t|tj|t|tj||dtj| |dtjdSr) rrr issubclassnumbersNumberrZRealrIZassertNotIsInstancerrrrtest_abc s zPythonAPItests.test_abcc CsttjdD]}|jj}tjd}|jtjd<|d}t||}t|}| ||t rt d}t d}t tjd<t||} t tjd<t| } | | t j| | |t tjd<t||} t tjd<t| } | | t j| | |t d }t d }t tjd<t||} t tjd<t| } | | t j| | |t tjd<t||} t tjd<t| } | | t j| | ||tjd<qdS)Nrrz -3.141590000z -3.123e81723)rpickleHIGHEST_PROTOCOLrrrmodulesdumpsloadsrrgrrIrZ DecimalTuple) rprotor savedecimalrrrrr Zsxr>Zsyrrr test_pickle sL                           zPythonAPItests.test_picklecCs|jj}tddD]R}d|d}|t||tt|||}|t}||t||q|t t|d|t t|d|t t|d|t t|ddS) N%0.2fY@rrr3r4) rrrrrr<rrqrrrrrrrrr>rrrtest_int s  zPythonAPItests.test_intcCsl|jj}tddD]T}d|d}|t||tt|||}|t}||t ||qdS)Nrrrr) rrrrrr<rrqrtruncrrrr test_trunc s  zPythonAPItests.test_trunccCs||jj}Gddd|}|t|||d}|t|||t|d||jdd}|||||||t d ||t d ||t d  |t|t dt|d |t|t dt|d |t|t d t|d | t |jd tdD]6}tdtdd}||t ||q@dS)Nc@seZdZddZdS)z1PythonAPItests.test_from_float..MyDecimalcSs d|_dS)Nr )r)r_rrrr sz:PythonAPItests.test_from_float..MyDecimal.__init__Nrrrrrr srr0r1r ls\&5$3| r2r3r4rrr5abcr8r9r:r;)rrrrrrrrrr<rDrArrrrr=)rrrr>Zbigintrrrrrtest_from_float s6      zPythonAPItests.test_from_floatcCs|jj}|jj}|jj}|dtd}||tj|d|dt d}||tj|d|d|gd}| ||jtj|t |dd|t |dd |t |d d dS) Nr)r#r$z3.1415r)r#r%z Decimal('-0')r;z Decimal('1')r%z Decimal('10')) rrr&r{rqrcreate_decimal_from_floatrpirurr)rrr&r{rrrrtest_create_decimal_from_float s8    z-PythonAPItests.test_create_decimal_from_floatcCs|jj}|jj}|jj}|ddd}||d|d|d||dj|dtd|d|j||d j|d |d |}|d }|j||d td}|||ddS)NiiayrRz7.335z.01z7.34r$z7.33Z10e99999Z1e100000rz 0.871831e800Z1e797)rrr$z 8.71E+799)rrr&ryrrrqr)rrr&ryr rrrrr test_quantize6 s( zPythonAPItests.test_quantizecCs|jj}|d}||j|||jd||||d}|t|ttd|t t |dd|t t |dd|t t |dd|t t |d ddS) Nz9.8182731e181273rr#rrealrMimag conjugate __complex__) rrrrrrcomplexr<rrr)rrrrrr test_complexN szPythonAPItests.test_complexcCs,|jj}|jj}|jj}|jj}|jj}|}d|_d|_d|_|}| | |d|d| |d|dd| ||ddd| ||dd| |j ||d|d| |j |||j || | |dj|dd |j ||d j|d| |j |||j || | |dj|d|d |j ||dj|d| |j |||j || |dj|d|d | |dj|dd | |dj|d|d| |dj|d|d| |dj|dd| |dj|dd| |dj|dd| |dj|d|d| |dj|ddd| |j ||dj|d|d| |j |||j || |dj|d|d|d| |dj|d|d|d| |dj|d |d|d | |d!j|d"|d|d#| |d!j|d"|d|d| |dj|d$|d|d%| |j ||dj |d&|d| |j |||j || |d'j!|d(|d|d)| |d*j"|d+|d d,|d-|j t#|dj$|d|j t#|dj%|d|j t#|dj&|d|j t#|dj'|d|j t#|dj(|d|j t#|dj)|d|j t#|dj*|d|j t#|dj+|d||dj,|d| |dj-|d|j t#|dj.|d|j t#|dj/|d|j t#|dj0|d| |d.j1|dd| |dj2|dd| |dj3|dd/| |d0j4|dd0| |d1j5|d2|dd| |d1j6|d2|dd| |d3j7|d2|dd| |d4j8d|dd| |d4j8d|dd| |j ||d4j9d|d| |j |||j || |d4j:d|dd|j t#|j;d5|d|j t#|dj<|d| |d=d|j t#|d$j>|d|j t#|d$j?|d|j t#|dj=d6d|j t#|dj=d6d7Wdn1s0YdS)8Nrrr"r)rrrrrrr!z0.7r4rz-0.9z9.73z1E+1Z9999'z-2000i0rrSz0.06250.2r)rr`rr20.01z0.0101rz-0.3z0.02z-0.03r6rorKZ1e109.99rr9.9z0.9)thirdrr`z7E+1irz0.21Z11rZ01Z23g?r)r)@rrr&r ryr|r#rrrrrrrrrrrrKrLrOrrUrTrRrr6rxrIrwrJrMrrPrrr?r@rArBrDrFrErHrCrGadjustedrradixrr>r5rSr3rNrWrrrrr canonicalr:r;)rrVr&r ryr|Zxcr rrrtest_named_parameters^ s """" z$PythonAPItests.test_named_parametersc Cs|j}|j}|j}|j}|j}|j}|j}|j}|j} |j } |j } | t |t | t ||| t ||| t |t| t ||| t |t| t || | t || | t ||| t || | t || | t ||| t ||| t ||| t | || t | || t | || t |j|| t |j|| t |j|| t |jt| t |j|dSr)rrryFloatOperationrzr|rr~r{r}rxrrArithmeticErrorrZeroDivisionErrorZConversionSyntaxZDivisionImpossibleZDivisionUndefinedZInvalidContext) rrrryrrzr|rr~r{r}rxrrrtest_exception_hierarchy sBz'PythonAPItests.test_exception_hierarchyN) rrrrrrrrrrrrrrrrrr s3  prc@seZdZeZdS)CPythonAPItestsNrrrrrr src@seZdZeZdS)PyPythonAPItestsNrrrrrr src@seZdZddZeddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdNZ*dOdPZ+dQdRZ,dSdTZ-dUdVZ.dWdXZ/dYdZZ0d[d\Z1d]d^Z2d_d`Z3dadbZ4dcddZ5dedfZ6dgdhZ7didjZ8dkdlZ9dmdnZ:dodpZ;dqdrZdwdxZ?dydzZ@d{d|ZAd}d~ZBdS)ContextAPItestsc Cs|jj}|jj}|jj}|jj}|}|ddddddddd}||fD]z}||jd||jt||j d||j d||j d||j dt ||dgt ||d|||gqFdS) N)r#r$rrrr2rr%rA?Brrrr%)rr&ryrzr|rr#r$r'rrrr2r!)rr&ryrzr|r"r r rrrr s&   zContextAPItests.test_none_argscCsrddl}|j}tD]}|||_||j|q|d}|tt |d||d}|tt |d|dS)Nrrr$z ROUND_UP) rrr& RoundingModesrr$rrrr)rrr Zrndrrrrr s    z(ContextAPItests.test_from_legacy_stringscCsttjdD]l}|jj}tjd}|jtjd<|}tt||}| |j |j | |j |j | |j |j | |j |j | |j|j| |j|j| |j|j| |j|jtrttfttfgnttfg}|D]\}}ttD]n\} } tt|D]V\} } tt|D]<\} } tdd} tdd}tdd}td}td}|tjd<|j| ||t| ||t|d| t|d| d}t||}|tjd<t|}|||j| |j | | |j || |j || |j t| | |j|| |j|t||dt|d| t||d t|d| q*qqq|tjd<qdS) NrrrMrrr)r#rrr$rr2rr%rr%)rrrrr&rrrrrr#rrr$rr2rr%rgrrrrr randrangerIr!)rrr&rr r combinationsZdumperloaderZrirfiZtir#rXrWcapsr2rrrrrr sZ           &zContextAPItests.test_picklecCsB|jj}||ddd|ddig||ddddigdS)Nr%r&r;)rr)rrZassertInZ assertNotInrrrrtest_equality_with_other_types] sz.ContextAPItests.test_equality_with_other_typescCs|jj}|jj}|}|}|t|t||t|jt|j|t|jt|jt|j }t|j }| ||| |j|jdSr) rrr&rZr=rrr%rekeysr)rrr&r rZk1Zk2rrr test_copyc s zContextAPItests.test_copycCs"|jj}|}|tt|ddS)NZ_clamp)rr&rrrrr&r rrr test__clampr szContextAPItests.test__clampcCsJ|jj}|jj}|}||d}||d||t|jddSNrro)rrr&rrrrrrr&r rrrrtest_abs} s zContextAPItests.test_abscCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSNrr#)rrr&rhrrrrrrrtest_add szContextAPItests.test_addcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rrrrrrrr test_compare szContextAPItests.test_comparecCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&r6rrrrrrrtest_compare_signal sz#ContextAPItests.test_compare_signalcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&r7rrrrrrrtest_compare_total sz"ContextAPItests.test_compare_totalcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&r8rrrrrrrtest_compare_total_mag sz&ContextAPItests.test_compare_total_magcCsJ|jj}|jj}|}||d}||d||t|jddSr)rrr&r:rrrrrrr test_copy_abs s zContextAPItests.test_copy_abscCsJ|jj}|jj}|}||d}||d||t|jddSr)rrr&r9rrrrrrrtest_copy_decimal s z!ContextAPItests.test_copy_decimalcCsJ|jj}|jj}|}||d}||d||t|jddSr)rrr&r;rrrrrrrtest_copy_negate s z ContextAPItests.test_copy_negatecCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddS)Nrrr#r)rrr&r<rrrrrrrr szContextAPItests.test_copy_signcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSNrrr#r)rrr&rrrrrrrr test_divide szContextAPItests.test_dividecCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&r=rrrrrrrtest_divide_int szContextAPItests.test_divide_intcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rrrrrrrr test_divmod szContextAPItests.test_divmodcCsJ|jj}|jj}|}||d}||d||t|jddSNr%r)rrr&rrrrrrrrtest_exp s zContextAPItests.test_expcCs^|jj}|jj}|}||d|d|d}||ddd||||ddd|||d|dd|||dd|d||||d|dd||t|jddd|t|jddd|t|jddd|t|j|d|dd |t|j|d |d d |t|dj|dd |t|d j|d d dS) Nrrrrr4rrz not a decimalrrgZd;O?)rrr&rrrrrrrrtest_fma s0  zContextAPItests.test_fmacCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&r@rrrrrrrtest_is_finite0 s zContextAPItests.test_is_finitecCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rArrrrrrrtest_is_infinite9 s z ContextAPItests.test_is_infinitecCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rBrrrrrrr test_is_nanB s zContextAPItests.test_is_nancCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rCrrrrrrrtest_is_normalK s zContextAPItests.test_is_normalcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rDrrrrrrr test_is_qnanT s zContextAPItests.test_is_qnancCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rErrrrrrrtest_is_signed] s zContextAPItests.test_is_signedcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rFrrrrrrr test_is_snanf s zContextAPItests.test_is_snancCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rGrrrrrrrtest_is_subnormalo s z!ContextAPItests.test_is_subnormalcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rHrrrrrrr test_is_zerox s zContextAPItests.test_is_zerocCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rrrrrrrrtest_ln s zContextAPItests.test_lncCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rrrrrrrr test_log10 s zContextAPItests.test_log10cCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rrrrrrrr test_logb s zContextAPItests.test_logbcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&r3rrrrrrrtest_logical_and sz ContextAPItests.test_logical_andcCsJ|jj}|jj}|}||d}||d||t|jddS)Nrr)rrr&r>rrrrrrrtest_logical_invert s z#ContextAPItests.test_logical_invertcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rNrrrrrrrtest_logical_or szContextAPItests.test_logical_orcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rWrrrrrrrtest_logical_xor sz ContextAPItests.test_logical_xorcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rxrrrrrrrtest_max szContextAPItests.test_maxcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rIrrrrrrr test_max_mag szContextAPItests.test_max_magcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rwrrrrrrrtest_min szContextAPItests.test_mincCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rJrrrrrrr test_min_mag szContextAPItests.test_min_magcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&Zminusrrrrrrr test_minus s zContextAPItests.test_minuscCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&r'rrrrrrr test_multiply szContextAPItests.test_multiplycCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rKrrrrrrrtest_next_minus s zContextAPItests.test_next_minuscCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rLrrrrrrrtest_next_plus s zContextAPItests.test_next_pluscCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rMrrrrrrrtest_next_toward sz ContextAPItests.test_next_towardcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rOrrrrrrrtest_normalize, s zContextAPItests.test_normalizecCsn|jj}|jj}|}||d||d||d||d||d||ddS)NrSrr)rrr&rr5)rrr&r rrrtest_number_class5 s z!ContextAPItests.test_number_classcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&plusrrrrrrr test_plus> s zContextAPItests.test_pluscCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||||d|d||t|jdd|t|jdd||jddddddS) Nrrr#r#rr!r)modulorEr&)rrr&powerrrrrrrr test_powerG szContextAPItests.test_powercCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rrrrrrrrrU szContextAPItests.test_quantizecCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr& remainderrrrrrrrtest_remaindera szContextAPItests.test_remaindercCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rPrrrrrrrtest_remainder_nearm sz#ContextAPItests.test_remainder_nearcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rrrrrrrr test_rotatey szContextAPItests.test_rotatecCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rRrrrrrrr test_sqrt s zContextAPItests.test_sqrtcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rQrrrrrrrtest_same_quantum sz!ContextAPItests.test_same_quantumcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rrrrrrrr test_scaleb szContextAPItests.test_scalebcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&rrrrrrrr test_shift szContextAPItests.test_shiftcCs|jj}|jj}|}||d|d}||dd||||dd|||d|d||t|jdd|t|jdddSr)rrr&subtractrrrrrrr test_subtract szContextAPItests.test_subtractcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rSrrrrrrrtest_to_eng_string s z"ContextAPItests.test_to_eng_stringcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rVrrrrrrrtest_to_sci_string s z"ContextAPItests.test_to_sci_stringcCsJ|jj}|jj}|}||d}||d||t|jddSr!)rrr&rUrrrrrrrtest_to_integral_exact s z&ContextAPItests.test_to_integral_exactcCs\|jj}|jj}|}||d}||d||t|jd|t|jdddS)Nr%rr)rrr&rTrrrrrrrtest_to_integral_value sz&ContextAPItests.test_to_integral_valueN)Crrrrr rrr rrrrrrrrrrrrrrr r"r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?rArDrrFrGrHrIrJrKrLrNrOrPrQrRrrrrr s =                                                       rc@seZdZeZdS)CContextAPItestsNrrrrrrS srSc@seZdZeZdS)PyContextAPItestsNrrrrrrT srTc@s<eZdZddZddZddZddZd d Zd d Zd S)ContextWithStatementcCsv|jj}|jj}|}|}|}Wdn1s80Y|}|||d|||d|||ddS)N!did not restore context correctlydid not copy the context __enter__ returned wrong context)rrHr r+ assertIsNot)rrHr orig_ctx enter_ctxset_ctx final_ctxrrrtest_localcontext s$z&ContextWithStatement.test_localcontextc Cs|jj}|jj}|jj}|jj}|}|dd}||}|}Wdn1sT0Y|}|||d||j|jd|||d|||ddS)Nrr#rVzdid not set correct contextrWrX)rr&rHr r+rr#rY) rr&rHr rZnew_ctxr[r\r]rrrtest_localcontextarg s  $z)ContextWithStatement.test_localcontextargc Cs|jj}|jj}|jj}|jj}|jj}|jj}|}||dd}|} || j |j || j |j d| j |<d| _ | |j d| || jd|| j |||h} || j |j || j |j | || j|dd|| j ||| j |~ Wdn1s(0Y|| j |~ Wdn1sZ0Y| |j d||j |||j |||j |||j |dS)NrTz0e-999z3.4e200r)rrr&rHr rxr|rrrr%rr=rrrrCr) rrr&rHr rxr|rZr`r"r rrrtest_nested_with_statements s>    ""z0ContextWithStatement.test_nested_with_statementsc Cs|jj}|}~|b}~|:}~|}~Wdn1sD0YWdn1sb0YWdn1s0YWdn1s0YdSrrr rr r"r r!c4rrrtest_with_statements_gc1-sz-ContextWithStatement.test_with_statements_gc1c Cs|jj}|}||h}~||>}~||}~~Wdn1sJ0YWdn1sh0YWdn1s0YWdn1s0YdSrrfrgrrrtest_with_statements_gc29s   z-ContextWithStatement.test_with_statements_gc2c Cs~|jj}|jj}|jj}|jj}|@}~|dd}||||}~||jd~|dd}||~||jd|dd} || ||jd|| ~} ~ || jd~ |dd} || ~ ||jd| } || jd~ Wdn1s0YWdn1s00YWdn1sP0YWdn1sp0YdS)Nrr_rrr)rr&r rHr+rr#) rr&r rHr+r"Zn1r Zn2Zn3r!Zn4rhrrrtest_with_statements_gc3Es<       z-ContextWithStatement.test_with_statements_gc3N) rrrr^rarerirjrkrrrrrU s  #  rUc@seZdZeZdS)CContextWithStatementNrrrrrrlfsrlc@seZdZeZdS)PyContextWithStatementNrrrrrrmhsrmc@s8eZdZddZddZeddZddZd d Zd S) ContextFlagsc sjj}jj}jj}jj}jj}jj}jj}fdd}|dddtggd} | j |dgf| j |dgf| j |d |d gf| j |d |d gf| j |d |d gfg} |g|g|g|g|g|||||gg} | D]\} } | | | }d d | jD}| D]}| |D]}|| |q| | }t|}|D]}||vrB||qB|jtd dd | jD}|jtd ||dd||f||dd||fq qdS)Ncs2jtkr$d|j|<|j|r.|n ||dSNT)rrgrr%Z _raise_error)rflagrrr raise_errorxs    z7ContextFlags.test_flags_irrelevant..raise_errorr"r,r)r#rrr$r%rz100E-425000010rrz 9.87654321cSsg|]\}}|r|qSrrrkrrrrrrz6ContextFlags.test_flags_irrelevant..rcSsg|]\}}|r|qSrrrrrrrrrz=operation produces different answers depending on flags set: zexpected %s, got %s.z9operation raises different flags depending on flags set: zexpected %s, got %s)rrr&r{r}rrxr~r'r4rRrhr'rMrrrOr?rrrr)rrr&r{r}rrxr~rqrZ operationsZflagsetsfnrrr extra_flagsrpZnew_ansZexpected_flagsZ new_flagsrrrtest_flags_irrelevantms\         z"ContextFlags.test_flags_irrelevantcCs2|jj}|jj}|jj}|}||j|j||j|j|j|_||j|j||j|jd|j|<|j|_||j|j||j|ji}||j|||j||j|d||<|||j||j||di}|||j||j|dg}|||j||j|dS)NTFr) rr&r{r}r=rr%rupdate)rr&r{r}r rrrrtest_flag_comparisonss4  z"ContextFlags.test_flag_comparisonscCs|jj}|jj}|jj}|}||j||||dd||j |||| dd||j ||| d}||j |||d||j ||| d}||j |||d||j |d|j|<|| ||d||j ||| ||j d||j ||| d}||j ||| d}||j |Wdn1s0YdS)Ng@T)rrrr rr%rrrrrrrr)rrrr r rrrrtest_float_operationsD        z!ContextFlags.test_float_operationcs8 jj jj} jj jj}d fdd d dd ddd d d d d td tdd fdd }d fdd }|}||Z} |j||dd||ddd|j<||d||dWdn1s*0YdS)NcsN|t||}|kr*|||n||d|jdSro)rrrr+rr)r&rEr rsignalr)rrrr assert_attrs  z7ContextFlags.test_float_comparison..assert_attrrGrHrJrIrr6r"rrr5r3r4csdD]} |||qdD]} |||q d|d d|d d|d d|d d|dd|dd|d d|dddd|dd|dd|ddtdd|ddS) N)rcre)rdrfrgrhrKr0rr2)r<)r rzr )rr{big_dbig_finf_dinf_f neg_inf_d neg_inf_f neg_zero_d neg_zero_fsmall_dsmall_fzero_dzero_frrdoit)s z0ContextFlags.test_float_comparison..doitcs|tddg}t|d|j||r\|tddgntddg}|j|dddfv}|j|dddddiv}|jdS) Nrz100.0rr;rpg$@r&rE)rrerlenrrrsorted)r rzrrE)rrrrrtest_containersGsz;ContextFlags.test_float_comparison..test_containers)rzT)N)N)N)rrr&rr r<rr%)rr&r rrrKr r)rrr{r|r}r~rrrrrrrrrrrtest_float_comparison s6 (     z"ContextFlags.test_float_comparisoncCs|jj}|jj}|jj}|jj}|}||j|||j||d|j|<d|j|<| |j|| |j|dSro) rrr&r{rrrr% clear_trapsr)rrr&r{rrrrrtest_float_operation_defaultfs  z)ContextFlags.test_float_operation_defaultN) rrrrvrxrryrrrrrrrnks B& 5[rnc@seZdZeZdS) CContextFlagsNrrrrrrvsrc@seZdZeZdS)PyContextFlagsNrrrrrrxsrc@s eZdZdZddZddZdS)SpecialContextszTest the context templates.c Cs4|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj } t ||d||||| g| } |j } |j } d} zzFd|_ |_ ||fD],}|||}| ||||j dqWn*ty}z|j} WYd}~n d}~00W| |_ | |_ || | r0| n | |_ | |_ || | r.| 0dS)Nr%i)r BasicContextExtendedContextrHr+ryrzr|rrxr!rZr#rYr Exceptionr)rrrrHr+ryrzr|rrx savecontextZbasic_context_precZextended_context_precextemplater rrrrtest_context_templates~sF     z&SpecialContexts.test_context_templatesc Cs@|jj}|jj}|jj}|jj}|jj}|jj}|jj}|jj}| |j d| |j dt ||d|||g| } |j } d} zzR|} | j } d|_ |} | | j | |||} | | || | j dWn,ty}z|j} WYd}~n d}~00W| |_ || | r<| n| |_ || | r:| 0dS)Nr"r%i)rr.rrrHr+ryrzr|rr#r!rZrYrr)rr.rrrHr+ryrzr|rZdefault_context_precrr Zsaveprecrrrrtest_default_contextsH  z$SpecialContexts.test_default_contextN)rrrrrrrrrrr{s$rc@seZdZeZdS)CSpecialContextsNrrrrrrsrc@seZdZeZdS)PySpecialContextsNrrrrrrsrc@seZdZddZdS)ContextInputValidationc CsB|jj}|jj}|}dD]F}t||d|t||d|tt||d|t t||dqt|dd|t|dd|tt|dd|t t|dd|t t|d d|t t|d d |t t|d d |t t|d dd D]>}|tt||d|tt||d |t t||gdq|t t|dd|t t|dg|t t|di|t t|dddidD]}|t |j |q|t t|d |t t|d |jt |dd|jt |dd|jt|d d|jt|dd|jt |dgd|jt |dgd|jt |dd|jt |dddS)Nr#rrrrrrrrrrr$r"r;rr2rrWrMrr%ryr)r#rrr$rr2rr%rr2rrrQr%rr)rr) rr&r.rZrrrrrrrKeyError __delattr__)rr&r.r r rrrtest_invalid_contextsL   z+ContextInputValidation.test_invalid_contextN)rrrrrrrrrsrc@seZdZeZdS)CContextInputValidationNrrrrrrsrc@seZdZeZdS)PyContextInputValidationNrrrrrrsrc@seZdZddZdS)ContextSubclassingcs|jj}jj}j}j}j}j}j}j }j } Gfddd} } | } dD]} | t | | t | | qh|j t| fiddi| dd} | | jd| | | j|dd |j t| fid d i| tdd } | | jt| | |d d|j t| fiddi| ddd} | | jd| |d|d}| ||d|||||fD]}|| j|qx|j t| fiddi| ddd} | | jd| || j|d|d|jtkr |||fD]}|| j|q|j t| fiddi| d d} | | jd | d}| | |d|j t| fiddi| ddd } | | jd| |d}| t|d!|j t| fid"d i| ||gd#} ||fD]}|| j|q| t!D]}|"| j|q|j t| fid$d i| ||gd%} ||fD]}|| j#|qB| $t!D]}|"| j#|qjdS)&NcseZdZdfdd ZdS)z>ContextSubclassing.test_context_subclassing..MyContextNc s||dur||_|dur&||_|dur4||_|durB||_|durP||_|dur^||_durttrfddt D|_ durttrfddt D|_ dS)Ncsi|]}||vqSrrrrrrr 5rz[ContextSubclassing.test_context_subclassing..MyContext.__init__..csi|]}||vqSrrrrrrr9r) rr#r$rrrr2rJr?rrr%) rr#r$rrrr2rr%r&rrr%rr#s*   zGContextSubclassing.test_context_subclassing..MyContext.__init__)NNNNNNNNrrrrr MyContext"srr#r$rrrr2rr%r#rrr_Z9e2rr$XYZ)r$r#rr"rr)rr#z1e-99z 2.234e-2000rr)rr#Z1e99z 2.234e2000rrZ1E222z1e+222r2rc)r2rz!1.000000000000000000000000000E+99rrr%r)%rrr&rxrzr{r|r}r~rryrrrrr#rrrqr$r@rrhrrrrgrrrVr2rrrrr%r)rrrxrzr{r|r}r~rryrr rr rrzrrrtest_context_subclassings|            z+ContextSubclassing.test_context_subclassingN)rrrrrrrrrsrc@seZdZeZdS)CContextSubclassingNrrrrrrsrc@seZdZeZdS)PyContextSubclassingNrrrrrrsrc@s$eZdZddZddZddZdS)CheckAttributescCs|tjtj|tjtj|tjtj|tjtj|tjdupVtjdu|tjdupptjdu|tj tj |t tt tdS)NTF) rrgrrrrTrUrr/ __version__dirrrrrtest_module_attributessz&CheckAttributes.test_module_attributescCsJddttD}ddttD}|t|t|tdS)NcSs"g|]}d|vs|ds|qS__rrrrrrrrz;CheckAttributes.test_context_attributes..cSs"g|]}d|vs|ds|qSrrrrrrrr)rrgr&rrrerrr rrrtest_context_attributessz'CheckAttributes.test_context_attributescCsNddttdD}ddttdD}|t|t|tdS)NcSs"g|]}d|vs|ds|qSrrrrrrrrz;CheckAttributes.test_decimal_attributes..r"cSs"g|]}d|vs|ds|qSrrrrrrrr)rrgrrrerrrrtest_decimal_attributessz'CheckAttributes.test_decimal_attributesN)rrrrrrrrrrrsrc@steZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZdS)CoveragecCsH|jj}||dd||dd||dddS)NZ 1234e9999i'r2rr3)rrrrrrrr test_adjustedszCoverage.test_adjustedcCsL|jj}|jj}|d}||d|}||d}||ddS)Nr")rrrHrr)rrrHrr rrrtest_canonicals  zCoverage.test_canonicalcCsp|jj}d|_d|_d|_t|_d|_d|_ t |jD]}d|j |<d|j |<q:| }d}|||dS)Nrr,rrFz{Context(prec=425000000, rounding=ROUND_HALF_DOWN, Emin=-425000000, Emax=425000000, capitals=0, clamp=1, flags=[], traps=[]))rr.rZr#rrrsr$rr2rrr%__repr__r)rr r#rrrrrtest_context_reprs   zCoverage.test_context_reprcCsH|jj}|jj}|}d|_d|_d|_|t|dd||ddd||ddd ||dd d||d |d dd| |d d d d|t |dd d d ||d d| |d  d| |d d||dd||dd||dd ||dd||d d||ddd||dd||d|d||d|d||dd||d d||dd d||dd d||dd||d||d||d||d||d||d||dWdn1s0Y|j}d|_d d!}|| }|}||||}|||| |d}|||Wdn1s:0YdS)"Nrrz-10r%7r!rrrrz1.2rrTz1.01rFZ20Z580rrr"z2E+1z-1E+1z+Normalroz1.12345r#rrrsii)!rrr r#rrrrrr+rBpowrrCrGrrrr>rKrLrOr5rUrr?r@rFrErHr:r;r<)rrr r rr rrrrrs^ 2   zCoverage.test_implicit_contextcCs|jj}|jj}|jj}|jj}|}t|dd\}}|||d|||dt|dd\}}||o|d|j |<t|dd\}}||o|d|j |<| t|d|d\}}||o|||j || t|dd \}}|| o2|||j || t|d d \}}||ot|||j |d|j |<| t|d d \}}|| o|||j |o|j |Wdn1s0YdS) NZ 10912837129rZ10901935Z194rrFr3rr ) rrr ryrzrrrrBr%rrrA)rrr ryrzr rr>rrrr sB    zCoverage.test_divmodcCs|jj}|jj}|jj}|jj}|}d|_|||dd|d||j |d|_d|_ d|_ |d|j |<||d|d |d ||j |Wdn1s0YdS) NrrrMrrrFrsrr3) rrr r|r}r#rrrrrrr%)rrr r|r}r rrrrDEs  zCoverage.test_powercCs~|jj}|jj}|jj}|L}d|_d|_d|_d|j|<|d|d}| | Wdn1sp0YdS)NrrFrZ1e1) rrr ryr#rrr%rrrBrrr ryr rrrrrYs zCoverage.test_quantizecCs>|jj}|jj}|}||dd||ddS)Nr#r%)rrrHrrrrrr test_radixfs zCoverage.test_radixcCs0|jj}dD]}|t|d|dtq dS)N)rlrorrrurbrxrzr|r#r)rrr+rrN)rrr rrrrnszCoverage.test_ropcCs|jj}|jj}|}d|_|t|dd|t|dd|t|ddd|t|d d d |t|d d d |t|djd|t|djddWdn1s0YdS)NrArrz9.99e-5rrrz1.23457rr%z 1.2345000000r`z0E+10rrr!) rrr r#rr __round__rr)rrr r rrr test_rounduszCoverage.test_roundcCs |j}|t|jdgdS)Nrv)rr&rrr)rr rrrtest_create_decimals zCoverage.test_create_decimalcCst|jj}|jj}|J}d|_|dddd}|t|d||dWdn1sf0YdS)Nriir%iSrr)rrr r#rrrrrr r rrrrrszCoverage.test_intcCsl|jj}|}d|_dd }||}||| ||}||| ||d}||| dS)Nrsiir)rr&r#r:rr;r<)rr&r rr rrrrs    zCoverage.test_copyN)rrrrrrrr rDrrrrrrrrrrrrs Q)  rc@seZdZeZdS) CCoverageNrrrrrrsrcs,eZdZeZfddZfddZZS) PyCoveragecs"tt|_tddSrrrrrrrs  zPyCoverage.setUpcst|jtdSrrrrrrrs zPyCoverage.tearDownrrrrrrs rc@seZdZdZddZdS)PyFunctionalityz!Extra functionality in decimal.pycCs>tj}tj}gd}|D] \}}}|t||||qdS)N) )z.0erz1e+0)z#.0erz1.e+0)rrr#)z#.0fr1.)r1.1r)z#grr)rr#r#)z#.0gr#r)rrz100%)z#.0%rz100.%)rrr rr)rrr rPrrrrrrtest_py_alternate_formattings  z,PyFunctionality.test_py_alternate_formattingN)rrrrrrrrrrsrc@s8eZdZdZddZddZddZdd Zd d Zd S) PyWhiteboxz White box testing for decimal.pycCstj}tj}|}d|_|d|d}|||d|d|d}|||d|d|d}|d|d }|||d |d |d }|d d |d }d|_|d|d}d|_|dd|d}Wdn1s0YdS)Nr!irz 0.00390625z-0.6z 0.0012885819Z256e7lo z-0.0625rZ152587890625e7ric rZ 152587890625riB)rrr r#rrrrrtest_py_exact_powers"zPyWhitebox.test_py_exact_powercs:tj}tj}tj}|}tddttD|_|||d|d|d|dd4fdd }|j j j j j j |d|d d |d d |d d |d d |dd |dd |dd |dd |d|dd |d|d|d|dd |dd |d|d|d|dd |dd |dd |d|d d |d!d |d"d |d#d |d$d |d%|d&d |d'd |d(|d)|d*d |d+d |d,d |d-|d.d |d/d |d0d |d1|d2|d3dS)5Ncss|]}|dfVqdS)rNrrrrrrrz=PyWhitebox.test_py_immutability_operations..z-25e55z33e+33Fcs|rvtd|djjjjjjjjjjjjn@td|djjjjjjdS)Nzd1.z(d2)z())rr_sign_int_exp)Z operationZuseOtherb1b2rrrrr checkSameDecsz@PyWhitebox.test_py_immutability_operations..checkSameDec__abs__rkTrargrhrercrfrd __float__ryr]__int__ __trunc__rwrq__neg____bool____pos__r{rlrbrrzrxrrr|ro__str__rnrtrrrrxrwrOrrPrQrRrSr)F) rrr.r+rZr(rr%rrrr)rrr.r+r rrrrtest_py_immutability_operationsst                           z*PyWhitebox.test_py_immutability_operationscCs>tj}|d}||}|t|d|t|t|dS)Nrr)rrrrr=rr.rrrtest_py_decimal_id7s zPyWhitebox.test_py_decimal_idcCsTtj}tj}|.}|ddt}||Wdn1sF0YdS)Nrr)rrr Z_rescalerurrBrrrrtest_py_rescale?s zPyWhitebox.test_py_rescalecCs tj}|t|djdtdS)Nz3.1234r)rrrrZ_roundrurrrrtest_py__roundHszPyWhitebox.test_py__roundN) rrrrrrrrrrrrrrs O rc@s4eZdZdZeddZeddZeddZdS) CFunctionalityzExtra functionality in _decimalcCstj}tj}tj}tj}dd}||}||jd||jd||jd|||||}||jd||jd||jd|||||}||jd ||jd ||jd |||| t |d | t |d | t |ddS)NcSs.||jdt||dgt||dgdS)Nrr%r)rr2r!)rrrrr assert_restYsz7CFunctionality.test_c_ieee_context..assert_restr`irdrbrd"iirDri) rg IEEEContext DECIMAL32 DECIMAL64 DECIMAL128rr#rrrrr)rrrrrrr rrrtest_c_ieee_contextQs.   z"CFunctionality.test_c_ieee_contextcCs:tj}|tjtjd}||jtj||jtjdS)Nr)rgr&r/ DecRoundedr_flags_trapsrrrrtest_c_contextuszCFunctionality.test_c_contextcCstjtjtjtjtjtjtjtjtj tj tj tj tj tjtjf}|tjd|tjd|tjd|tjdt|D]\}}||d|>q|tjtjtjBtjBtjBtjBtj Btj B|tjtjtjB|tjtjtj BtjBdS)Nrrlir)rgr/DecConversionSyntaxDecDivisionByZeroDecDivisionImpossibleDecDivisionUndefined DecFpuError DecInexactDecInvalidContextDecInvalidOperationDecMallocErrorDecFloatOperation DecOverflowr DecSubnormal DecUnderflowrrrrZIEEE_CONTEXT_MAX_BITSrDecIEEEInvalidOperationZ DecErrorsZDecTraps)rcondrrrrrtest_constants}sH     zCFunctionality.test_constantsN)rrrrrequires_extra_functionalityrrrrrrrrNs # rc@seZdZdZddZddZddZdd Zd d Zd d Z e ddZ ddZ e ddZ ddZddZddZddZddZe ddZe d d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zeejd,d-eed.d.d/d0d1d2Z d3S)4 CWhiteboxzWhitebox testing for _decimalc Cstj}tj}dd}dd}|`}d|_tdD]@}t||}tdd}||} ||||} || | q2Wdn1s0YdS)Nr%#$i@Brri)rgrr r#rrrr) rrr rrr rr&rErr rrr test_bignums   zCWhitebox.test_bignumcCs|ttjdddS)Nr"r)rrrgrrrrrtest_invalid_constructionsz#CWhitebox.test_invalid_constructioncCsTtj}tj}tj}tj}|||||dWdn1sF0YdS)NZ1e9999999999999999999)rgrryr&r r)rrryr&r rrrtest_c_input_restrictions z"CWhitebox.test_c_input_restrictioncCstj}tj}|}d|_d|_d|_t|_d|_ d|_ t tD]}d|j |<d|j |<q@d|j |<d|j |<|}d}|||dS)Nrr,rrTaQContext(prec=425000000, rounding=ROUND_HALF_DOWN, Emin=-425000000, Emax=425000000, capitals=0, clamp=1, flags=[Clamped, InvalidOperation, DivisionByZero, Inexact, FloatOperation, Overflow, Rounded, Subnormal, Underflow], traps=[Clamped, InvalidOperation, DivisionByZero, Inexact, FloatOperation, Overflow, Rounded, Subnormal, Underflow]))rgr.rrZr#rrrsr$rr2rrr%rr)rr.rr r#rrrrrtest_c_context_reprs"     zCWhitebox.test_c_context_reprc Cstj}tj}tj}tj}tj}tj}tj}tjdk}|} | t | j j dd| t | j j dd| t| j j|| t| j j|| tt| ddg| tt| ddg| t t| dddi| t t| dddi| j } | |=d | d <| t t| d| | t t| d| |r d nd } |r.d nd} dD]} | tt| | | q6| tt| d| |j t|| d|j t|| d|j t|| d|j t|| dd|j t|| dd|j t|| dd|j t|| dd|j t|| dddD]j} | tt| | | d| tt| | | dtjdkr| tt| | | | tt| | | dqtjdkr| tt| d| d| tt| d| d| tt| d| dtjdkrF| tt| dd| tt| dd| tt| dd| tt| dd| tt| dd| tt| dddD]j} | tt| | d| tt| | d| tt| | gd |rJ| tt| | d!| tt| | d"qJ| ttd#t| ttd$t|}| t|d%||dS)&Nri!rrrr%r riprrCrBlNZoiʚ;rrr_rc)rrrr)r#rrrr2win32rrri?ri9rrzwith localcontext("xyz"): passz-with localcontext(context=getcontext()): passr)rgr&ryr|rr rHr+rrrr __setitem__r%r __delitem__rrrZrrplatformrexecrW)rr&ryr|rr rHr+HAVE_CONFIG_64r rint_maxZ gt_max_emaxr Z saved_contextrrrtest_c_context_errorss      zCWhitebox.test_c_context_errorscCs|tjtj|tjtj|tjtj|tjtj|tjtj|tjtj|tj tj |tj tj dSr) r+rgrurrqrprrrtrsr'rvrrrrtest_rounding_strings_internedGsz(CWhitebox.test_rounding_strings_internedc Cstj}tj}tj}tj}tj}tj}tjdk}|}|r=10.10rCrBrz=%d.1)rgrrrrrr)rrrmaxsizerrr test_c_formats  zCWhitebox.test_c_formatcCsftj}tj}tj}|d}||d|t|jd|t|jdd|t|jd||d|t|jd|t|jdd|t|jd|| d|t|j d|t|j dd|t|j d|j}|dt }|||d|d t }|||dd|j |<|||dj t Wdn1sX0YdS)Nr%rrz99999999999999999999999999.9Z100000000000000000000000000Tz999.9) rgrr{r rrrrrTrUrur%)rrr{r rr rrrtest_c_integrals. zCWhitebox.test_c_integralc CsTtj}tj}tj}tj}tj}||dd|t t |ddd|t |dj dd|t |dj d dd|t |d j |d g|t |d j |d ||t |d j |d d |t |d j |d td |T}||t |j|ddd|t |jd|t |jd|t |jdddd|t |j dd dd|t||dd||d d|j|<|||djd|||jdd||j||d|j|<|||djd|||jdd||j|d|j|<d|_||t |d ddWdn1sF0YdS)Nz9.99e10z99.9E+9rrrr"rr rrz 1e-100000r%rr8r!Z200Tri)rgrryrzrHr rrSrrrr5rQrrurr<rr?rrrr%rarrrr#)rrryrzrHr r rrr test_c_funcss\    zCWhitebox.test_c_funcscCstj}tj}|d}dD]0}t||}|jt|dd|jt|dddqdD]0}t||}|jt|dd|jt|dddqN|jt|jdgd|jt|jigd|t|jgg|jt|jdgd|jt|jigd|t|jgg|jt|jdgd|jt|jigd|t|jgg|jt|j dddd|jt|j ddddd|jt|j dgdd|jt|j dgdd |t|j dgg|}|jt|j dddd |jt|j dddd |jt|j dddd dS) NZ 10001111111) rrCrGrrrr>rKrLrOr5rRrSrr) rr6r3rNrxrIrwrJrPrrrrrrr)mod) rgrr&rrrrrTrUrrrC)rrr&rr funcr rrrtest_va_args_exceptions,s:  z!CWhitebox.test_va_args_exceptionscCsL|tjjtjtjBtjBtjBtjB|tj jtjtjBtjBdSr) rrgrrrrrrr/r.rrrrtest_c_context_templatesXsz"CWhitebox.test_c_context_templatesc&s"tj}tj}tj}tj}tj}tj}tj}tj}tj } tj } tj } tj } tj } tj}fdd}|}||jv||jD]}d|j|<q|jD]}|q||jD]\}}|qƈ|j||jdd|jdddt|jjdddt|jt|jt|j}t|j}|j }|!| |_"|j| || |_#|j||!|j}d||<||_|||j||j}d||<||_|||j| tj | tj$| tj%|tj&|tj'|tj(|tj)|tj*|tji }tj+tj,tj-tj.tj tj/tj0g}tt1t}t2|D]V}t2|D]D}t3D]6}t45t1t|}t45t1t|}t46dd}t46d d }t46d d}t46d d } t46d d }!t46d d }"||||||!| t7|t7|d }|j8||j9||j:||j;||j<|!|j=| d }#|D]}$|#||$O}#qj|j"|#d }#|D]}$|#||$O}#q|j#|#qqvqh|D](}%|%|_"|j"|@|||jq|D](}%|%|_#|j#|@|||jqdS) Ncs4|D]*}||kr ||q||qdSr)rr)rzZ signal_dictr#rrrassertIsExclusivelySetysz.assertIsExclusivelySetTrr rrrsirrr)>rgr&r.ryrrzr|r~rr}r{rxr/rrrZrr%rr valuesrOrrrr+rrrrr getsizeofrrrrrrrrrrrrrrrrrrrrrsamplerr?r#r$rrrr2)&rr&r.ryrrzr|r~rr}r{rxr/rrr)r rsrrrZ IntSignalsZIntCondZlimr>rrrr%r#rXrWr2r Zcrrrrrrrtest_c_signal_dictds                       zCWhitebox.test_c_signal_dictcstjzddlm}Wnty2|dYn0dd}dfdd }d |gd d d }d |gd d d }d|gd dd }|dkr|t|d|d|t|d|d|t|d|ddS)NrrrcSsddd|DS)NrcSsg|] }t|qSrrrrrrrrzJCWhitebox.test_invalid_override..make_grouping..)rrrrrrsz6CWhitebox.test_invalid_override..make_groupingrcs|||Sr)rrrarrrsz0CWhitebox.test_invalid_override..get_fmtr)r.rrZxxxxxrrZyyyyyrr)Nr)rgrrrrrrr)rrrrZinvalid_groupingZ invalid_dotZ invalid_seprrartest_invalid_overrides2     zCWhitebox.test_invalid_overridecCstj}tj}tj}|}d|j|<dtj}||||dtj d}||||dtj}||||dtj d}||||Wdn1s0YdS)NTz0e%drz1e%d)rgrr ryr%rr!rrrrrtest_exact_conversions   zCWhitebox.test_exact_conversioncCstj}tj}tj}tj}tj}|}d|j|<d|j|<d|j|<ddtjf}| t | |d| |||ddtjf}| ||j || |||ddtj df}| t | |d| |||ddtj df}| ||j || |||ddtjdf}| t |j || t ||ddtj df}| t |j || t ||d}| t ||d d }| t ||d d }| t ||d Wdn1s0YdS) NTrrz -0E+999999)rrrz -0E-1000007rrr)rrr)rrrz-sNaN1)rgrr ryr|rr%rr!rrrrr)rrr ryr|rr rrrrtest_from_tuple'sB      zCWhitebox.test_from_tuplecCstj}tjdk}||dd|rZ|dd}|dd}|||dn0|dd}|dd}|||d dS) Nrrr%r@ir!r)rgrrr9 __sizeof__r)rrrrr rrr test_sizeofWs zCWhitebox.test_sizeofcsztj}Gdddt}Gdddt}GdddtGfdddt}|||fD] }|||d |d qTdS) Nc@seZdZddZddZdS)z.XcSsdSNrrrrrrrjszMCWhitebox.test_internal_use_of_overridden_methods..X.as_integer_ratiocSs|SrrrrrrrlszDCWhitebox.test_internal_use_of_overridden_methods..X.__abs__NrrrrrrrrrXisr9c@seZdZddZdS)z.YcSs dgdSNrr8rrrrrrpszDCWhitebox.test_internal_use_of_overridden_methods..Y.__abs__N)rrrrrrrrYosr;c@seZdZddZdS)z.IcSs dgdSr:rrrrr bit_lengthtszGCWhitebox.test_internal_use_of_overridden_methods..I.bit_lengthN)rrrr<rrrrIssr=cs eZdZfddZddZdS)z.ZcsddfSr7rrr=rrrxszMCWhitebox.test_internal_use_of_overridden_methods..Z.as_integer_ratiocSs|SrrrrrrrzszDCWhitebox.test_internal_use_of_overridden_methods..Z.__abs__Nr8rr>rrZws r?gfffffFY@)rgrr<rrr)rrr9r;r?rrr>r'test_internal_use_of_overridden_methodsesz1CWhitebox.test_internal_use_of_overridden_methodsZaixzEAIX: default ulimit: test is flaky because of extreme over-allocationT)addressZmemoryzVASAN/MSAN sanitizer defaults to crashing instead of returning NULL for malloc failure.cCs\gd}tj}tj}tj}|tjtjtjd}||||dd||d d||d d||d d||dd d||d  d ||d  d||d  |d |t |ddd||ddd||d dd||dd|dWdn1sN0YdS)N) r>rKrLr3rNrWrMrr)r#rrrrrMrr%l 9VrZ40E9z2.0E+5r)rrirz0.0025)rgrr&r rrTrrrrrrrRr)rZMaxContextSkiprr&r Z maxcontextrrrtest_maxcontext_exact_ariths$ z%CWhitebox.test_maxcontext_exact_arithN)!rrrrr rrrrrr rrrr r"r#r$r'r(r-r0r1r2r6r@rskipIfrrrr rDrrrrr sD e  *& ;,  %0r ztest requires C versionc@s eZdZdZddZddZdS) SignatureTestzFunction signaturesc CsttD]}|drqtt|}tt|}|dksF|dksFt|rt|}t|}t|j }dd|j D}|j ||d|ddd|j D}d d|j D} |d kr|j || d |dqdS) Nrrr&cSsg|]}|ds|qS)rrrrrrrs z5SignatureTest.test_inspect_module..parameter name mismatch in %smsgcSsg|] }|jqSrkindrrrrrrcSs$g|]}|dds|djqS)rrr)rrKrrrrrsr+parameter kind mismatch in %s)rrrrrginspect isfunction signaturer? parametersr rr*rO) rr p_funcc_funcp_sigc_sigc_namesp_namesc_kindp_kindrrrtest_inspect_modules*      z!SignatureTest.test_inspect_modulecstjjtjjttdtdtdtdtdtdtdtdtdtdddtjtdttdtdtdtdtdtdtdddtjtd ifdddd fd d }|d |d dS)Nrr#r;)r`rrr rr&rEr rrBnumrr$r) r`rr&rEr rrBrZrr$rcspg}i}|jD]T\}}|dkr$q|jkrB|||q|jkr^||||<qtdq||fS)Nrzunexpected parameter kind)rPrOrKrr)moduler#rkwargsnameZparam)POSPOS_KWDpdictrrmkargss    z0SignatureTest.test_inspect_types..mkargscSs(|dkr dS|dkrdS|dkr$dS|S)zwThe C Context docstrings use 'x' in order to prevent confusion with the article 'a' in the descriptions.rr&r rErr r)rrrrtrs   z,SignatureTest.test_inspect_types..trc stt|}tt|}t|D]}|dr.qt||}t||}t|rt|}t|}t|j }fdd|j D} j | |d|ddd|j D} dd|j D}  | d | d|d krj | d d| d dd |dnj t| t| d |dt|\} } zt|d || i| Wn&ty~td || | fYn0t|\} } zt|d || i| Wqtytd || | fYq0qdS)Nrcsg|] }|qSrrr)rbrrrrzBSignatureTest.test_inspect_types..doit..rGrHcSsg|] }|jqSrrJrrrrrrcSsg|] }|jqSrrJrrrrrrrrrrLr"zinvalid signature for %s: %s %s)rrrgrrrMrNrOr?rPr rr*r+rrr)tyZp_typeZc_typer rQrRrSrTrVrUrXrWrkwds)r^r_rarrbrrrsH         z.SignatureTest.test_inspect_types..doitrr&) rMZ_ParameterKindZPOSITIONAL_ONLYZPOSITIONAL_OR_KEYWORDrgrrtrHr)rrr)r^r_rar`rrbrtest_inspect_typessF   /z SignatureTest.test_inspect_typesN)rrrrrYrerrrrrFsrFrrc Cstttt|dur|ntda|a|dur6t}nttg}t t D]l}d|vsH| dr`qH| d\}}|dur||vrqH|fdd}ttd||ttd||~~~~qHzt||durdd lm} tjd} trttjd<tt|| d ttjd<tt|| tjd<Wtr0tttttttsPtd tttjdurtd nNtr~tttttttstd tttjdurtd 0dS) z Execute the tests. Runs all arithmetic tests if arith is True or if the "decimal" resource is enabled in regrtest.py Nrz.decTestrcSs|t|Sr)r directory)rrrrrrjrztest_main..Ztest_r)IGNORE_EXCEPTION_DETAIL)Z optionflagsz*C tests skipped: no module named _decimal.zGInternal error: unbalanced number of changes to sys.modules['decimal'].)r-rgrrrr all_testsrroslistdirrfrrrrdoctestrgrrrr+ORIGINAL_CONTEXTwarningswarn UserWarningorig_sys_decimalr) arithverbose todo_testsdebugZ test_classesfilenameheadtailZtesterrgrrrr test_mainOsX          rxz:test_decimal.py [--debug] [{--skip | test1 [test2 [...]]}]z--debugz-d store_truez2shows the test number and context before each test)actionhelpz--skipz-sz%skip over 90% of the arithmetic tests)rqrr)rqrrrsrt)NNNN)rrrirrrmrrZrrrZ test.supportrrrrrrrr r r r rrMr0rrgrrrpZ cfractionsrZ pfractionsrrrHrr r*rxr}r{r~rr|rzryrrr!rurqrprrrtrsr'rvrrlr-Z TESTDATADIRrargvr__file__pathdirnamecurdirZtestdirseprfisdirrrhasattrZEXTRA_FUNCTIONALITYZ skipUnlessr rEZskip_if_extra_functionalityZTestCaser0rrrrSrTrUrrrrrrrrr$r)r*r5r6r7rrrrrrrSrTrUrlrmrnrrrrrrrrrrrrrrrrrrr rFrhinsertrxZoptparseZ OptionParserrZ add_option parse_argsoptrskiprtrrrr s4           eWM)',-/ Xm~ P>m U      7