a ze5D@sRddlZddlZddlmZddlmZmZddlmZm Z Gdddej Z dS)N) cmp_to_key)support seq_tests) ALWAYS_EQNEVER_EQcseZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zfd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zfd/d0Zfd1d2Zd3d4Zd5d6Zd7d8ZZS)9 CommonTestcCs||g||gd}||||g|gd}|gd|||gd||}|t|t||||dS)N)) assertEqual type2test__init__ZassertNotEqualidselfabrC/opt/bitninja-python-dojo/embedded/lib/python3.9/test/list_tests.py test_inits zCommonTest.test_initcCs@g}d}|t||dWdn1s20YdS)N'list indices must be integers or slicesrassertRaisesRegex TypeErrorrrmsgrrrtest_getitem_error"szCommonTest.test_getitem_errorcCs@g}d}|t|d|d<Wdn1s20YdS)Nrpythonrrrrrrtest_setitem_error(szCommonTest.test_setitem_errorcCsg}gd}||}||}|t|t||t|t||t|t||t|d|t|d|||d|t|d|t|ddS)Nrr r z [0, 1, 2]r z[0, 1, 2, [...], 3])rrstrreprappend)rZl0l2Za0a2rrr test_repr.s    zCommonTest.test_reprcCs>|g}ttdD]}||g}q|tt|dS)Nd)rrangesysgetrecursionlimit assertRaisesRecursionErrorr%)rrirrrtest_repr_deep?s zCommonTest.test_repr_deepc Cs|td}|||tdd|||dzttjd}|t|Wdn1sn0Yttjd$}| | t |Wdn1s0YWt tjnt tj0dS)Niwr)rr+r&extendopenrZTESTFNwriter$rreadr%osremove)rdforrr test_printEs   ,4zCommonTest.test_printcCs|td}|t|jtdddgd|t|jtddd|t|jtdddddg|t|jddgd|tddd<|||gd dS) Nr rr r xr )rr r r r r rr r? ) rr+r. ValueError __setitem__slicer __getitem__rrrrrrtest_set_subscriptSszCommonTest.test_set_subscriptc Csx|td}t|}|t||tddd|tt||tt|||tt tgddS)Nr>rKr) rr+reversedrlistr. StopIterationnextrlen)rrr4rrr test_reversed^szCommonTest.test_reversedcCs|ddg}d|d<d|d<|||ddgd|d<|||ddgd|d<|||ddg|t|jdd|t|jdd|g}|t|jdd|t|jdd|t|j|gd }d|d<d|d<d |d<|||gd d |d<d |d<d|d<|||gdd|d<d|d<|||gdd|d<d|d<|||gdd}|t|d|d<Wdn1s0YdS)Nrr r*r2rRr rr r r r r )r r r r r r rrA)r rrAr r Xc)r rrAr\r]rB)r rrAr^rBrr!r)rrr. IndexErrorrMrrrrrr test_setitemhs@ zCommonTest.test_setitemcCs|ddg}|d=||dg|d=||g|ddg}|d=||dg|d=||g|ddg}|t|jd|t|jd|g}|t|jd|t|jdS)Nrr rYrRrZr )rrr.r_ __delitem__rrPrrr test_delitems    zCommonTest.test_delitemcCsHddg}||}tddD]}|d||d|<||||dd}|d||d|<|||||d||d<||||dd}||d||d<|||tddD]P}||||||<||||dd}||||||<|||qq|dd}ddg|dd<||gdg|dd<||g|gd}||dd<|||gd |gd}||dd<|||gd |gd}||dd<|||gd |g}ttd |dd<|||td |t|jtddd |t|jdS)Nrr rZr rYrR)rYrRrr )r r r r r )r r r r r r )r r r r r r )r r r r r r r r?r )rr+rtupler.rrMrN)rlrr0r(jZaa2rrr test_setslicesL                zCommonTest.test_setslicecCs|ddg}|dd=|dd=|||g|ddg}|dd=|dd=|||g|ddg}|dd=|||dg|ddg}|dd=|||dg|ddg}|dd=|dd=|||g|ddg}|dd=|dd=|||g|ddg}|dd=|||dg|ddg}|dd=|||dg|ddg}|dd=|||gdS)Nrr r rYrR)rrrPrrr test_delslices>             zCommonTest.test_delslicecCsP|g}|d|d|d|||gd|t|jdS)Nrr r r#)rr&rr.rrPrrr test_appends     zCommonTest.test_appendcCs|dg}|d}|dd}||||||||g|||||||||gd|d}|d||td|t|jd|t|jGddd}|gd }||||gd dS) Nr)rr )rrr rrr spameggsspameggsc@s$eZdZddZddZddZdS)z*CommonTest.test_extend..CustomItercSs|SNrrrrr__iter__sz3CommonTest.test_extend..CustomIter.__iter__cSstdSrl)rUrmrrr__next__sz3CommonTest.test_extend..CustomIter.__next__cSstjSrl)r,maxsizermrrr__length_hint__sz:CommonTest.test_extend..CustomIter.__length_hint__N)__name__ __module__ __qualname__rnrorqrrrr CustomItersru)r r r r )rr5rrTr.r)rZa1r(rrurrr test_extends$        zCommonTest.test_extendcCs|gd}|dd|dd|dd||gd|dd}|dd|d d |d d |||gd |t|jdS)Nr#rrYr rRr rYrRrrr r fooi8leftr2right) ryrYrRrrrxr r rz)rinsertrr.rrrrr test_insert$s       zCommonTest.test_insertcCs|gd}|||ddg|d||dg|t|jd|d||g|t|j|t|jdd|gd}dS)N)rRrr rRrr *)rr?r>()rpoprr.r_rrPrrrtest_pop3s   zCommonTest.test_popcs&|gd}|d||ddg|d||dg|d||g|t|jd|t|j|ddg}|t|jt||ddg|t||dg|tg}|d||g|tg}|t||g|tg}|t|jtGdddtGfddd}|gd }||j|Gfd d d }|d }|d |||d|d |||d|t|jd |||d|dd|d g}||}||jd t ||D]\}}| ||q dS)N)rrr r rr c@s eZdZdS)z&CommonTest.test_remove..BadExcN)rrrsrtrrrrBadExc[srcseZdZfddZdS)z&CommonTest.test_remove..BadCmpcs|dkrdS)Nr Frrotherrrr__eq___sz-CommonTest.test_remove..BadCmp.__eq__NrrrsrtrrrrrBadCmp^sr)rr r r cseZdZfddZdS)z'CommonTest.test_remove..BadCmp2cs dSrlrrrrrrhsz.CommonTest.test_remove..BadCmp2.__eq__NrrrrrBadCmp2gsrZ abcdefghcijcZ abdefghcijZ abdefghijrr) rr:rr.rLrrr ExceptionzipassertIs)rrrrr;er@yrrr test_remove@sN                zCommonTest.test_removecst|gdd|tjddd||gdGddd|fdd td Ddd<|tjddS) Nrwrr r rYrRrr r c@seZdZddZddZdS)z&CommonTest.test_index..EvilCmpcSs ||_dSrlvictim)rrrrrrsz/CommonTest.test_index..EvilCmp.__init__cSs|jdd=dS)NFrrrrrrs z-CommonTest.test_index..EvilCmp.__eq__N)rrrsrtrrrrrrEvilCmpsrcsg|] }qSrr).0_rrrr z)CommonTest.test_index..r*) super test_indexrr:r.rLindexrr+rm __class__rrr{s   zCommonTest.test_indexcCsZ|gd}|dd}|||gd|||||t|jddS)Nrr r rrRrYr})rreverserr.rruu2rrr test_reverses  zCommonTest.test_reversecCs|gd}|||g|g}|||g|g}|d||d||dg|t|jddS)N)r r r r r )rclearrr&r.rrrrrr test_clears      zCommonTest.test_clearcCs|gd}|}||gd|g}|}||g|ddg}|}|d||ddg|||dg|ddddgd g}|}|||||d|d|t|jddS) Nrrrr0r r r r r )rcopyrr&rr.r)rrvrrr test_copys     zCommonTest.test_copycs|ddg}|||ddg|gd}||||gd|t|jdddd}|jt|d|||gdd d }|td jt|d|tjd fd d}|jtjt|d|tjdddddS)Nr rrrr}cSs ||kr dS||krdSdSdS)Nrr rRr)rrrrrrevcmps z$CommonTest.test_sort..revcmp)keycSs2|d|d}}||krdS||kr*dSdSdS)Nr rArrRr r)r@rZxmodZymodrrr myComparisons z*CommonTest.test_sort..myComparisonrDr cs*d||krdS||kr"dSdSdS)Nr rrR)r&)r@rzrrselfmodifyingComparisons  z5CommonTest.test_sort..selfmodifyingComparison)rsortrr.rrr+rL)rrrrrrrr test_sorts&  zCommonTest.test_sortcCs*|d}d|dd<||tddS)Nrihr Zham)rrrTrrrr test_slices  zCommonTest.test_slicecslt|ddg}|}|ddg7}||||d}|d7}|||d|t|jddS)Nrr r r rirjrk)r test_iaddrrrr.r__iadd__rrrrrs    zCommonTest.test_iaddcs8t|g}t|}|d9}|t||dS)Nr?)r test_imulrrr)rsZoldidrrrrs   zCommonTest.test_imulcCs@|gd}|ddd=|||ddg|td}|ddd=|||gd|td}|ddd=|||gd|td }|ddd =|||gd |td }d gd|ddd<|||gd |td }d gd|ddd<|||gd|td}||ddd <|||gd|td }|dd}|dd}|ddg|dd<|ddg|tdd<|ddg|dd<|||||||td }ttd|ddd<|||gd|td }|dddd>=dS)Nr[r r r r )rr r rY)rr r r r?i) r r r r r rrAr^rBrR) rRr rRr rRr rRrArRrB) rr?r r r r?rrAr^r?r )r r r rZtwoelements) rr r r r r r rAr rBrBiM)rrr+rNrc)rrrrrrrtest_extendedslicing sD        zCommonTest.test_extendedslicingcCs$Gdddt}|tt|dS)Nc@seZdZddZdS)z9CommonTest.test_constructor_exception_handling..FcSstdSrl)KeyboardInterruptrmrrrrn6szBCommonTest.test_constructor_exception_handling..F.__iter__N)rrrsrtrnrrrrF5sr)objectr.rrT)rrrrr#test_constructor_exception_handling3sz.CommonTest.test_constructor_exception_handlingcCsv|gd}t|}t|}|D] }t|q"|d|t|g|t|dg|||gddS)NrrB)r r r rB)riterrVr&rrT)rrZexhitZempitr@rrrtest_exhausted_iterator:s  z"CommonTest.test_exhausted_iterator) rrrsrtrr r"r)r1r=rQrXr`rbrfrgrhrvr|rrrrrrrrrrrrr __classcell__rrrrr s8  %.) ! ;  0 )r) r,r9 functoolsrtestrrZ test.supportrrrrrrrs