a ze}@sddlZddlZddlZddlZddlZddlmZmZddlZddl Z ddl Z ddl Z ddl m Z ddlmZmZejddgdZejddgdZejd d ZGd d d ZGd ddee jZGddde jZdD]Zeeeeeeq[e edGdddee jZGdddeZ GdddeZ!Gdddej"Z#e edGdddej"Z$Gdddej"Z%e edGdd d ej"Z&e'd!kre (dS)"N) randrangeshuffle)MutableMapping) mapping_testssupport collections _collections)Zblocked)Zfreshc cs:tj|}|tj|<zdVW|tj|<n |tj|<0dSN)sysmodules)nameZ replacementZoriginal_moduler J/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_ordered_dict.pyreplaced_modules   rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1e2j3d_d`Z4daS)bOrderedDictTestscCs^|j}|t|ddgdWdn1s40Ygd}|t|t|||t|fit|||t||||t|gdddd||t|dd d g|t|dd d g|t|d|t|d d |t|j|gd}|jddgddd|t|gddS)Nabrrcderr)r rrr rr*self)r&r$other)r(r$r rrr)r,)r7rfrgrrrrrrr,)r1r/) OrderedDict assertRaises TypeError assertEqualsorteddictitemslist__init__)r&r3pairsrr r r test_inits, ,"  zOrderedDictTests.test_initcCsD|j}gd}t|||}|fi|}|t||dS)Nr2)r3rr6r:r9)r&r3r9Zargdictrr r rtest_4687s zOrderedDictTests.test_468cCs|j}|t"|ddgdWdn1s80Ygd}|}|t||t|||}|jfit||t|||}|||t|||}|jgdddd|t|||}|jdd |t|d g|}|jid |t|d ifg|}|jdd ddd|tt|gd|gd}|jddgddd|t|gd|t|jd|t|jdd|t|j|t|jd|t|jdd|t|jdS)Nrrrr!rr r#r%)r&r?r'r(r.r/)redbluer(r&))rBr.)r(r/)rAr )r&r@r)rr,rr0r2r$r ) r3r4r5updater8r6r7r9r:)r&r3r<odrr r r test_update?sL 0    zOrderedDictTests.test_updatecs4gGfddd}|||dgdS)Ncs$eZdZfddZfddZdS)z.OrderedDictTests.test_init_calls..SpamcsddS)Nkeysr appendr%Zcallsr rrFps z3OrderedDictTests.test_init_calls..Spam.keyscsddS)Nr9r rGr%rIr rr9ss z4OrderedDictTests.test_init_calls..Spam.itemsN)__name__ __module__ __qualname__rFr9r rIr rSpamos rMrF)r3r6)r&rMr rIrtest_init_callsms z OrderedDictTests.test_init_callscCs|j}|d}|t|dddD|jddd}|t|dddD|jddd}|t|dddDdS)NabccSsg|] }|dfqSr r .0rr r r }z2OrderedDictTests.test_fromkeys..valuecSsg|] }|dfqSr r rPr r rrRrSrcSsg|] }|dfqSrr rPr r rrRrS)r3fromkeysr6r:r9r&r3rDr r r test_fromkeyszs zOrderedDictTests.test_fromkeyscCs(|j}||t|t|tdSr )r3assertIsInstancer assertTrue issubclass)r&r3r r rtest_abcszOrderedDictTests.test_abccCsN|j}gd}t|||}|t|t|||t|ddSN)rrr)rrrrr,r)r3rr6lenclearr&r3r<rDr r r test_clearszOrderedDictTests.test_clearcCs|j}gd}||}|d=|d||t|d=Wdn1sN0Y|t||dd|dddS)Nr_rrr)r3 assertNotInr4KeyErrorr6r:r9rbr r r test_delitems  $zOrderedDictTests.test_delitemcCs>|j}|gd}d|d<d|d<|t|gddS)N)rrrrrrr rr-)rgr)rrirhr)r-rjr3r6r:r9rXr r r test_setitems zOrderedDictTests.test_setitemcCs|j}gd}t|||}|t|dd|D|t|dd|D|t|dd|D|t|||tt|ddt|D|tt|ddt|D|tt|ddt|D|tt|tt|dS) Nr_cSsg|] }|dqSrVr rQtr r rrRrSz3OrderedDictTests.test_iterators..cSsg|] }|dqSrVr rmr r rrRrScSsg|] }|dqSrr rmr r rrRrScSsg|] }|dqSrVr rmr r rrRrScSsg|] }|dqSrVr rmr r rrRrScSsg|] }|dqSror rmr r rrRrS)r3rr6r:rFvaluesr9reversedrbr r rtest_iteratorss$zOrderedDictTests.test_iteratorscCs\|j}|d}t|}t|}||=|tt|Wdn1sN0YdS)NrO)r3rWiternextr4 Exception)r&r3rDitkeyr r r%test_detect_deletion_during_iterations  z6OrderedDictTests.test_detect_deletion_during_iterationcCs|j}|t|ddgdWdn1s40Ygd}||}|t|dd|D|t|dd|D|t|dd|D|t|||tt|tddt|DdS) NrrrcSsg|] }|dqSrVr rmr r rrRrSz:OrderedDictTests.test_sorted_iterators..cSsg|] }|dqSrVr rmr r rrRrScSsg|] }|dqSror rmr r rrRrScSsg|] }|dqSrVr rmr r rrRrS) r3r4r5r6r7rFrpr9rqrbr r rtest_sorted_iteratorss ,z&OrderedDictTests.test_sorted_iteratorscCs|j}|}g}|t|||t|||t|||t|||tt|||tt|||tt|||tt||dSr )r3r6r:rFrpr9rq)r&r3rDemptyr r rtest_iterators_emptysz%OrderedDictTests.test_iterators_emptycCs~|j}gd}t|||}|r8|||q|t|Wdn1s`0Y|t|ddSr^)r3rr6popitempopr4rer`rbr r r test_popitems &zOrderedDictTests.test_popitemcCsb|j}ddtdD}||}tdD]}|dq(|d|jdd|t|ddS)NcSsg|] }||fqSr r rQir r rrRrSz6OrderedDictTests.test_popitem_last..r@TZlastrj)r3ranger|r6r`)r&r3r<objrr r rtest_popitem_lasts    z"OrderedDictTests.test_popitem_lastcCsH|j}gd}t|||}t||rJ|\}}||||q&|t|dWdn1st0Y|t|d|||ddGddd|}|dd}||d d d ||d d d||d d d ||jd d d d |t|d Wdn1s:0YdS)Nr_Zxyzri90c@seZdZddZdS)z*OrderedDictTests.test_pop..MissingcSsdSNrr r&rwr r r __missing__sz6OrderedDictTests.test_pop..Missing.__missing__NrJrKrLrr r r rMissingsrrrrr rr.default)r3rr}r6r4rer`)r&r3r<rDkvrmr r rtest_pops(  (  zOrderedDictTests.test_popcCs|j}gd}t|||}||}||||dd|dd}||}|||||t||t||||||dddS)Nr_r)r3rr6ZassertNotEqualr8)r&r3r<Zod1Zod2r r r test_equality s  zOrderedDictTests.test_equalityc sj}gd}||fdd}||t|ttdjfttjdD]F}j|d&|t t |Wdqh1s0YqhWdn1s0Y|t t |}| ||||dS)Nr_csnd|f}|||t|tt|tt|tdS)Nz copy: %s od: %s) assertIsNotr6r:r9r`type)dupmsgrDr&r rchecks   z,OrderedDictTests.test_copying..checkrr)proto)r3copydeepcopyrmodulerpickleHIGHEST_PROTOCOLsubTestloadsdumpsevalreprrC)r&r3r<rrZ update_testr rr test_copyings  T zOrderedDictTests.test_copyingcCs:|j}gd}||}|tdd|dDdS)Nr_css|]}t|tkVqdSr )rr:)rQZpairr r r <rSz5OrderedDictTests.test_yaml_linkage..r)r3r[all __reduce__rbr r rtest_yaml_linkage4sz"OrderedDictTests.test_yaml_linkagecCsj|j}gd}||}||jt||dd|_||jdd||dddidS)Nr_rrix)r3rZ__dict__r8 assertIsNonerrr6rbr r rtest_reduce_not_too_fat>sz(OrderedDictTests.test_reduce_not_too_fatcCs|j}|}||d<td|jjtdtjdD]H}tt||}|||| t | dg| |d|q2Wdn1s0YdS)Nrrr) r3rrrrrrrrr6r:rFassertIs)r&r3rDrrr r rtest_pickle_recursiveIs z&OrderedDictTests.test_pickle_recursivecCsL|j}|gd}|t|d|tt|||t|ddS)Nr_zIOrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])z OrderedDict())r3r6rrrXr r r test_reprVs  zOrderedDictTests.test_reprcCs,|j}|d}||d<|t|ddS)NrOrz@OrderedDict([('a', None), ('b', None), ('c', None), ('x', ...)]))r3rWr6rrXr r rtest_repr_recursive^s   z$OrderedDictTests.test_repr_recursivecCsP|j}|}||d<t|}||t||d<t|}||tdS)Nr$)r3rprrZstrr9)r&r3rDrr r rtest_repr_recursive_valuesfs   z+OrderedDictTests.test_repr_recursive_valuescCs|j}gd}t|||}t|}||ddd|t||||ddd|t|dd||jdd d d Gd d d |}||d d d dS)Nr_rrirrr)rrir1r"rc@seZdZddZdS)z1OrderedDictTests.test_setdefault..MissingcSsdSrr rr r rrsz=OrderedDictTests.test_setdefault..Missing.__missing__Nrr r r rrsrr )r3rr:r9r6 setdefault)r&r3r<rDZ pair_orderrr r rtest_setdefaultts z OrderedDictTests.test_setdefaultcCs\|j}|}d|d<d|d<|d=|t|dgd|d<|t|ddgdS)NrrrrrrrkrXr r r test_reinsertszOrderedDictTests.test_reinsertcCs2|j}|d}|t|td|d|t|td|dd|t|td|dd|t|td|d|t|td|jddd|t|td |t|d Wdn1s0Y|t|d dWdn1s$0YdS) NabcderZabdecFZcabderrrZbcader)r3rWr6r: move_to_endr4rerXr r rtest_move_to_ends"      ( z!OrderedDictTests.test_move_to_endcCs|j}|d}|jddd|t|td|jddd|t|td|d}|d|t|td|d|t|td dS) NrOrFrZcabrZacbZbcaZbac)r3rWrr6r:rXr r rtest_move_to_end_issue25406s    z,OrderedDictTests.test_move_to_end_issue25406cCs:|j}tdd}|fi|}|t|t|dS)Nrr)r3r8Z assertGreaterr getsizeof)r&r3rrDr r r test_sizeofs zOrderedDictTests.test_sizeofcCsL|j}d}||}||t|||t|dS)Nz@the quick brown fox jumped over a lazy dog yesterday before dawn)r3splitrWr6rFr8r9)r&r3srDr r r test_viewss  zOrderedDictTests.test_viewscCs:|j}Gddd|}gd}|t|||dS)Nc@seZdZddZdS)z3OrderedDictTests.test_override_update..MyODc_s tdSr )ru)r&argskwdsr r rrCsz:OrderedDictTests.test_override_update..MyOD.updateN)rJrKrLrCr r r rMyODsr)rrrrk)r&r3rr9r r rtest_override_updatesz%OrderedDictTests.test_override_updatecCs4|j}d}tdD]}|d|fg}q~tdS)Ni)r3rr gc_collect)r&r3r_r r rtest_highly_nesteds  z#OrderedDictTests.test_highly_nestedcsj|j}gGfddd|}d}tdD]}|d|fg}||_q*~t|tttddS)NcseZdZfddZdS)z:OrderedDictTests.test_highly_nested_subclass..MyODcs|jdSr )rHrr%Zdeletedr r__del__szBOrderedDictTests.test_highly_nested_subclass..MyOD.__del__N)rJrKrLrr rr rrsrd)r3rrrrr6r:rq)r&r3rrrr rrtest_highly_nested_subclasss z,OrderedDictTests.test_highly_nested_subclassc Cs|j}Gddd}dd}d}||}||}|||}|}d||<d||<d||<d|d<||=||=|t||dfdgdS) Nc@s,eZdZddZddZddZddZd S) z9OrderedDictTests.test_delitem_hash_collision..KeycSs||_tt||_dSr )_hashridrU)r&hashr r rr;szBOrderedDictTests.test_delitem_hash_collision..Key.__init__cSs|jSr )rr%r r r__hash__szBOrderedDictTests.test_delitem_hash_collision..Key.__hash__cSs(z|j|jkWSty"YdS0dS)NF)rUAttributeError)r&r(r r r__eq__s z@OrderedDictTests.test_delitem_hash_collision..Key.__eq__cSs|jSr rTr%r r r__repr__szBOrderedDictTests.test_delitem_hash_collision..Key.__repr__N)rJrKrLr;rrrr r r rKeysrcSs$d}||d@}|d>||dS)Nr@rrr )rZMINSIZErr r r blocking_hashs zCOrderedDictTests.test_delitem_hash_collision..blocking_hashr.after)r.rk) r&r3rrZ COLLIDINGrwZ collidingblockingrDr r rtest_delitem_hash_collisions z,OrderedDictTests.test_delitem_hash_collisioncCs |j}Gddd}|}tdD]}|}|||<q"|tt|Wdn1sb0Y|tt|Wdn1s0Y|tt|Wdn1s0Y|t|Wdn1s0YdS)Nc@seZdZddZdS)z-OrderedDictTests.test_issue24347..KeycSstdS)Ni)rr%r r rrsz6OrderedDictTests.test_issue24347..Key.__hash__NrJrKrLrr r r rrsrr) r3rr4rer:rpr9rr)r&r3rrDrrwr r rtest_issue24347s   * * & z OrderedDictTests.test_issue24347cCs0|j}Gddd}|}d||<|dS)Nc@seZdZddZdS)z-OrderedDictTests.test_issue24348..KeycSsdS)Nrr r%r r rr*sz6OrderedDictTests.test_issue24348..Key.__hash__Nrr r r rr)srr)r3r|)r&r3rrDr r rtest_issue24348&s  z OrderedDictTests.test_issue24348cCsL|j}|}dD]6}dD],}t|dkr4|jdd||}|||<qqdS)NZ0123456789ABCDEFrFr)r3r`r|)r&r3rDZc0c1rwr r rtest_issue246672s   z OrderedDictTests.test_issue24667cCs.|j}|}t|dd|dt|dSNspamrNULL)r3r8 __setitem__rdrrXr r rtest_dict_setitemKsz"OrderedDictTests.test_dict_setitemcCs^|j}|}d|d<d|d<t|d|tt|Wdn1sP0YdSNrrrham)r3r8 __delitem__r4rerrXr r rtest_dict_delitemQs  z"OrderedDictTests.test_dict_delitemcCs:|j}|}d|d<d|d<t||dt|dS)Nrrrrr)r3r8rardrrXr r rtest_dict_clearZs  z OrderedDictTests.test_dict_clearcCs^|j}|}d|d<d|d<t|d|tt|Wdn1sP0YdSr)r3r8r}r4rerrXr r r test_dict_popbs  zOrderedDictTests.test_dict_popcCs\|j}|}d|d<d|d<t||tt|Wdn1sN0YdSr)r3r8r|r4rerrXr r rtest_dict_popitemks  z"OrderedDictTests.test_dict_popitemcCs.|j}|}t|dd|dt|dSr)r3r8rrdrrXr r rtest_dict_setdefaulttsz%OrderedDictTests.test_dict_setdefaultcCs.|j}|}t|dg|dt|dS)N)rrr)r3r8rCrdrrXr r rtest_dict_updatezsz!OrderedDictTests.test_dict_updatecsF|jGfddd}d|j|<t|}~t||dS)NcseZdZZdS)z/OrderedDictTests.test_reference_loop..AN)rJrKrLrDr r3r rAsr)r3rDweakrefrefgccollectr)r&rrr rrtest_reference_loops  z$OrderedDictTests.test_reference_loopcCsPt|t|jt|dd|jt|dd|jt|dd|jdS)NcSs t|Sr )rsrFrr r rrSz.cSs t|Sr )rsrprr r rrrScSs t|Sr )rsr9rr r rrrS)rZcheck_free_after_iteratingrsr3r%r r rtest_free_after_iteratingsz*OrderedDictTests.test_free_after_iteratingcCs^|j}|dddd}|dddd}|}|}||O}|t|O}|ddddd}||t|B||||B||||||||}||O}|ddddd}|t||B||||B|||||t||B||tt||B||t|t|B||}|d O}|d O}||||t |dBWdn1s0Y|t |d BWdn1s0Y|t |d BWdn1s0Y|t |d BWdn1s0Y|t |d O}Wdn1sP0YdS) Nrr)rrrrr)rrr)rrrr)rrrrr ZBAD) r3rr:r9r6r8rrr4r5 ValueError)r&r3rrrrexpectedr r rtest_merge_operatorsF     ( ( ( ( z$OrderedDictTests.test_merge_operatorcCs6t|dgi}t|tt|dSr )rsr3r9rrr[Z is_trackedrt)r&rvr r r!test_ordered_dict_items_result_gcsz2OrderedDictTests.test_ordered_dict_items_result_gcN)5rJrKrLr=r>rErNrYr]rcrfrlrrrxryr{r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr cpython_onlyrr r r rrsb.               '     +rc@seZdZeZejZdS)PurePythonOrderedDictTestsNrJrKrLpy_collrr3r r r rrsrc@seZdZeZeZdS)CPythonBuiltinDictTestsN)rJrKrLbuiltinsrr8r3r r r rrsrztest_init test_update test_abc test_clear test_delitem test_setitem test_detect_deletion_during_iteration test_popitem test_reinsert test_override_update test_highly_nested test_highly_nested_subclass test_delitem_hash_collision z0requires the C version of the collections modulec@sHeZdZeZejZejZejddZ ddZ ddZ ejddZ d S) CPythonOrderedDictTestsc Cs||j}tj}tj}|j}|d|d}|d}|d}|d}|} || |dd|d| _|| |dd|| d d td D|| |d|dd|d || d d td d D|| |d|dd |d ||| |d|| |d|| |d|d} |t | | |t | | |t | | |t | | dS)NZ nQ2P3PnPn2PZ2nP2nZn2PPZPn2Pr@r rcSsg|] }||fqSr r rr r rrRrSz=CPythonOrderedDictTests.test_sizeof_exact..rcSsg|] }||fqSr r rr r rrRrSriZiP2n2P) r3structcalcsizerZ calcobjsize check_sizeofrrCrrFr9rprs) r&r3rsizerZ basicsizeZ entrysizepZnodesizerDZitersizer r rtest_sizeof_exacts0&&z)CPythonOrderedDictTests.test_sizeof_exactcCs|j}|d}|t|td|t8t|D]\}}||||dq8Wdn1sl0Y|t"|D] }d|d<qWdn1s0Y|t |D] }|d=qWdn1s0Y|t|tddS)Nrr r-rZbdeaf) r3rWr6r:r4 RuntimeError enumeraterZ assertLess)r&r3rDrrr r r test_key_change_during_iterations   , ( &z8CPythonOrderedDictTests.test_key_change_during_iterationc Cs|j}gd}||}dD]}t||}t|dd}ttjdD]z}|j||dXt|}t|t ||} t | } | t| || t||WdqH1s0YqHqdS)Nr_)rFrpr9r) method_nameprotocol) r3getattrr:rrrrrsrtrrr6) r&r3r<rDr methrrrvrZ unpickledr r rtest_iterators_picklings    z/CPythonOrderedDictTests.test_iterators_picklingcCsJt|}||_g}||t|}||~~~tdSr )rrr3cyclerHrr)r&rrZx_refr r r"test_weakref_list_is_not_traversed*s   z:CPythonOrderedDictTests.test_weakref_list_is_not_traversedN) rJrKrLc_collrr3rrrrr rrr r r rrs rc@s"eZdZeZGdddejZdS)"PurePythonOrderedDictSubclassTestsc@s eZdZdS)z.PurePythonOrderedDictSubclassTests.OrderedDictNrJrKrLr r r rr3Bsr3Nrr r r rr?src@s"eZdZeZGdddejZdS)CPythonOrderedDictSubclassTestsc@s eZdZdS)z+CPythonOrderedDictSubclassTests.OrderedDictNrr r r rr3Isr3N)rJrKrLrrr3r r r rrFsrc@s eZdZeddZddZdS)PurePythonGeneralMappingTestscCs tj|_dSr rr3 type2testclsr r r setUpClassOsz(PurePythonGeneralMappingTests.setUpClasscCs|}|t|jdSr Z_empty_mappingr4rer|r&rr r rr~Ssz*PurePythonGeneralMappingTests.test_popitemNrJrKrL classmethodrr~r r r rrMs rc@s eZdZeddZddZdS)CPythonGeneralMappingTestscCs tj|_dSr rr3rrr r rr[sz%CPythonGeneralMappingTests.setUpClasscCs|}|t|jdSr rrr r rr~_sz'CPythonGeneralMappingTests.test_popitemNrr r r rr!Xs r!c@s eZdZeddZddZdS)PurePythonSubclassMappingTestscCsGdddtj}||_dS)Nc@s eZdZdS)z@PurePythonSubclassMappingTests.setUpClass..MyOrderedDictNrr r r r MyOrderedDicthsr$rrr$r r rrfsz)PurePythonSubclassMappingTests.setUpClasscCs|}|t|jdSr rrr r rr~lsz+PurePythonSubclassMappingTests.test_popitemNrr r r rr#ds r#c@s eZdZeddZddZdS)CPythonSubclassMappingTestscCsGdddtj}||_dS)Nc@s eZdZdS)z=CPythonSubclassMappingTests.setUpClass..MyOrderedDictNrr r r rr$vsr$r"r%r r rrtsz&CPythonSubclassMappingTests.setUpClasscCs|}|t|jdSr rrr r rr~zsz(CPythonSubclassMappingTests.test_popitemNrr r r rr&qs r&__main__))r contextlibrrrrandomrrrr Zunittestrcollections.abcrtestrrZimport_fresh_modulerrcontextmanagerrrZTestCaserrrmethodsetattrrZ skipUnlessrrrZBasicTestMappingProtocolrr!r#r&rJmainr r r rsN  0   ]