a ze_@sJddlZddlZddlZddlmZejddgdZejddgdZGdddZGd d d e Z Gd d d Z Gd ddZ Gddde ej ZeedGddde ej ZGdddZGdddeej ZeedGdddeej ZeedGdddeej ZeedGdddeej ZedkrFedS)N)supportoperator _operator)Zblocked)Zfreshc@s<eZdZddZddZddZddZd d Zd d Zd S)Seq1cCs ||_dSNlstselfrr F/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_operator.py__init__ sz Seq1.__init__cCs t|jSrlenrr r r r __len__ sz Seq1.__len__cCs |j|Srrr ir r r __getitem__szSeq1.__getitem__cCs |j|jSrrr otherr r r __add__sz Seq1.__add__cCs |j|Srrrr r r __mul__sz Seq1.__mul__cCs ||jSrrrr r r __rmul__sz Seq1.__rmul__N __name__ __module__ __qualname__r rrrrrr r r r r s rc@s<eZdZddZddZddZddZd d Zd d Zd S)Seq2cCs ||_dSrrr r r r r sz Seq2.__init__cCs t|jSrrrr r r rsz Seq2.__len__cCs |j|Srrrr r r rszSeq2.__getitem__cCs |j|jSrrrr r r rsz Seq2.__add__cCs |j|Srrrr r r r!sz Seq2.__mul__cCs ||jSrrrr r r r#sz Seq2.__rmul__Nrr r r r rs rc@seZdZddZdS) BadIterablecCstdSr)ZeroDivisionErrorrr r r __iter__'szBadIterable.__iter__N)rrrr!r r r r r&src@sDeZdZddZddZddZddZd 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)dOS)POperatorTestCasecCs|j}|t|j|t|jdd||dd||dd||dd||dd||dd||dddS Ny?y@r?@)module assertRaises TypeErrorlt assertFalse assertTruer rr r r test_lt,szOperatorTestCase.test_ltcCs|j}|t|j|t|jdd||dd||dd||dd||dd||dd||dddSr#)r)r*r+ler-r.r/r r r test_le7szOperatorTestCase.test_lecCs|j}Gdddt}|t|j|t|j||||dd||dd||dd||dd||dd||dddS) Nc@seZdZddZdS)z#OperatorTestCase.test_eq..CcSstdSr SyntaxErrorrr r r __eq__Esz*OperatorTestCase.test_eq..C.__eq__N)rrrr5r r r r CDsr6r$rr%r&r'r()r)objectr*r+eqr4r-r.r rr6r r r test_eqBszOperatorTestCase.test_eqcCs|j}Gdddt}|t|j|t|j||||dd||dd||dd||dd||dd||dddS) Nc@seZdZddZdS)z#OperatorTestCase.test_ne..CcSstdSrr3rr r r __ne__Ssz*OperatorTestCase.test_ne..C.__ne__N)rrrr;r r r r r6Rsr6r$rr%r&r'r()r)r7r*r+ner4r.r-r9r r r test_nePszOperatorTestCase.test_necCs|j}|t|j|t|jdd||dd||dd||dd||dd||dd||dddSr#)r)r*r+ger.r-r/r r r test_ge^szOperatorTestCase.test_gecCs|j}|t|j|t|jdd||dd||dd||dd||dd||dd||dddSr#)r)r*r+gtr.r-r/r r r test_gtiszOperatorTestCase.test_gtcCsL|j}|t|j|t|jd||dd||dddS)Nr$)r)r*r+abs assertEqualr/r r r test_absts zOperatorTestCase.test_abscCs>|j}|t|j|t|jdd||ddddS)N)r)r*r+addrDr/r r r test_add{szOperatorTestCase.test_addcCs>|j}|t|j|t|jdd||ddddS)N )r)r*r+and_rDr/r r r test_bitwise_andsz!OperatorTestCase.test_bitwise_andcCs|j}|t|j|t|jdd||ddd||ddgddggd||td d gtd ggd ||td d gtd ggd |t|jd ddS)NpyZthonZpythonr$r'rFrG)r$r'rFrGrH)rPrQrH )r)r*r+concatrDrrr/r r r test_concats &&zOperatorTestCase.test_concatcCs|j}|t|j|t|jdd|t|jtd||gddd||gdddtd}||||dg|d||ididgiddS) Nr$)r$r'r$rFr$rGrFrPrnanr')r)r*r+countOfr rrDfloatr rrVr r r test_countOfszOperatorTestCase.test_countOfcCsV|j}gd}|t|j||t|j|d|||d||gddS)NrGrFr'r$r$)rGr'r$)r)r*r+delitem assertIsNonerDr rar r r test_delitems zOperatorTestCase.test_delitemcCs@|j}|t|jd|t|jdd||ddddS)NrPr')r)r*r+floordivrDr/r r r test_floordivszOperatorTestCase.test_floordivcCs@|j}|t|jd|t|jdd||ddddS)NrPr'g@)r)r*r+truedivrDr/r r r test_truedivszOperatorTestCase.test_truedivcCsF|j}td}|t|j|t|j|d|||dddS)NrLr')r)ranger*r+getitemrDr_r r r test_getitems zOperatorTestCase.test_getitemcCs|j}|t|j|t|jdd|t|jtd||gddd|t|jgddtd}||||dg|d||ididgiddS)Nr$r\rFrrVrWr') r)r*r+indexOfr rrD ValueErrorrYrZr r r test_indexOfszOperatorTestCase.test_indexOfcCs:|j}|t|j|t|jd||dddS)NrG)r)r*r+invertrDinvr/r r r test_invertszOperatorTestCase.test_invertcCsd|j}|t|j|t|jdd||ddd||ddd|t|jdddS)N*rPr$rLrr'rB)r)r*r+lshiftrDrjr/r r r test_lshifts zOperatorTestCase.test_lshiftcCs>|j}|t|j|t|jdd||ddddS)NrprPr'r$)r)r*r+modrDr/r r r test_modszOperatorTestCase.test_modcCs>|j}|t|j|t|jdd||ddddS)NrPr'rL)r)r*r+mulrDr/r r r test_mulszOperatorTestCase.test_mulcCsJ|j}|t|j|t|jddGddd}||dddS)Nrpc@seZdZddZdS)z'OperatorTestCase.test_matmul..McSs|dS)Nr$r rr r r __matmul__sz2OperatorTestCase.test_matmul..M.__matmul__N)rrrrwr r r r Msrx))r)r*r+matmulrD)r rrxr r r test_matmuls zOperatorTestCase.test_matmulcCsp|j}|t|j|t|jd||dd||dd||dd||dddSNrPrlr)r)r*r+negrDr/r r r test_negszOperatorTestCase.test_negcCs>|j}|t|j|t|jdd||ddddS)NrLrPrK)r)r*r+or_rDr/r r r test_bitwise_orsz OperatorTestCase.test_bitwise_orcCsp|j}|t|j|t|jd||dd||dd||dd||dddSr|)r)r*r+posrDr/r r r test_posszOperatorTestCase.test_poscCsb|j}|t|j|t|jdd||ddd|t|jd|t|jddddS)NrFrPr$r')r)r*r+powrDr/r r r test_pows zOperatorTestCase.test_powcCsd|j}|t|j|t|jdd||ddd||ddd|t|jdddS)NrprPr$r'rrB)r)r*r+rshiftrDrjr/r r r test_rshifts zOperatorTestCase.test_rshiftcCsj|j}|t|j|t|jdd|t|jtd||tdd||tdddS)Nr$rGr'rP) r)r*r+containsr rr.rfr-r/r r r test_containss zOperatorTestCase.test_containscCsr|j}ttd}|t|j||t|j|dd|||dd||gd|t|j|dddS)NrFrr')r'r$r'rG) r)listrfr*r+setitemr^rD IndexErrorr_r r r test_setitems zOperatorTestCase.test_setitemcCs>|j}|t|j|t|jdd||ddddS)NrPr'rF)r)r*r+subrDr/r r r test_sub szOperatorTestCase.test_subcCs||j}Gdddt}|t|j|t|j|||d||dg||d||gdS)Nc@seZdZddZdS)z&OperatorTestCase.test_truth..CcSstdSrr3rr r r __bool__)sz/OperatorTestCase.test_truth..C.__bool__N)rrrrr r r r r6(sr6rPr)r)r7r*r+truthr4r.r-r9r r r test_truth&szOperatorTestCase.test_truthcCs>|j}|t|j|t|jdd||ddddS)N rH)r)r*r+xorrDr/r r r test_bitwise_xor2sz!OperatorTestCase.test_bitwise_xorcCs\|j}d}}|dd|dd}|t|j||||||||dSNZxyzpdqrF)r)r*r+is_r.r-r rr`bcr r r test_is8s zOperatorTestCase.test_iscCs\|j}d}}|dd|dd}|t|j||||||||dSr)r)r*r+is_notr-r.rr r r test_is_not@s zOperatorTestCase.test_is_notcCs|j}Gddd}|}d|_|d}|||d|t||t||d|jt||dd|d}|t|||t|jd|t|j|}d |_d |_d |_ ||d d d|d|t|jdGdddt }|t |d||}d|_||_ d|j _|d}|||d|t||j |dd}|||d|ddd}|t|||d}|t|||d}|t||||j _ d|j j _|d}|||d|ddd}|||ddS)Nc@s eZdZdS)z+OperatorTestCase.test_attrgetter..ANrrrr r r r AJsrarthurnameZdent)ZsurnameZrankr'XYZxzy)rrr)rr rc@seZdZddZdS)z+OperatorTestCase.test_attrgetter..CcSstdSrr3r rr r r __getattr__asz7OperatorTestCase.test_attrgetter..C.__getattr__N)rrrrr r r r r6`sr6foothomasz child.name)rrzchild.child.namezchild.z.childjohnson)rrr) r)r attrgetterrDr*r+AttributeErrorrrrr7r4child)r rrr`frecordr6r r r test_attrgetterHsT          z OperatorTestCase.test_attrgetterc Cs|j}d}|d}|||d|t||t||d|jt||dd|d}|t||Gdddt}|t|d||d }|t|||t|jtd d }|d }|||d |d }|t ||gd}|d}|t t ||gd|t ||d gdt t t td}||ddd|d|t|ddd|td} ||d| d||tdd| dGdddt} ||d| dd||dgd d||dtd!d"d!dS)#NABCDEr'r6rF)sizerLc@seZdZddZdS)z+OperatorTestCase.test_itemgetter..CcSstdSrr3rr r r rsz7OperatorTestCase.test_itemgetter..C.__getitem__N)rrrrr r r r r6srprval)keyrZnonkey)ZapplerFZbananar'ZpearrPZoranger$r$)rFr'rPr$)rrrrrP)2Z105rZabcderBerG)rdc@seZdZdZdS)z+OperatorTestCase.test_itemgetter..TzTuple subclassN)rrr__doc__r r r r Tsrrabcr`)r`rrd)r) itemgetterrDr*r+rr7r4dictKeyErrorrmapsortedstrrftupleslice) r rr`rr6rZ inventoryZgetcountdatatrr r r test_itemgetter}sF        z OperatorTestCase.test_itemgettercCs|j}|t|j|t|jdGddd}|}|d}|t|||ddd}|||d|t||t||d|jt||dd|d }|||d |t||||jd d d }|||d |jd ddd}|||ddS)Nrc@s&eZdZddZd ddZddZdS) z-OperatorTestCase.test_methodcaller..Ac_s|d|dSNrr$r r argskwdsr r r rsz1OperatorTestCase.test_methodcaller..A.foorpcSs|Srr r rr r r barsz1OperatorTestCase.test_methodcaller..A.barc_s|d|dfSNrr r rrr r r bazsz1OperatorTestCase.test_methodcaller..A.bazN)rprrrrrrr r r r rs rrr$r'rF)spamrrprPrrreggs)rr )rr)r)r*r+ methodcallerrrD)r rrr`rr r r test_methodcallers&   z"OperatorTestCase.test_methodcallercCs8|j}Gdddt}|}|||dd|||dd|||dd|||dd|||dd|||dd || |dd || |dd || |dd || |dd || |dd|||dd|||dd||||ddS)Nc@s|eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)z(OperatorTestCase.test_inplace..CcSsdS)Niaddr rr r r __iadd__z1OperatorTestCase.test_inplace..C.__iadd__cSsdS)Niandr rr r r __iand__rz1OperatorTestCase.test_inplace..C.__iand__cSsdS)N ifloordivr rr r r __ifloordiv__rz6OperatorTestCase.test_inplace..C.__ifloordiv__cSsdS)Nilshiftr rr r r __ilshift__rz4OperatorTestCase.test_inplace..C.__ilshift__cSsdS)Nimodr rr r r __imod__rz1OperatorTestCase.test_inplace..C.__imod__cSsdS)Nimulr rr r r __imul__rz1OperatorTestCase.test_inplace..C.__imul__cSsdS)Nimatmulr rr r r __imatmul__rz4OperatorTestCase.test_inplace..C.__imatmul__cSsdS)Niorr rr r r __ior__rz0OperatorTestCase.test_inplace..C.__ior__cSsdS)Nipowr rr r r __ipow__rz1OperatorTestCase.test_inplace..C.__ipow__cSsdS)Nirshiftr rr r r __irshift__rz4OperatorTestCase.test_inplace..C.__irshift__cSsdS)Nisubr rr r r __isub__rz1OperatorTestCase.test_inplace..C.__isub__cSsdS)Nitruedivr rr r r __itruediv__rz5OperatorTestCase.test_inplace..C.__itruediv__cSsdS)Nixorr rr r r __ixor__rz1OperatorTestCase.test_inplace..C.__ixor__cSsdS)NrPr rr r r rrz4OperatorTestCase.test_inplace..C.__getitem__N)rrrrrrrrrrrrrrrrrr r r r r6sr6rPrrrrrrrrrrrrr)r)r7rDrrrrrrrrrrrrriconcat)r rr6rr r r test_inplaces"zOperatorTestCase.test_inplacecCs8|j}Gdddt}||gdd||tgdd|||dd|||tdd|||tdd|t||d Wdn1s0Y|t||d Wdn1s0Y|t ||t Wdn1s*0YdS) Nc@seZdZddZddZdS)z,OperatorTestCase.test_length_hint..XcSs ||_dSr)value)r rr r r r sz5OperatorTestCase.test_length_hint..X.__init__cSs t|jtur|jn|jSdSr)typerrr r r __length_hint__sz.X.__length_hint__N)rrrr rr r r r rsrr'r)r$r'rFrFrGrr) r)r7rD length_hintiterNotImplementedr+r*rj LookupError)r rrr r r test_length_hints  , , z!OperatorTestCase.test_length_hintcCsZ|j}ddt|D}|D]8}t||}t|d|ddd}|r|||qdS)NcSsg|]}|ds|qS)_) startswith).0rr r r rz.__r)r)dirgetattrstripZassertIs)r rnamesrZorigZdunderr r r test_dunder_is_originals z(OperatorTestCase.test_dunder_is_originalN)*rrrr0r2r:r=r?rArErJrNrUr[rarcrerhrkrorrrtrvr{r~rrrrrrrrrrrrrrrrrr r r r r"+sN            53!r"c@seZdZeZdS)PyOperatorTestCaseN)rrr py_operatorr)r r r r rsrzrequires _operatorc@seZdZeZdS)COperatorTestCaseN)rrr c_operatorr)r r r r rsrc@s,eZdZddZddZddZddZd S) OperatorPickleTestCasecCs~ttjd|jt||}Wdn1s40Yttjd|jt|WdS1sp0YdS)Nr) rZ swap_itemsysmodulesr)pickledumpsmodule2loads)r objprotoZpickledr r r copys*zOperatorPickleTestCase.copyc CsH|jj}Gddd}|}d|_d|_d|_||_||j_d|jj_tt j dD]}|j |d|d }| ||}| t|t|| |||||d d d }| ||}| t|t|| |||||d }| ||}| t|t|| ||||WdqX1s80YqXdS) Nc@s eZdZdS)z1OperatorPickleTestCase.test_attrgetter..ANrr r r r r srrrrVr$rrrrzt.u.v)r)rrrrruvrfrHIGHEST_PROTOCOLsubTestrrDrepr)r rrr`rrf2r r r rs.      z&OperatorPickleTestCase.test_attrgetterc Cs|jj}d}ttjdD]}|j|d|d}|||}|t|t|||||||ddd}|||}|t|t||||||Wdq1s0YqdS)Nrr$rr'rrG) r)rrfrr"r#rrDr$)r rr`rrr%r r r r:s   z&OperatorPickleTestCase.test_itemgetterc CsN|jj}Gddd}|}ttjdD]}|j|d|d}|||}|t|t|||||||ddd}|||}|t|t|||||||ddd }|||}|t|t|||||||d d d d }|||}|||||Wdq*1s>0Yq*dS)Nc@s&eZdZddZd ddZddZdS) z3OperatorPickleTestCase.test_methodcaller..Ac_s|d|dSrr rr r r rLsz7OperatorPickleTestCase.test_methodcaller..A.foorpcSs|Srr rr r r rNsz7OperatorPickleTestCase.test_methodcaller..A.barc_s|d|dfSrr rr r r rPsz7OperatorPickleTestCase.test_methodcaller..A.bazN)rprr r r r rKs rr$rrrr'rPrrrrr) r)rrfrr"r#rrDr$)r rrr`rrr%r r r rIs(      z(OperatorPickleTestCase.test_methodcallerN)rrrrrrrr r r r rsrc@seZdZeZeZdS)PyPyOperatorPickleTestCaseN)rrrrr)rr r r r r&hsr&c@seZdZeZeZdS)PyCOperatorPickleTestCaseN)rrrrr)rrr r r r r'lsr'c@seZdZeZeZdS)CPyOperatorPickleTestCaseN)rrrrr)rrr r r r r(qsr(c@seZdZeZeZdS)CCOperatorPickleTestCaseN)rrrrr)rr r r r r)vsr)__main__)ZunittestrrtestrZimport_fresh_modulerrrr7rrr"ZTestCaserZ skipUnlessrrr&r'r(r)rmainr r r r s2 g Q