a zeb@sddlZddlmZddlmZddlmZdZGdddZGdd d eZ Gd d d eej Z Gd d d eej Z Gdddeej Z Gdddeej ZGddde ej ZGddde ej ZGddde ej ZGddde ej ZGddde ej ZGddde ej ZGdddeej ZGd d!d!eej ZGd"d#d#eZGd$d%d%eZGd&d'd'eZGd(d)d)ej Zed*kredS)+N)repeat)deque) length_hint c@seZdZddZdS)TestInvariantWithoutMutationscCsh|j}ttdtdD]}|t||t|q|t|d|tt||t|ddSNr) itreversedrangen assertEqualrnext assertRaises StopIteration)selfr irE/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_iterlen.pytest_invariant6s z,TestInvariantWithoutMutations.test_invariantN)__name__ __module__ __qualname__rrrrrr4src@seZdZddZdS)TestTemporarilyImmutablecCs\|j}|t|tt||t|td||tt||t|ddSr)r r rr rmutater RuntimeError)rr rrrtest_immutable_during_iterationAsz8TestTemporarilyImmutable.test_immutable_during_iterationN)rrrrrrrrr?src@seZdZddZdS) TestRepeatcCstdt|_dSN)rr r rrrrsetUpQszTestRepeat.setUpNrrrr rrrrrOsrc@seZdZddZdS) TestXrangecCsttt|_dSriterr r r rrrrr VszTestXrange.setUpNr!rrrrr"Tsr"c@seZdZddZdS)TestXrangeCustomReversedcCsttt|_dSrr r r r rrrrr [szTestXrangeCustomReversed.setUpNr!rrrrr%Ysr%c@seZdZddZdS) TestTuplecCstttt|_dSr)r$tupler r r rrrrr `szTestTuple.setUpNr!rrrrr'^sr'c@seZdZddZdS) TestDequecCs"ttt}t||_|j|_dSr)rr r r$r poprrdrrrr gs  zTestDeque.setUpNr!rrrrr)esr)c@seZdZddZdS)TestDequeReversedcCs"ttt}t||_|j|_dSr)rr r r r r*rr+rrrr ns  zTestDequeReversed.setUpNr!rrrrr-lsr-c@seZdZddZdS) TestDictKeyscCs$ttt}t||_|j|_dSr)dictfromkeysr r r$r popitemrr+rrrr us zTestDictKeys.setUpNr!rrrrr.ssr.c@seZdZddZdS) TestDictItemscCs(ttt}t||_|j|_dSr) r/r0r r r$itemsr r1rr+rrrr |szTestDictItems.setUpNr!rrrrr2zsr2c@seZdZddZdS)TestDictValuescCs(ttt}t||_|j|_dSr) r/r0r r r$valuesr r1rr+rrrr szTestDictValues.setUpNr!rrrrr4sr4c@seZdZddZdS)TestSetcCs"ttt}t||_|j|_dSr)setr r r$r r*rr+rrrr s  z TestSet.setUpNr!rrrrr6sr6c@seZdZddZddZdS)TestListcCsttt|_dSrr#rrrrr szTestList.setUpcCsttt}t|}t|t||t|td|t|t|tdg|dd<|t|d|t|g|td|t|ddSNrr) listr r r$rr rappendextendrr,r rrr test_mutations   zTestList.test_mutationNrrrr r@rrrrr8sr8c@seZdZddZddZdS)TestListReversedcCsttt|_dSrr&rrrrr szTestListReversed.setUpcCsttt}t|}t|t||t|td|t|t|tdg|dd<|t|d|t|g|td|t|ddSr9) r<r r r rr rr=r>r?rrrr@s   zTestListReversed.test_mutationNrArrrrrBsrBc@seZdZddZddZdS)BadLencCs ttdSNrr$r rrrr__iter__szBadLen.__iter__cCs tddSNZhellorrrrr__len__szBadLen.__len__N)rrrrFrIrrrrrCsrCc@seZdZddZddZdS) BadLengthHintcCs ttdSrDrErrrrrFszBadLengthHint.__iter__cCs tddSrGrHrrrr__length_hint__szBadLengthHint.__length_hint__NrrrrFrKrrrrrJsrJc@seZdZddZddZdS)NoneLengthHintcCs ttdSrDrErrrrrFszNoneLengthHint.__iter__cCstSr)NotImplementedrrrrrKszNoneLengthHint.__length_hint__NrLrrrrrMsrMc@seZdZddZddZdS)TestLengthHintExceptionscCsx|ttt|ttt|tgjt|tgjtttd}|t|jt|t|jtdSrD)rrr<rCrJr> bytearrayr )rbrrrtest_issue1242657s z*TestLengthHintExceptions.test_issue1242657cCs|ttttddSrD)r r<rMr rrrrtest_invalid_hintsz*TestLengthHintExceptions.test_invalid_hintN)rrrrRrSrrrrrOs rO__main__)Zunittest itertoolsr collectionsroperatorrr rrZTestCaserr"r%r'r)r-r.r2r4r6r8rBobjectrCrJrMrOrmainrrrr,s0