a 5dg`@sddlmZddlZddlZddlZddlZddlZddlZddl Z ddl Z Gddde j Z Gddde j ZGddde j ZGd d d e j ZGd d d e j Zed kre dS))run_with_localeNc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZeddddZeddddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+S), TypesTestscCsjddis|ddd}Gddd}|}|s<|d|sJ|d tsX|d |sf|d dS) Nxz!{'x': 1} is false instead of truecSsdSNrrr+/usr/local/lib/python3.9/test/test_types.pyfz'TypesTests.test_truth_values..fc@s eZdZdS)z'TypesTests.test_truth_values..CN__name__ __module__ __qualname__rrrrCr rzf is false instead of truezC is false instead of truezsys is false instead of truezx is false instead of true)failsys)selfr rrrrrtest_truth_valuesszTypesTests.test_truth_valuescCs"dsdr|dn |ddS)Nrz0 or 0 is true instead of falserz 1 and 1 is false instead of truerrrrrtest_boolean_ops s zTypesTests.test_boolean_opscCsddkr.testidz1.5ez1.500000e{0:+03d}g;%_nTr*z 1.500000e+100r+gEw;S%Tz 1.500000e+101gj+c4+z 1.500000e-100gUO+z 1.500000e-101%gr1z%#gz1.00000)ranger strformatr,r-)rr/irrrtest_float_to_stringYs zTypesTests.test_float_to_stringc CsNd}d}||ur|dddkr,|dddkr>|dddkrP|dddkrb|dddkst|dd dks|dd \}}}||||||krd ksn|d tj d }dD]R}||}||} | |kr|d||| |ft| tur|dt| qdD]>}||d }||} t| tur(|d| t| fq(tj}dD]>}||d }||} t| turr|d| t| fqrtj} || d td|| d td|| dtdz dd>WntyYn 0|dz dd?Wnty>Yn 0|ddS)Nz256 is not shared$zint opi ii)idi+zint mul commutativityr)rr= z%r * %r == %r != %rz%expected type(prod) to be int, not %rz#expected type(%r) to be int, not %rz*(sys.maxsize + 1) should have returned intz+(-sys.maxsize - 1) should have returned intr>z+(-sys.maxsize - 2) should have returned intr"zint negative shift <>)rrmaxsizetyper(assertIsInstancer) rrrZxsizeZysizeZzsizemZdivisorjprodrrrrtest_normal_integersssj &          zTypesTests.test_normal_integerscCspddkr|dddkr$|dddkr6|dddkrH|dddksZ|dddksl|ddS)NgB@zfloat opg(g(@gBg8@g8rrrrr test_floatss zTypesTests.test_floatscCstddkr|dtddkr,|dtddkrB|d d d krT|d d d krf|d ddkrx|dtddkstddkr|dddvrddvrddvrddvrn |dd}d||dkr|dd}||dd|||dddd||dddd||dddd||dddd ||d!ddd"||d#d$|||d$d#d|ddd||d#d$dddS)%Nrrzlen('')rrzlen('a')Zabcdefz len('abcdef')Zxyzabcdezstring concatenationZ xyzxyzxyzzstring repetition *3zstring repetition 0*rczmin/max stringrdzin/not in stringZgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz%s!!znasty string formatting bug 0123456789r>Z02468Z13579r%Z 9876543210Z97531Z31r0)lenrminmaxr,)rrrrrr test_stringss*""  zTypesTests.test_stringscCs(|ttdd|ttdddddS)Nrr>rQr=)r TypeErrorrDrrrrtest_type_functionszTypesTests.test_type_functioncszfdd}|ddd|ddd|ddd|dd d |d d d |dd d|d d d|ddd|d dd|ddd|d dd|ddd|d dd |ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|d dd |d dd |td!d"dd!|td!d"dd#|td!d" dd$|td!d" dd%|dd&d|d d&d |d'd&d(|d)d&d*|dd&d+|dd&d,|dd-d+|dd-d,|dd.d/|dd.d,|dd0d1|dd0d,|dd2d3|d d2d4|dd2d5|dd2d6|dd7d5|dd7d6|dd8d9|dd8d6|dd:d;|dd:d6|d|d|dd?d@|d d?dA|d dBdC|ddDdE|dFdGdH|dFdIdJ|dKdIdL|d.test[rMZ 123456789rrL-r2r%-1z-3z 1z -1z+3z +1z 3  1rQr3XZ4d2i.z-4d2Z8xz 4d2z -4d2ber@ZBEz-bez-BEoAZ101iz-101Z2322z-2322z-oz oz 2322z+oz+2322rZ11z-11Z 10011010010z -10011010010z-bz bz 10011010010z+bz +10011010010rz#bZ0b0z-#bZ0b1z-0b1z-#5bz -0b1z+#5bz +0b1r0z+#bz +0b1100100z#012bZ 0b0001100100rRz -0b001100100z#oZ0o0z-#oZ0o1z-0o1z-#5oz -0o1z+#5oz +0o1z+#oz+0o144z#012oZ 0o0000000144z -0o000000144z#xZ0x0z-#xZ0x1z-0x1z-#5xz -0x1z+#5xz +0x1z+#xz+0x64z#012xZ 0x0000000064z -0x000000064@Z 0x000001e240iz -0x00001e240z#XZ0X0z-#XZ0X1z-0X1z-#5Xz -0X1z+#5Xz +0X1z+#Xz+0X64z#012XZ 0X0000000064z -0X000000064Z 0X000001E240z -0X00001E240{,Z123iz-123z1,234z-1,234z123,456z-123,456z 1,234,567iy)z -1,234,567z010,z 00,001,234 Ze10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000Ze10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100z1.3z+cz,nz,cz#ccSsg|] }t|qSrchr.0rrrr ar z1TypesTests.test_int__format__..rzcSsg|] }t|qSrrlrnrrrrpbr AZzbcdoxXeEfFgGn%zeEfFgG%)rrr%r0rRIi.i0<20Z123456000000000000001<20Z12345611111111111111*<20z123456**************0>20Z000000000000001234561>20Z11111111111111123456*>20z**************1234560=201=20*=20) r(rrr-rWr3ordr,r )rr/rYvaluerrrtest_int__format__s                                                                                                          zTypesTests.test_int__format__ LC_NUMERICz en_US.UTF8cCs\tddD]L}dd|}|tjd|ddt|d|tjd |ddt|d q dS) NirkgeAg$@r1Tgroupingnz%.10gz.10n)r3r,locale format_stringr5)rr6rrrrtest_float__format__localezs z%TypesTests.test_float__format__localecCsd}tddD]*}|tjd|ddt|d|d}qd }d }d }d D]d}|ttd|tt|||ttd|tt|||ttd|tt||qJdS) Nl ~l!]crz%dTrrrkz>20nz<20nz^20n)rbi90rgrjiNarZrtl4? )r3r,rrr5rS)rrr6ZrfmtZlfmtZcfmtrrrtest_int__format__locales   z#TypesTests.test_int__format__localecs6fdd}|ddd|ddd|ddd |dd d |d d d |dd d|d dd |ddd|ddd|ddd|ddd|ddd|dd d|ddd|ddd|ddd|ddd|ddd|dd d!|dd dd"}d#D]D}||}t|d$|d%d&|dd'd(qd}d#D]D}||}t|d)|d%d&|dd'd(qR|dd*d+|dd*d,|dd-d.|dd-d/|d0d*d1|d0d-d2|d3dd4|d3d5d4|d6dd7|d6d5d7|d8d9d:|d8d;d:|d8dd;d?|d>dd@dA|dBd@dC|dDdEdF|dGdHdI|d8dJdK|d8dLdK|d8dMdN|d>dLdO|d>dMdO|d>dPdQ|dRdSdT|dUdVdW|dUdXdW|dDdXdY|dDdZd[|dd\d]td^jdtd^jd_d`dattdbtdcddDdedattdftdgddDD]}|dhvrltt d|tt d|tt d|tt di|tt dj|tt dk|tt dl|ql|ddmdn|ddodp|ddqd |ddrds|dtd du|dtdvdw|ddxdy|ddzd{|dd|d+|dd}d+|dd~d|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddd|ddddS)Ncs(|||t|||dSr)r,r-r5)r rYr.rrrr/sz-TypesTests.test_float__format__..testrr z0.000000rz0.0g{Gz?z0.01ggGz?r2z1.23gGzz-1.23Z1grz gr_r&r]z+gz+1gϠ#l{wiz 1.1234e+200Gz 1.1234E+200z1.000000z -1.000000z fz 1.000000z+fz +1.000000g3R<=ɥR)r Fbi.r:)Z 112340000000Z 112339999999r*z 1.000000e+00z -1.000000e+00Ez 1.000000E+00z -1.000000E+00gM0k\Dz 1.123400e+20z 1.123400E+20gZbtiz+1e+200+g0l4viz +1.1e+200gH@Z010fz 1234.000000Z011fZ012fz 01234.000000gHz -1234.000000Z013fz -01234.000000g_~Hz -01234.123412g7$z011.2fz -0123456.12g333333?z010,.2z 0,000,001.2z011,fz 1,234.000000z012,fz013,fz 01,234.000000z -1,234.000000z014,fz-01,234.000000gz015,fz-012,345.000000g$z016,fz-0,123,456.000000z017,fz-0,123,456.123412z013,.2fz -0,123,456.12%z -100.000000%g@rcSsg|] }t|qSrrlrnrrrrpr z3TypesTests.test_float__format__..rrqrcSsg|] }t|qSrrlrnrrrrpr rrrszeEfFgGn%g}Ô%ITg}Ô%Ig0.++g0.+z.0ez1e+00z#.0ez1.e+00z.0fz#.0fz1.r'z1.1z#gz1.10000z.0%z100%z#.0%z100.%Z0ez#0eZ0fz#0fz.1ez1.0e+00z#.1ez.1fz1.0z#.1fz.1%z100.0%z#.1%g@ruz12345.60000000000000rvz12345.61111111111111rwz12345.6*************rxz000000000000012345.6ryz111111111111112345.6rzz*************12345.6r{r|r}) r-r,rSassertInrrWr3r~rr5)rr/r fmtr.rYrrrtest_float__format__s                                                                                 zTypesTests.test_float__format__cCsr|ttdddd|ttddddd|ttddddddD]}|ttdd|qTdS) Nrr2i'rMra1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.ZxXobnsri)rrr5)rcoderrrtest_format_spec_errors,s z"TypesTests.test_format_spec_errorscCs |tjd|tjddSNr)Z assertGreaterobject __basicsize__tuple __itemsize__rrrrtest_internal_sizes?szTypesTests.test_internal_sizescCsD|tjtj|tjtj|tjtj|tjtjdSr)rEr__init__typesWrapperDescriptorType__str____lt__r(rrrrtest_slot_wrapper_typesCsz"TypesTests.test_slot_wrapper_typescCsJ|tjtj|tjtj|tjtj|djtjdS)N*)rErrrMethodWrapperTyperrrrrrtest_method_wrapper_typesIsz$TypesTests.test_method_wrapper_typescCsx|tjtj|tjtj|djtj|gjtj|tj dtj |tj tj|tj tjdS)Nr from_bytes) rEr4joinrMethodDescriptorTypelistappendBuiltinMethodTyper(__dict__ClassMethodDescriptorTyper__new__rrrrtest_method_descriptor_typesOsz'TypesTests.test_method_descriptor_typesN)r r rrrrr!r$r)r7rIrJrVrXrrrrrrrrrrrrrrr s0  9*  rc@szeZdZejZddZddZddZddZ d d Z d d Z d dZ ddZ ddZddZddZddZddZdS)MappingProxyTestscCsGdddt}ddd}|||||ddd}||||tddiddi}|||||t|jd|t|jd |t|jd d gdS) Nc@s eZdZdS)z4MappingProxyTests.test_constructor..userdictNr rrrruserdict^srrr>ryrrrk)rrrr)dictr, mappingproxy collectionsChainMaprrW)rrmappingrrrtest_constructor]s  z"MappingProxyTests.test_constructorcCs4tt|ittt}||hddS)N>copy __contains____class_getitem__values__ior____or__items __getitem____len__keys __reversed____ror__get__iter__)setdirrrr,)rattrsrrr test_methodsls zMappingProxyTests.test_methodscCsz|ddd}||dd||dd|t|jd||dd||d||ddddS)NrrBrrrrxxxr)rr,rKeyErrorrr assertIsNonerviewrrrtest_getszMappingProxyTests.test_getcCsGdddt}||dd}||dd||dd||dd||dd||ddd|d|v|d|vdS) Nc@seZdZddZdS)z3MappingProxyTests.test_missing..dictmissingcSsd|S)Nz missing=%srrkeyrrr __missing__sz?MappingProxyTests.test_missing..dictmissing.__missing__N)r r rrrrrr dictmissingsrrrrrz missing=yr)rrr,r assertTrue assertFalse)rrrrrr test_missingszMappingProxyTests.test_missingcCsGdddt}|ddi}||}|d|v|d|v|d|v||dd|t|jd|t|d|t |d || d || dd || dd || d || d||ddS)Nc@sVeZdZddZddZddZddZd d Zd d Zd dZ ddZ dddZ dS)z5MappingProxyTests.test_customdict..customdictcSs|dkr dSt||SdS)NmagicT)rrrrrrrszBMappingProxyTests.test_customdict..customdict.__contains__cSstdS)Niterrrrrrrsz>MappingProxyTests.test_customdict..customdict.__iter__cSsdS)Nrrrrrrsz=MappingProxyTests.test_customdict..customdict.__len__cSsdS)Nrrrrrrrsz:MappingProxyTests.test_customdict..customdict.copycSsdS)Nrrrrrrrsz:MappingProxyTests.test_customdict..customdict.keyscSsdS)Nrrrrrrrsz;MappingProxyTests.test_customdict..customdict.itemscSsdS)Nrrrrrrrsz.customdict.valuescSsdt||S)Nz getitem=%s)rrrrrrrszAMappingProxyTests.test_customdict..customdict.__getitem__NcSsdt||d|S)Nzget=%sz default=%r)rr)rrdefaultrrrrsz9MappingProxyTests.test_customdict..customdict.get)N) r r rrrrrrrrrrrrrr customdictsrrrrrz getitem=valuerrrz get=valuezget=default=Nonerrr)rrrrr,rrrrrSrrrrr)rrZcustomrrrrtest_customdicts   z!MappingProxyTests.test_customdictcCsRddi}ddi}t||}||}|d|v|d|v|d|v||dd||dd|t|jd|t t |d|t |d| }| ||||tj|||||dd||dd||d|t t |d|t t |d|t t |ddS) Nrrrr>rqr))rr)rr>rr>)rrrrrr,rrrrsortedrSrZ assertIsNotrErrrrr)rZd1Zd2rrrrrr test_chainmaps,    zMappingProxyTests.test_chainmapcCsL|td}|d|v|d|v|d|v|d|vdS)NrrrrLr)rrfromkeysrrrrrr test_containss zMappingProxyTests.test_containscCsi}||}|}|}|}|t|g|t|g|t|gd|d<|t|dg|t|dg|t|dgdS)Nrr)rr)rrrrr,r)rrrrrrrrr test_viewss zMappingProxyTests.test_viewscCsNtdD]@}tdd|}|t||||}|t||qdS)NrKZabcde)r3rrr,rSr)rZexpecteddatarrrrtest_lens   zMappingProxyTests.test_lencCsd}d}tt||}|t|}|t|t||t|t||t|t||t|t|dS)Nrr) rziprrr,rrrr)rrrrrrrrtest_iteratorssz MappingProxyTests.test_iteratorscCsNdddddd}||}|d=t|}|t|td|tt|dS) Nrr>rrQr=)rrfoorLrMrZdcba)rreversedr,rr StopIterationnext)rrMmprrrr test_reverseds  zMappingProxyTests.test_reversedcCsfdddd}||}|}|t|t|||d|d<||dd||dddS)N3])key1Zkey2Zkey3Fr)rrr,rDr)rZoriginalrrrrr test_copy s   zMappingProxyTests.test_copycCs4dddd}||}|t|ddgBWdn1sB0Y|tddg|BWdn1sx0Y|t|ddgO}Wdn1s0Yddd}|||Bddddd |||Bddddd ||dddd||dddd||ddddS) Nrrr>)rrrL)rr>)rMr>rQ)rLp)rrrLr)rLrrr)rrrWZassertDictEqualr,)rrrotherrrr test_unions   * * * zMappingProxyTests.test_unionN)r r rrMappingProxyTyperrrrrrrrrrrrrrrrrrrZs 0  rc@seZdZGdddeZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)S)*ClassCreationTestscs<eZdZfddZefddZefddZZS)zClassCreationTests.Metac st|||dSr)superr)clsnamebasesnskw __class__rrr*sz ClassCreationTests.Meta.__init__c st||||Sr)rr)mclsrrrrrrrr,szClassCreationTests.Meta.__new__c s$t||}d|d<|||S)Nrr)r __prepare__update)rrrrrrrrr /s z#ClassCreationTests.Meta.__prepare__) r r rr staticmethodr classmethodr  __classcell__rrrrMeta)s  rcCs,td}||jd||jtfdSNrr new_classr,r __bases__rrrrrrtest_new_class_basics6s z(ClassCreationTests.test_new_class_basicscCs"tdtf}|t|tdSr)rrr(r issubclassrrrrtest_new_class_subclass;sz*ClassCreationTests.test_new_class_subclasscCs`|j}|dd}tdD]B}tdt|d|}|||||jd||jdqdS)Nr> metaclassrqrrr) rr3rrr4rEr,rrq)rrZsettingsr6rrrrtest_new_class_meta?s   z&ClassCreationTests.test_new_class_metacCs^|j}dd}tdd|dd|}|||||jd||jd||jddS) NcSs d|d<dSNrrrrrrrfuncKsz9ClassCreationTests.test_new_class_exec_body..funcrrr>rrr)rrrrEr,rrrqrrrrrrrtest_new_class_exec_bodyIs z+ClassCreationTests.test_new_class_exec_bodycCsBdd}tdttft|dd}||dttfiddifdS)Nc[s ||||fSrr)rrrrrrr meta_funcUszGClassCreationTests.test_new_class_metaclass_keywords..meta_funcrar)rrr)rrr(rrr,)rrresrrr!test_new_class_metaclass_keywordsSs  z4ClassCreationTests.test_new_class_metaclass_keywordscCs2tddid}||jd||jtfdS)Nrrrrrrrtest_new_class_defaults\sz*ClassCreationTests.test_new_class_defaultscCst|j}dd}tjdtft|dd|d}|t|t|||||j d||j d||j ddS) NcSs d|d<dSrrrrrrrdsz>ClassCreationTests.test_new_class_meta_with_base..funcrr>r)rrkwds exec_bodyrr) rrrr(rrrrEr,rrrqrrrrtest_new_class_meta_with_basebs  z0ClassCreationTests.test_new_class_meta_with_basecsnGdddGfddd}|}td|fi}||jf||j|f||j|tfdS)Nc@s eZdZdS)z;ClassCreationTests.test_new_class_with_mro_entry..ANr rrrrrrqr rrcseZdZfddZdS)z;ClassCreationTests.test_new_class_with_mro_entry..CcsfSrrrrrrrr__mro_entries__sszKClassCreationTests.test_new_class_with_mro_entry..C.__mro_entries__Nr r rr(rr'rrrrsrDrrr,r__orig_bases____mro__r)rrrLr*rr'rtest_new_class_with_mro_entrypsz0ClassCreationTests.test_new_class_with_mro_entrycCsGddd}Gddd}Gddd}|}td|||fi}||j||f||j|||f||j|||tfdS)Nc@s eZdZdS)z@ClassCreationTests.test_new_class_with_mro_entry_none..ANr rrrrrr|r rrc@s eZdZdS)z@ClassCreationTests.test_new_class_with_mro_entry_none..BNr rrrrr}r rc@seZdZddZdS)z@ClassCreationTests.test_new_class_with_mro_entry_none..CcSsdSNrrr&rrrr(szPClassCreationTests.test_new_class_with_mro_entry_none..C.__mro_entries__Nr)rrrrr~srr*r+)rrrrrrLr*rrr"test_new_class_with_mro_entry_none{sz5ClassCreationTests.test_new_class_with_mro_entry_nonecsdGdddGfddd}|}|t td|fiWdn1sV0YdS)Nc@s eZdZdS)zAClassCreationTests.test_new_class_with_mro_entry_error..ANr rrrrrrr rrcseZdZfddZdS)zAClassCreationTests.test_new_class_with_mro_entry_error..CcsSrrr&r'rrr(szQClassCreationTests.test_new_class_with_mro_entry_error..C.__mro_entries__Nr)rr'rrrsrr*)rrWrr)rrrLrr'r#test_new_class_with_mro_entry_errors  z6ClassCreationTests.test_new_class_with_mro_entry_errorcsGdddGdddGdddGdddGfd d d }Gfd d d }td ||fi}||jfdS)Nc@s eZdZdS)zEClassCreationTests.test_new_class_with_mro_entry_multiple..A1Nr rrrrA1r r2c@s eZdZdS)zEClassCreationTests.test_new_class_with_mro_entry_multiple..A2Nr rrrrA2r r3c@s eZdZdS)zEClassCreationTests.test_new_class_with_mro_entry_multiple..B1Nr rrrrB1r r4c@s eZdZdS)zEClassCreationTests.test_new_class_with_mro_entry_multiple..B2Nr rrrrB2r r5cseZdZfddZdS)zDClassCreationTests.test_new_class_with_mro_entry_multiple..AcsfSrrr&r2r3rrr(szTClassCreationTests.test_new_class_with_mro_entry_multiple..A.__mro_entries__Nr)rr6rrrrsrrcseZdZfddZdS)zDClassCreationTests.test_new_class_with_mro_entry_multiple..BcsfSrrr&r4r5rrr(szTClassCreationTests.test_new_class_with_mro_entry_multiple..B.__mro_entries__Nr)rr7rrrsrr*rrr,r)rrrrr*r)r2r3r4r5r&test_new_class_with_mro_entry_multiplesz9ClassCreationTests.test_new_class_with_mro_entry_multiplec sGdddGdddGdddGdddGd d d Gfd d d }Gfd dd}Gddd}td|||fi}||j|fdS)Nc@s eZdZdS)zGClassCreationTests.test_new_class_with_mro_entry_multiple_2..A1Nr rrrrr2r r2c@s eZdZdS)zGClassCreationTests.test_new_class_with_mro_entry_multiple_2..A2Nr rrrrr3r r3c@s eZdZdS)zGClassCreationTests.test_new_class_with_mro_entry_multiple_2..A3Nr rrrrA3r r:c@s eZdZdS)zGClassCreationTests.test_new_class_with_mro_entry_multiple_2..B1Nr rrrrr4r r4c@s eZdZdS)zGClassCreationTests.test_new_class_with_mro_entry_multiple_2..B2Nr rrrrr5r r5cseZdZfddZdS)zFClassCreationTests.test_new_class_with_mro_entry_multiple_2..Acs fSrrr&r2r3r:rrr(szVClassCreationTests.test_new_class_with_mro_entry_multiple_2..A.__mro_entries__Nr)rr;rrrrsrrcseZdZfddZdS)zFClassCreationTests.test_new_class_with_mro_entry_multiple_2..BcsfSrrr&r7rrr(szVClassCreationTests.test_new_class_with_mro_entry_multiple_2..B.__mro_entries__Nr)rr7rrrsrc@s eZdZdS)zFClassCreationTests.test_new_class_with_mro_entry_multiple_2..CNr rrrrrr rr*r8)rrrrrr*r)r2r3r:r4r5r(test_new_class_with_mro_entry_multiple_2sz;ClassCreationTests.test_new_class_with_mro_entry_multiple_2csiGfdddt}tdtf}tdtfd|i}td||fdti\}}}||||||t|ddS)Ncs eZdZddZfddZdS)z0ClassCreationTests.test_prepare_class..Ac_stj|i|Sr)rDrargskwargsrrrrsz8ClassCreationTests.test_prepare_class..A.__new__csSrrr>Z expected_nsrrr sz.A.__prepare__N)r r rrr rrArrrrsrrrrrr*r)rDrrr prepare_classassertIsr,rS)rrrrrmetarr#rrArtest_prepare_classs  z%ClassCreationTests.test_prepare_classcCsGdddt}|td"Gddd|d}Wdn1sD0YGddd}|td$Gd d d |d}Wdn1s0YdS) Nc@seZdZeddZdS)8ClassCreationTests.test_bad___prepare__..BadMetacWsdSrrr@rrrr sDClassCreationTests.test_bad___prepare__..BadMeta.__prepare__Nr r rr r rrrrBadMetasrIz>^BadMeta\.__prepare__\(\) must return a mapping, not NoneType$c@s eZdZdS)z4ClassCreationTests.test_bad___prepare__..FooNr rrrrFoosrJrc@seZdZeddZdS)rFcWsdSrrr@rrrr srGNrHrrrrrIszB^\.__prepare__\(\) must return a mapping, not NoneType$c@s eZdZdS)z4ClassCreationTests.test_bad___prepare__..BarNr rrrrBarsrL)rDassertRaisesRegexrW)rrIrJrLrrrtest_bad___prepare__s0z'ClassCreationTests.test_bad___prepare__c sGdddGddd}Gfddd}|}|tdd|t|ff|t|f|f|t|f|f|t|ff|t|fff}|f}|f}||f}||||fD]}|t||qdS)Nc@s eZdZdS)z0ClassCreationTests.test_resolve_bases..ANr rrrrrrr rrc@s eZdZdS)z0ClassCreationTests.test_resolve_bases..BNr rrrrrr rcseZdZfddZdS)z0ClassCreationTests.test_resolve_bases..Ccs|vr dSfSr/rr&r'rrr(sz@ClassCreationTests.test_resolve_bases..C.__mro_entries__Nr)rr'rrrsrr)r,r resolve_basesrC) rrrrLrrrqtrrr'rtest_resolve_basess  z%ClassCreationTests.test_resolve_basesc sbgGfdddt}Gfddd|}tddd|i}|dgtddd|i}|ddgtd ||f}|ddg|d |jtd ||f}|ddg|d |jtd |fdti}|ddg|d |jtd |fd|i}|ddg|d |jdS)Ncs*eZdZfddZeddZZS)z;ClassCreationTests.test_metaclass_derivation..AMetacsdt||||S)NAMetarrrrrrrr new_callsrrrs zCClassCreationTests.test_metaclass_derivation..AMeta.__new__cSsiSrrrrrrrrr szGClassCreationTests.test_metaclass_derivation..AMeta.__prepare__r r rrr r r rrVrrrRsrRcs.eZdZfddZefddZZS)z;ClassCreationTests.test_metaclass_derivation..BMetacsdt||||S)NBMetarSrTrUrrrs zCClassCreationTests.test_metaclass_derivation..BMeta.__new__cst||}d|d<|S)NTBMeta_was_here)rr rTrrrr szGClassCreationTests.test_metaclass_derivation..BMeta.__prepare__rXrrYrrrZsrZrrrrrrr[C2r*r)rDrrr,clearrr) rrRrZrrrrr\r*rrrYrtest_metaclass_derivations2 z,ClassCreationTests.test_metaclass_derivationcsGddd|jd}tfdd}tddd|i}td tfd|i}td |fd|i}||||||dS) Nc@s eZdZdS)z>ClassCreationTests.test_metaclass_override_function..ANr rrrrrr'srrrKcsSrrr=Zmarkerrrr+szAClassCreationTests.test_metaclass_override_function..funcrarrYrs)rrrrrC)rrrrrar`rsrr_r test_metaclass_override_function$s   z3ClassCreationTests.test_metaclass_override_functionc s*ggGfddd}Gfddd|}tddd|i}||t||dg|dgtddd|i}||t||ddg|ddgtd ||f}||t||ddg|ddgtd ||f}||t||ddg|ddg|t$td |fdti}Wdn1s0Ytd |fd|i}||t||ddg|ddgtd t|f} ||t| |ddg|ddgtd|tf} ||t| |ddg|ddg|t"td|t f} Wdn1s0Y|t"tdt |f} Wdn1s0YdS)Ncs.eZdZfddZefddZZS)zEClassCreationTests.test_metaclass_override_callable..ANotMetacsdt|SNANotMetarSrr>r?rUrrr;s zMClassCreationTests.test_metaclass_override_callable..ANotMeta.__new__csdiSrb)rrW) prepare_callsrrr >s zQClassCreationTests.test_metaclass_override_callable..ANotMeta.__prepare__rXrrVrerrrc:srccs0eZdZfddZefddZZS)zEClassCreationTests.test_metaclass_override_callable..BNotMetacsdt|SNBNotMetarSrdrUrrrDs zMClassCreationTests.test_metaclass_override_callable..BNotMeta.__new__csdt||Srg)rrr rW)rrerrr Gs zQClassCreationTests.test_metaclass_override_callable..BNotMeta.__prepare__rXrrfrrrhCsrhrrrrrrr\r*rrF2ra) rrrCrDr,r]rrWrr() rrcrhrrrrr\r*rrrirarrfr test_metaclass_override_callable5sh   4 2 z3ClassCreationTests.test_metaclass_override_callablecCsd}|tdtGdddt}|t}|dWdn1sL0Y|t|j|Gdddt|d}|t}|dWdn1s0Y|t|j|dS)Nz2type.__new__() takes exactly 3 arguments (1 given)r"c@s eZdZdS)z4ClassCreationTests.test_one_argument_type..MNr rrrrMsrkc@s eZdZdS)z4ClassCreationTests.test_one_argument_type..NNr rrrrNsrlrK)rCrDr(rrWr,r4 exception)rZexpected_messagerkcmrlrrrtest_one_argument_types & &z)ClassCreationTests.test_one_argument_typeN)r r rrDrrrrrr!r"r%r.r0r1r9r<rErNrQr^rarjrorrrrr's(       6Trc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdS) SimpleNamespaceTestscCst}tjddd}tjfitddd}|ttdddWdn1s\0Y|t$tjfiddiWdn1s0Y|t|jd|t|i|t|jd|t|ddd|t|jd|t|ddddS)Nrr>rrQrrr) rSimpleNamespacerrrWr,rSrvarsrns1ns2ns3rrrrs , 2z%SimpleNamespaceTests.test_constructorcCs@tt}ttjddd}||i||ddddS)Nrr>rrq)rsrrrr,rrurvrrr test_unbounds  z!SimpleNamespaceTests.test_unboundcCsft}tjddd}tjddd}|j}~||ji||jddd||tddddS)Nrr>rTFrrq)rrrrr,r)rrurvrwrrrrtest_underlying_dictsz)SimpleNamespaceTests.test_underlying_dictcCsntjdddd}||jd||jd||jd|t|jWdn1s`0YdS)Nrr>rQrrw) rrrr,rrr|rAttributeErrorrqrrrrr test_attrgets  z!SimpleNamespaceTests.test_attrgetc Csft}tjdddd}d|_d|_d|_d|_||jtddd||jtdddddd dS) Nrr>rQr{spamhamr=r)rrr|rqtheta) rrrrrrqrr,rrrxrrr test_attrsetsz!SimpleNamespaceTests.test_attrsetcCst}tjdddd}|t|`Wdn1s<0Y|t|`Wdn1sj0Y|`|t|tdddd|_|t|tdddd|`|t|tdddd|_|t|tdd |`|t|idS) Nrr>rQr{)r|rr)r|rrr"r) rrrrr}rrr,rsrrxrrr test_attrdels  " "z!SimpleNamespaceTests.test_attrdelcCs\tjdddd}t}d|_d|_d}|t|dj|d |t|d j|d dS) Nrr>rQr{rr" namespacez{name}(x=1, y=2, w=3)rz{name}(x='spam', _y=5))rrrrZ_yr,reprr5)rrurvrrrr test_reprszSimpleNamespaceTests.test_reprcCsNtjdd}t}d|_|tt|||||tdS)Nrr)rrrrr,ZassertNotEqualrxrrr test_equals   zSimpleNamespaceTests.test_equalcCstjddd}t}tj|d}||_d|_||_|t|tddd|t|t|dd||j||t|t|d||jjddS)Nrr>rr?)rr) rrrrrr,rsrrrrtrrr test_nesteds z SimpleNamespaceTests.test_nestedcCstjdd}t}tjdd}||_||_||_||j|||jj|||jj|j||j|||j|||jj|dS)NcookierLrr)rrrrr,rtrrrtest_recursive s  z#SimpleNamespaceTests.test_recursivecCsrtjdd}t}tjdd}||_||_||_d}dj|d}dj|d}|t|||t||dS) Nrrrrrz${name}(c='cookie', spam={name}(...))rz*{name}(spam={name}(x=1, spam={name}(...))))rrrrr5r,r)rrurvrwrrepr1Zrepr2rrrtest_recursive_reprs    z(SimpleNamespaceTests.test_recursive_reprcCstjdd}|tt|Wdn1s40Y|tt|Wdn1sf0Y|td|vWdn1s0Y|t|dWdn1s0YdS)NZ spamspamspamrr)rrrrrWrSrr~rrr test_as_dict(s  & & & z!SimpleNamespaceTests.test_as_dictcCsHGdddtj}|ddd}|t|||t|ddddS)Nc@s eZdZdS)z0SimpleNamespaceTests.test_subclass..SpamNr rrrrSpam5srr? )rZeggs)rrrrCrDr,rs)rrrrrr test_subclass4s z"SimpleNamespaceTests.test_subclassc Cstjddd}ttjdD]f}d|}zt||}Wn.tyh}zt||WYd}~n d}~00t|}| |||qdS)Nr)Z breakfastZlunchrz protocol {}) rrrr3pickleHIGHEST_PROTOCOLr5dumpsrWloadsr,)rrprotocolZpnameZ ns_pickledr*Z ns_roundtriprrr test_pickle=s   z SimpleNamespaceTests.test_picklecCsGdddt}|t|k|t|k|tt|kWdn1sf0Y|tt|kWdn1s0Y|tt|kWdn1s0Y|tt|kWdn1s0YdS)Nc@seZdZejZdS)zMSimpleNamespaceTests.test_fake_namespace_compare..FakeSimpleNamespaceN)r r rrrrrrrrrFakeSimpleNamespaceMsr)r4rrrrrrrW)rrrrrtest_fake_namespace_compareJs , , , z0SimpleNamespaceTests.test_fake_namespace_compareN)r r rrryrzrrrrrrrrrrrrrrrrrps        rpc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)CoroutineTestsc CsPddtg}|D]:}|tdt|Wdq1s@0YqdS)Nrz#types.coroutine.*expects a callable)rrMrWr coroutine)rZsamplessamplerrrtest_wrong_args\s  zCoroutineTests.test_wrong_argscsltjdd}||dGddd}|tjfdd}||t|}||dS)NcSsdSNrrrrrrrdsz/CoroutineTests.test_non_gen_values..foorc@seZdZddZdS)z5CoroutineTests.test_non_gen_values..AwaitablecSsdSr/rrrrr __await__jsz?CoroutineTests.test_non_gen_values..Awaitable.__await__N)r r rrrrrr AwaitableisrcsSrrrZawrrrms)rrr,rC)rrrrrrtest_non_gen_valuescs  z"CoroutineTests.test_non_gen_valuescsdd}|j}|jj}t|}|||||jj|||j||fdd}tdD]8}t|}|}||||jj||qddS)NcsdSrrrrrrrzr z*CoroutineTests.test_async_def..foocsSrrrZfoo_cororrbarr z*CoroutineTests.test_async_def..barr>) __code__co_flagsrrrCr,r3cr_codeclose)rrZfoo_codeZ foo_flagsZ decorated_foor_cororrrtest_async_defvs      zCoroutineTests.test_async_defcsJGddd}|tjfdd}||||dS)Nc@s,eZdZddZddZddZddZd S) z/CoroutineTests.test_duck_coro..CoroLikecSsdSrrrrrrsendr z4CoroutineTests.test_duck_coro..CoroLike.sendcSsdSrrrrrrthrowr z5CoroutineTests.test_duck_coro..CoroLike.throwcSsdSrrrrrrrr z5CoroutineTests.test_duck_coro..CoroLike.closecSs|Srrrrrrrr z9CoroutineTests.test_duck_coro..CoroLike.__await__N)r r rrrrrrrrrCoroLikesrcsSrrrrrrrsz*CoroutineTests.test_duck_coro..foorrrCr)rrrrrrtest_duck_coros zCoroutineTests.test_duck_corocsJGddd}|tjfdd}||||dS)Nc@s<eZdZddZddZddZddZd d Zd d Zd S)z5CoroutineTests.test_duck_corogen..CoroGenLikecSsdSrrrrrrrr z:CoroutineTests.test_duck_corogen..CoroGenLike.sendcSsdSrrrrrrrr z;CoroutineTests.test_duck_corogen..CoroGenLike.throwcSsdSrrrrrrrr z;CoroutineTests.test_duck_corogen..CoroGenLike.closecSs|Srrrrrrrr z?CoroutineTests.test_duck_corogen..CoroGenLike.__await__cSs|Srrrrrrrr z>CoroutineTests.test_duck_corogen..CoroGenLike.__iter__cSsdSrrrrrr__next__r z>CoroutineTests.test_duck_corogen..CoroGenLike.__next__N) r r rrrrrrrrrrr CoroGenLikes rcsSrrrrrrrsz-CoroutineTests.test_duck_corogen..foor)rrrrrrtest_duck_corogens z CoroutineTests.test_duck_corogenc sGddd}tj|dd_d_d_|tjj | t t j fdd}||t j| | t |tjj|tjj| jj| jjd D]:}|tt|Wdq1s 0Yqt_t_t_t_| jj| jj| jj| jj| jj| jj| jj| jjj d j d !t"j#!$d d d j$d d d !$d d j$d d !$d j$d !t%}|j$_&z$d Wn2t%y}z| ||WYd}~nd}~00|'d !|t($Wdn1s0Y|)j$j*|t(d Wdn1s60Y|)jj*|t( Wdn1sx0Y|)j j*t j fdd}| |t+,}| |dS)Nc@s4eZdZddZddZddZddZd d Zd S) z-CoroutineTests.test_duck_gen..GenLikecSsdSrrrrrrrr z2CoroutineTests.test_duck_gen..GenLike.sendcSsdSrrrrrrrr z3CoroutineTests.test_duck_gen..GenLike.throwcSsdSrrrrrrrr z3CoroutineTests.test_duck_gen..GenLike.closecSsdSrrrrrrrr z6CoroutineTests.test_duck_gen..GenLike.__iter__cSsdSrrrrrrrr z6CoroutineTests.test_duck_gen..GenLike.__next__N)r r rrrrrrrrrrGenLikes rcSs|Srrgenrrrr z.CoroutineTests.test_duck_gen..rztest.gencsSrrrrrrrsz)CoroutineTests.test_duck_gen..foo>cr_frame gi_yieldfromrgi_framecr_await gi_running cr_runninggi_coderr>rQz&wrapper did not propagate an exceptioncsSrrr)wrapperrrr sz)CoroutineTests.test_duck_gen..bar)-unittestZmockZ MagicMockrr rrErr GeneratorrCrrr_GeneratorWrapperr Coroutinerrr}getattrrrrrrrrrrrZassert_called_once_withrZ reset_mockrrr ExceptionZ side_effectrrWrZcalledweakrefref)rrrrerrorexrrr)rrr test_duck_gens   ,       "  ( * ( zCoroutineTests.test_duck_genc sGdddtjfdd}||tjfdd}|}||ddz|dWn6ty}z||jd d WYd}~nd}~00|d dS) Nc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)z:CoroutineTests.test_duck_functional_gen..GeneratorzEmulates the following generator (very clumsy): def gen(fut): result = yield fut return result * 2 cSsd|_||_dSr)_i_fut)rZfutrrrrszCCoroutineTests.test_duck_functional_gen..Generator.__init__cSs|SrrrrrrrszCCoroutineTests.test_duck_functional_gen..Generator.__iter__cSs |dSr)rrrrrrszCCoroutineTests.test_duck_functional_gen..Generator.__next__c Ssxzb|jdkr.|dusJ|jW|jd7_S|jdkrDt|d|jdkrRtW|jd7_n|jd7_0dS)Nrrr>)rrr)rvrrrr!s     z?CoroutineTests.test_duck_functional_gen..Generator.sendcWsd|_|tur|dSNr0)r GeneratorExit)rtpexcrrrr,sz@CoroutineTests.test_duck_functional_gen..Generator.throwcSs|tdSr)rrrrrrr0sz@CoroutineTests.test_duck_functional_gen..Generator.closeN) r r r__doc__rrrrrrrrrrrs rcsdSrrr)rrrr3sz4CoroutineTests.test_duck_functional_gen..foocsIdHdSrrr)rrrcorofunc9sz9CoroutineTests.test_duck_functional_gen..corofuncrrzStopIteration was expected) rrrErr,rrr>r)rrrrrr)rrrtest_duck_functional_gens  (z'CoroutineTests.test_duck_functional_gencsFdd}|tjfdd}|}||tj||dD]}|t||t|qH||jj| t |d| | dd| t d| dWdn1s0Y||}| d| td  |ttd Wdn1s0Yt|}||dS) Ncss dVdVS)Nrr>rrrrrgen_funcFsz)CoroutineTests.test_gen..gen_funccsSrrrrrrrJsz$CoroutineTests.test_gen..foo)r rrrrrr>rr)rrrErrCrrrrr,rrrMrrr)rrrrrrrrtest_genEs.( 0 zCoroutineTests.test_gencsPtjdd}|tjfdd}||t|}||dS)Ncss dVdSrrrrrrrfsz3CoroutineTests.test_returning_itercoro..gencsSrrrZgencororrrlsz3CoroutineTests.test_returning_itercoro..foo)rrrC)rrrrrrtest_returning_itercoroes  z&CoroutineTests.test_returning_itercorocCsdd}|t|||tt||||jjtj@||jjtj @|}||j jtj@||j jtj @|t||dS)Ncss dVdSrrrrrrrwr z(CoroutineTests.test_genfunc..gen) rCrrrrrinspectZCO_ITERABLE_COROUTINErZ CO_COROUTINEr)rrrrrr test_genfuncvszCoroutineTests.test_genfunccsdddtjfdd}|}|dt||t|t||tt| hddS)Ncss dVdSrrrrrrrsz/CoroutineTests.test_wrapper_object..gencsSrrrrrrrsz0CoroutineTests.test_wrapper_object..coroZGeneratorWrapper> rrrrrrrrrrrr) rrrrr,r4rrr issuperset)rrrrrrtest_wrapper_objectsz"CoroutineTests.test_wrapper_objectN)r r rrrrrrrrrrrrrrrrr[si3 r__main__)Z test.supportrcollections.abcrrrrrrZ unittest.mockrrZTestCaserrrrprr mainrrrrs2 QNw@;