a  ze@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlZddlmZmZmZmZmZddlmZmZedZedZedZGd d d eZGd d d ejeeZe d kre!dS)N)deepcopy)support) TestEquality TestHashing LoggingResultLegacyLoggingResult#ResultWithNoStartTestRunStopTestRun)captured_stderr gc_collectfoofoo.barquuxc@sDeZdZdZGdddejZGdddeZGdddejZdS) Testz5Keep these TestCase classes out of the main namespacec@seZdZddZddZdS)zTest.FoocCsdSNselfrrK/opt/bitninja-python-dojo/embedded/lib/python3.9/unittest/test/test_case.pyrunTest!zTest.Foo.runTestcCsdSrrrrrrtest1"rzTest.Foo.test1N)__name__ __module__ __qualname__rrrrrrFoo src@seZdZddZdS)zTest.BarcCsdSrrrrrrtest2%rzTest.Bar.test2N)rrrrrrrrBar$srcs8eZdZdZfddZddZddZdd ZZS) zTest.LoggingTestCasez!A test case which logs its calls.csttj|d||_dSNtest)superrLoggingTestCase__init__events)rr" __class__rrr!*szTest.LoggingTestCase.__init__cCs|jddS)NsetUpr"appendrrrrr%.szTest.LoggingTestCase.setUpcCs|jddSrr&rrrrr1szTest.LoggingTestCase.testcCs|jddS)NtearDownr&rrrrr(4szTest.LoggingTestCase.tearDown) rrr__doc__r!r%rr( __classcell__rrr#rr 's  r N) rrrr)unittestTestCaserrr rrrrrsrc@seZdZededfgZededfededfededfgZddZddZ dd Z d d Z d d Z ddZ ddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Z d6d7Z!d8d9Z"d:d;Z#dd?Z%d@dAZ&dBdCZ'dDdEZ(e)*e+j,j-dFkdGdHdIZ.e)*e+j,j-dFkdGdJdKZ/dLdMZ0dNdOZ1dPdQZ2dRdSZ3dTdUZ4dVdWZ5dXdYZ6dZd[Z7d\d]Z8d^d_Z9d`daZ:dbdcZ;dddeZdjdkZ?dldmZ@dndoZAdpdqZBdrdsZCdtduZDdvdwZEdxdyZFdzd{ZGd|d}ZHd~dZIddZJddZKddZLddZMddZNddZOddZPddZQddZRddZSddZTddZUddZVddZWddZXeYjZddZ[ddZ\ddZ]ddZ^ddZ_ddZ`ddZaddZbddZcddZdddZeddZfddZgddZhddZiddZjddZkddZlemjnddÄZoddńZpdS) Test_TestCaserrrcCsGdddtj}||dddt}|dd||j|ddWdn1sn0Y|t|Wdn1s0YdS)Nc@seZdZddZddZdS)z3Test_TestCase.test_init__no_test_name..TestcSs tdSr MyExceptionrrrrrTrz;Test_TestCase.test_init__no_test_name..Test.runTestcSsdSrrrrrrrUrz8Test_TestCase.test_init__no_test_name..Test.testNrrrrrrrrrrSsriz .Test.runTest)r+r, assertEqualid assertRaisesfailureExceptionAttributeErrorrun)rrrrrrtest_init__no_test_nameRs * z%Test_TestCase.test_init__no_test_namecCs2Gdddtj}||dddddS)Nc@seZdZddZddZdS)z7Test_TestCase.test_init__test_name__valid..TestcSs tdSrr.rrrrrirz?Test_TestCase.test_init__test_name__valid..Test.runTestcSsdSrrrrrrrjrz.Test.testNr0rrrrrhsrriz .Test.test)r+r,r3r4rrrrrtest_init__test_name__validgsz)Test_TestCase.test_init__test_name__validcCs@Gdddtj}z |dWnty0Yn 0|ddS)Nc@seZdZddZddZdS)z9Test_TestCase.test_init__test_name__invalid..TestcSs tdSrr.rrrrrtrzATest_TestCase.test_init__test_name__invalid..Test.runTestcSsdSrrrrrrrurz>Test_TestCase.test_init__test_name__invalid..Test.testNr0rrrrrssrZtestfoozFailed to raise ValueError)r+r, ValueErrorfailr:rrrtest_init__test_name__invalidrs   z+Test_TestCase.test_init__test_name__invalidcCs*Gdddtj}||dddS)Nc@seZdZddZdS)z.Test_TestCase.test_countTestCases..FoocSsdSrrrrrrrrz3Test_TestCase.test_countTestCases..Foo.testNrrrrrrrrrsrr)r+r,r3ZcountTestCasesrrrrrtest_countTestCasessz!Test_TestCase.test_countTestCasescCs2Gdddtj}|}|t|tjdS)Nc@seZdZddZdS)z1Test_TestCase.test_defaultTestResult..FoocSsdSrrrrrrrsz9Test_TestCase.test_defaultTestResult..Foo.runTestNrrrrrrrrrsr)r+r,defaultTestResultr3type TestResult)rrresultrrrtest_defaultTestResults z$Test_TestCase.test_defaultTestResultcsHg}t|}Gfdddtj||gd}|||dS)NcseZdZfddZZS)z>Test_TestCase.test_run_call_order__error_in_setUp..Foocst|tddSNzraised by Foo.setUprr% RuntimeErrorrrr$rrr%szDTest_TestCase.test_run_call_order__error_in_setUp..Foo.setUp)rrrr%r*rrr#rrsr) startTestr%addErrorstopTestrrr r8r3rr"rGexpectedrrMr#test_run_call_order__error_in_setUps z1Test_TestCase.test_run_call_order__error_in_setUpcs>g}Gfdddtj|gd}|||dS)Ncs&eZdZddZfddZZS)zMTest_TestCase.test_run_call_order__error_in_setUp_default_result..FoocSs t|jSrrr"rrrrrDsz_Test_TestCase.test_run_call_order__error_in_setUp_default_result..Foo.defaultTestResultcst|tddSrIrJrrLrrr%szSTest_TestCase.test_run_call_order__error_in_setUp_default_result..Foo.setUp)rrrrDr%r*rrMr#rrsr) startTestRunrNr%rOrP stopTestRunrr r8r3rr"rSrrMr2test_run_call_order__error_in_setUp_default_results  z@Test_TestCase.test_run_call_order__error_in_setUp_default_resultcsHg}t|}Gfdddtjgd}|||||dS)NcseZdZfddZZS)z=Test_TestCase.test_run_call_order__error_in_test..Foocst|tddSNraised by Foo.testrrrKrrLrrrszBTest_TestCase.test_run_call_order__error_in_test..Foo.testrrrrr*rrMr#rrsrrNr%rr(rOrPrQrRrrMr"test_run_call_order__error_in_tests z0Test_TestCase.test_run_call_order__error_in_testcs>g}Gfdddtjgd}||||dS)Ncs&eZdZddZfddZZS)zLTest_TestCase.test_run_call_order__error_in_test_default_result..FoocSs t|jSrrUrrrrrDsz^Test_TestCase.test_run_call_order__error_in_test_default_result..Foo.defaultTestResultcst|tddSr[r]rrLrrrszQTest_TestCase.test_run_call_order__error_in_test_default_result..Foo.testrrrrDrr*rrMr#rrsrrVrNr%rr(rOrPrWrXrYrrMr1test_run_call_order__error_in_test_default_results  z?Test_TestCase.test_run_call_order__error_in_test_default_resultcsHg}t|}Gfdddtjgd}|||||dS)NcseZdZfddZZS)z?Test_TestCase.test_run_call_order__failure_in_test..Foocst||ddSr[rrr=rrLrrrszDTest_TestCase.test_run_call_order__failure_in_test..Foo.testr^rrMr#rrsrrNr%rr( addFailurerPrQrRrrMr$test_run_call_order__failure_in_tests z2Test_TestCase.test_run_call_order__failure_in_testcs>Gfdddtjgd}g}||||dS)Ncs&eZdZddZfddZZS)zNTest_TestCase.test_run_call_order__failure_in_test_default_result..FoocSs t|jSrrUrrrrrDsz`Test_TestCase.test_run_call_order__failure_in_test_default_result..Foo.defaultTestResultcst||ddSr[rdrrLrrrszSTest_TestCase.test_run_call_order__failure_in_test_default_result..Foo.testrarrMr#rrsr)rVrNr%rr(rfrPrWrX)rrSr"rrMr3test_run_call_order__failure_in_test_default_results  zATest_TestCase.test_run_call_order__failure_in_test_default_resultcsHg}t|}Gfdddtj||gd}|||dS)NcseZdZfddZZS)zATest_TestCase.test_run_call_order__error_in_tearDown..Foocst|tddSNzraised by Foo.tearDownrr(rKrrLrrr(szJTest_TestCase.test_run_call_order__error_in_tearDown..Foo.tearDown)rrrr(r*rrMr#rrsrr_rQrRrrMr&test_run_call_order__error_in_tearDown s z4Test_TestCase.test_run_call_order__error_in_tearDowncs>Gfdddtjg}|gd}|||dS)Ncs&eZdZddZfddZZS)zPTest_TestCase.test_run_call_order__error_in_tearDown_default_result..FoocSs t|jSrrUrrrrrDszbTest_TestCase.test_run_call_order__error_in_tearDown_default_result..Foo.defaultTestResultcst|tddSrirjrrLrrr(szYTest_TestCase.test_run_call_order__error_in_tearDown_default_result..Foo.tearDown)rrrrDr(r*rrMr#rrsrrbrXrYrrMr5test_run_call_order__error_in_tearDown_default_results  zCTest_TestCase.test_run_call_order__error_in_tearDown_default_resultcCs"Gdddtj}|ddS)Nc@seZdZddZddZdS)z=Test_TestCase.test_run_call_order_default_result..FoocSstSr)rrrrrrD-szOTest_TestCase.test_run_call_order_default_result..Foo.defaultTestResultcSsdSrrrrrrr/szBTest_TestCase.test_run_call_order_default_result..Foo.testN)rrrrDrrrrrr,srr)r+r,r8rArrr"test_run_call_order_default_result*sz0Test_TestCase.test_run_call_order_default_resultcs4Gfdddtj|||||dS)NcseZdZfddZZS)z6Test_TestCase._check_call_order__subtests..Fooc st|dD]}|j|dl|dkr6|ddD]D}|j|d$||dkr`tdWdq:1st0Yq:Wdq1s0Yqdd dS) Nr@r2r1ir@failurer2r1jr\r)rrsubTestr=rKrrprtrLrrr6s  Hz;Test_TestCase._check_call_order__subtests..Foo.testr^rrMr#rr5srrXrrGr"Zexpected_eventsrrMr_check_call_order__subtests4sz)Test_TestCase._check_call_order__subtestscCs&g}t|}gd}||||dS)N) rNr%rr(addSubTestFailureaddSubTestSuccessrzrzr{rOrP)rryrRrrrtest_run_call_order__subtestsLsz+Test_TestCase.test_run_call_order__subtestscCs&g}t|}gd}||||dS)Nre)rryrRrrr$test_run_call_order__subtests_legacyUsz2Test_TestCase.test_run_call_order__subtests_legacycs4Gfdddtj|||||dS)NcseZdZfddZZS)z>Test_TestCase._check_call_order__subtests_success..Fooc s~t|dD]f}|j|dFdD]0}|j|dWdq(1sN0Yq(Wdq1sn0YqdS)N)r@r2rorrrs)rrrvrwrLrrr`s zCTest_TestCase._check_call_order__subtests_success..Foo.testr^rrMr#rr_srrXrxrrMr#_check_call_order__subtests_success^s z1Test_TestCase._check_call_order__subtests_successcCs8g}t|}gdddgddg}||||dS)N)rNr%rr(rur{ addSuccessrP)rr~rRrrr%test_run_call_order__subtests_successksz3Test_TestCase.test_run_call_order__subtests_successcCs&g}t|}gd}||||dS)N)rNr%rr(rrP)rr~rRrrr,test_run_call_order__subtests_success_legacyusz:Test_TestCase.test_run_call_order__subtests_success_legacycsNg}t|}d|_Gfdddtjgd}|||||dS)NTcseZdZfddZZS)zATest_TestCase.test_run_call_order__subtests_failfast..Foocst||jdd|dWdn1s:0Y|jdd|dWdn1sp0Y|ddS)Nr@rorqr2)rrrvr=rrLrrrs ((zFTest_TestCase.test_run_call_order__subtests_failfast..Foo.testr^rrMr#rrsr)rNr%rr(rzrP)rfailfastrr r8r3rRrrMr&test_run_call_order__subtests_failfast}s z4Test_TestCase.test_run_call_order__subtests_failfastcsTgGfdddtj}t}d|_t|}||gd}||dS)Ncs0eZdZfddZfddZfddZdS)z1Test_TestCase.test_subtests_failfast..Foocs@|dWdn1s(0YddS)Na1a2)rvr'rr"rrtest_as (z8Test_TestCase.test_subtests_failfast..Foo.test_acsr|dWdn1s(0Y||dWdn1sZ0YddS)Nb1rqb2)rvr'r=rrrrtest_bs  ( (z8Test_TestCase.test_subtests_failfast..Foo.test_bcsddS)Ncr'rrrrtest_csz8Test_TestCase.test_subtests_failfast..Foo.test_cN)rrrrrrrrrrrs  rT)rrr)r+r,rFrZ makeSuiter8r3)rrrGZsuiterSrrrtest_subtests_failfasts  z$Test_TestCase.test_subtests_failfastcs:gGfdddtj}|d|ddgdS)NcseZdZfddZdS)z.Test_TestCase.test_subtests_debug..Foocs@d|dWdn1s20YdS)N test case subtest 1)r'rvrrrrrs  z5Test_TestCase.test_subtests_debug..Foo.test_aN)rrrrrrrrrsrrrr)r+r,debugr3rArrrtest_subtests_debugs z!Test_TestCase.test_subtests_debugcCs(Gdddtj}||djtdS)Nc@seZdZddZdS)z9Test_TestCase.test_failureException__default..FoocSsdSrrrrrrrsz>Test_TestCase.test_failureException__default..Foo.testNr?rrrrrsrr)r+r,assertIsr6AssertionErrorrArrrtest_failureException__defaultsz,Test_TestCase.test_failureException__defaultcCsVg}t|}Gdddtj}||djt|d|gd}|||dS)Nc@seZdZddZeZdS)zMTest_TestCase.test_failureException__subclassing__explicit_raise..FoocSs tdSr)rKrrrrrszRTest_TestCase.test_failureException__subclassing__explicit_raise..Foo.testNrrrrrKr6rrrrrsrrrNrfrPrr+r,rr6rKr8r3rr"rGrrSrrr2test_failureException__subclassing__explicit_raisesz@Test_TestCase.test_failureException__subclassing__explicit_raisecCsVg}t|}Gdddtj}||djt|d|gd}|||dS)Nc@seZdZddZeZdS)zMTest_TestCase.test_failureException__subclassing__implicit_raise..FoocSs|ddSNr )r=rrrrrszRTest_TestCase.test_failureException__subclassing__implicit_raise..Foo.testNrrrrrrsrrrrrrrr2test_failureException__subclassing__implicit_raisesz@Test_TestCase.test_failureException__subclassing__implicit_raisecCs Gdddtj}|dS)Nc@seZdZddZdS)z%Test_TestCase.test_setUp..FoocSsdSrrrrrrrsz-Test_TestCase.test_setUp..Foo.runTestNrCrrrrrsr)r+r,r%rArrr test_setUpszTest_TestCase.test_setUpcCs Gdddtj}|dS)Nc@seZdZddZdS)z(Test_TestCase.test_tearDown..FoocSsdSrrrrrrrsz0Test_TestCase.test_tearDown..Foo.runTestNrCrrrrrsr)r+r,r(rArrr test_tearDownszTest_TestCase.test_tearDowncCs(Gdddtj}||tdS)Nc@seZdZddZdS)z"Test_TestCase.test_id..FoocSsdSrrrrrrrsz*Test_TestCase.test_id..Foo.runTestNrCrrrrr sr)r+r,assertIsInstancer4strrArrrtest_id szTest_TestCase.test_idcsTgtGfdddtj}|d}||gd}||dS)Ncs$eZdZfddZfddZdS)z;Test_TestCase.test_run__uses_defaultTestResult..FoocsddSrrrrrrrsz@Test_TestCase.test_run__uses_defaultTestResult..Foo.testcsSrrr) defaultResultrrrD szMTest_TestCase.test_run__uses_defaultTestResult..Foo.defaultTestResultN)rrrrrDrrr"rrrs rr)rVrNrrrPrW)rr+r,r8rr3)rrrGrSrrr test_run__uses_defaultTestResults  z.Test_TestCase.test_run__uses_defaultTestResultcCs8Gdddtj}t}|d|}|||dS)Nc@seZdZddZdS)z9Test_TestCase.test_run__returns_given_result..FoocSsdSrrrrrrr0sz>Test_TestCase.test_run__returns_given_result..Foo.testNr?rrrrr/srr)r+r,rFr8r)rrrGretvalrrrtest_run__returns_given_result-sz,Test_TestCase.test_run__returns_given_resultcsDttGfdddtj}|d}||dS)Ncs"eZdZddZfddZdS)zKTest_TestCase.test_call__invoking_an_instance_delegates_to_run..FoocSsdSrrrrrrr@szPTest_TestCase.test_call__invoking_an_instance_delegates_to_run..Foo.testcs||Sr)r)rrGZresultInZ resultOutrrr8Cs zOTest_TestCase.test_call__invoking_an_instance_delegates_to_run..Foo.runN)rrrrr8rrrrr?srr)r+rFr,r)rrrrrr0test_call__invoking_an_instance_delegates_to_run;s  z>Test_TestCase.test_call__invoking_an_instance_delegates_to_runcCs||dSr) assertIsNoneshortDescriptionrrrr$testShortDescriptionWithoutDocstringLsz2Test_TestCase.testShortDescriptionWithoutDocstringr2z)Docstrings are omitted with -O2 and abovecCs||ddS)z7Tests shortDescription() for a method with a docstring.Nr3rrrrr(testShortDescriptionWithOneLineDocstringOsz6Test_TestCase.testShortDescriptionWithOneLineDocstringcCs||ddS)zTests shortDescription() for a method with a longer docstring. This method ensures that only the first line of a docstring is returned used in the short description, no matter how long the whole thing is. z>Tests shortDescription() for a method with a longer docstring.Nrrrrr*testShortDescriptionWithMultiLineDocstringWs z8Test_TestCase.testShortDescriptionWithMultiLineDocstringcCs||ddS)z Tests shortDescription() whitespace is trimmed, so that the first line of nonwhite-space text becomes the docstring. zATests shortDescription() whitespace is trimmed, so that the firstNrrrrr&testShortDescriptionWhitespaceTrimmingesz4Test_TestCase.testShortDescriptionWhitespaceTrimmingcsVGdddt}}|||kdfdd }|||||dS)Nc@seZdZdZdS)z7Test_TestCase.testAddTypeEqualityFunc..SadSnakez)Dummy class for test_addTypeEqualityFunc.N)rrrr)rrrrSadSnakeosrcs t|t|kokSSr)rE)abmsgrrrAllSnakesCreatedEqualsszDTest_TestCase.testAddTypeEqualityFunc..AllSnakesCreatedEqual)N)object assertFalseZaddTypeEqualityFuncr3)rs1s2rrrrtestAddTypeEqualityFuncns  z%Test_TestCase.testAddTypeEqualityFunccCs,t}|||||j|j|tdSr)rrr5r6rthingrrr testAssertIs{s zTest_TestCase.testAssertIscCs,t}||t||j|j||dSr)rZ assertIsNotr5r6rrrrtestAssertIsNotszTest_TestCase.testAssertIsNotcCs(g}||t||j|j|tdSr)rlistr5r6dictrrrrtestAssertIsInstances   z"Test_TestCase.testAssertIsInstancecCs(g}||t||j|j|tdSr)ZassertNotIsInstancerr5r6rrrrrtestAssertNotIsInstances   z%Test_TestCase.testAssertNotIsInstancecCsdddd}|dd|dgd|d ||d d|d gd|d |||j|jd d||j|jdgd||j|jd|||j|jdd||j|jdgd||j|jd|dS)NZbananaZgrassZfish)monkeycowZsealrabcr2rnrdrZotterxZelephantrr@r)assertIn assertNotInr5r6)rZanimalsrrr testAssertIns"     zTest_TestCase.testAssertInc Cs:ttdt|ii|iddi|ddiddi|ddiddd|dddddd||j |ddiiWdn1s0Y||j$|ddiddiWdn1s0Y||j$|ddiddiWdn1s*0Y||j&|dddddiWdn1sn0Y||j&|dddddiWdn1s0Yd d d td D}||j$|d |id diWdn1s 0YWdn1s,0YdS)Nignorerr@r2rroner)rrcss|]}t|VqdSr)chr).0rprrr rz=Test_TestCase.testAssertDictContainsSubset..r u�) warningscatch_warnings simplefilterDeprecationWarningassertDictContainsSubsetr5r6joinrange)rrrrrtestAssertDictContainsSubsets(   .2466z*Test_TestCase.testAssertDictContainsSubsetc Csdiifggfttfttfg}|D]\}}z|||Wn&|jyh|d||fYn0z|j||ddWn&|jy|d||fYn0z|||dWq*|jy|d||fYq*0q*dgfitftdd gtdd gftdd gtd d gftd dgtd dgfg}|D]L\}}||j|j||||j|j||d|j|j|j||ddq:dS) N)rrzassertEqual(%r, %r) failedr rz$assertEqual(%r, %r) with msg= failedz/assertEqual(%r, %r) with third parameter failedrrr@r2r1)set frozensetr3r6r=r5)rZ equal_pairsrrZ unequal_pairsrrrtestAssertEqualsF    zTest_TestCase.testAssertEqualcCs|gg|dd|gdddgg}g}|tjj|j|||tjj|jt|t||tjj|j|t|||||||t|t|||t||t||||j|j|t|||j|jt||||j|jd|||j|jdt|||j|jdt|||j|jdd||j|jdd||j|jdd| iiddi}i}|tjj|j ||| || ||d|d<|tjj|j ||d||j|j d|||j|j g|||j|j dddS)Nrrrr@rzThese are unequal) assertListEqualassertTupleEqualassertSequenceEqualr5r+r,r6tupleextendassertDictEqualupdate)rrrrrrrr testEqualitysh                    zTest_TestCase.testEqualityc Cs||jdddd}ddd}dtt|t|}tj j t |df}t |d|_z| ||Wn0|j y}z|jd }WYd}~nd}~00|d |t |t ||||t |d|_z| ||Wn2|j y,}z|jd }WYd}~nd}~00|d |t |t ||||d|_z| ||Wn2|j y}z|jd }WYd}~nd}~00|d |t |t ||||dS) Nirrir r@r2rz!assertSequenceEqual did not fail.)r3maxDiffrdifflibZndiffpprintZpformat splitlinesr+case DIFF_OMITTEDlenrr6argsr= assertLessr assertGreaterr)rZseq1Zseq2diffomittederrrrtestAssertSequenceEqualMaxDiffs>           z,Test_TestCase.testAssertSequenceEqualMaxDiffcCsrd|_|dd}tjjtd}||d|d|_|dd}||dd|_|dd}||ddS)Nr@r barfoobarr)r_truncateMessager+rrrr3)rmessagerrrrtestTruncateMessageEs    z!Test_TestCase.testTruncateMessagec Csrtd}dd}||_z|iddiWn6|jyb}z|t|dWYd}~nd}~00|ddS)Nr3cSsdSrrrrrrrtruncateUsz.truncater@rr zassertDictEqual did not fail)r+r,rrr6r3rr=rrrrrrrtestAssertDictEqualTruncatesSs &z*Test_TestCase.testAssertDictEqualTruncatesc Csntd}dd}||_z|ddWn6|jy^}z|t|dWYd}~nd}~00|ddS)Nr3cSsdSrrrrrrraszATest_TestCase.testAssertMultiLineEqualTruncates..truncater rz!assertMultiLineEqual did not fail)r+r,rassertMultiLineEqualr6r3rr=rrrr!testAssertMultiLineEqualTruncates_s &z/Test_TestCase.testAssertMultiLineEqualTruncatescsZjdd_jd_fddd}j$}|d|dWdn1sn0Ydt|j|d|dd }d d }j |_ fd d|d|d}}j}||Wdn1s 0Y dt|jt|jd ||f|d|ddS)Ni cs tdSN_diffThresholdsetattrr old_thresholdrrrtrz=Test_TestCase.testAssertEqual_diffThreshold..Zxxxxxxxxxxxxxxxxrr^Z@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcSs tddS)Nzthis should not be raised) SystemError)rrrrrexplodingTruncationszHTest_TestCase.testAssertEqual_diffThreshold..explodingTruncationcs tdS)Nrrr) old_truncaterrrr rz%r != %r) r3rr addCleanupr5r6rr exceptionrr)rscmr rrr)r rrrtestAssertEqual_diffThresholdks*2,z+Test_TestCase.testAssertEqual_diffThresholdcsjd_fddd}|d|d}}j}||Wdn1sd0Yd}t|jd||f|d|dd }|d||d|}}j}||Wdn1s0Yd }t|jd ||||fd }|d||d|}}j}||Wdn1sf0Yd }d}t|jd ||||fdS)Nrcs tdSrrrrrrr rz7Test_TestCase.testAssertEqual_shorten..ZdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrrzKxxxx[35 chars]xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxz'%sa' != '%sb'Z2yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzxxxx[85 chars]xxxxxxxxxxxz'%sa%s' != '%sb%s'Zdyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyzxxxx[91 chars]xxxxxz6yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy[56 chars]yyyy)rrr5r6r3rr)rrrrrrprrrrtestAssertEqual_shortens.**,z%Test_TestCase.testAssertEqual_shortenc Cst}|gdgd|gdgd|||dddg|dd|df|gdgd||j|jd dgdgd d gd ddg||j|jgdgd ||j|jd gd d g||j|jd d gd g||j|jgdd d g|d dgddgdgdddgd dgg|td dgddgtd dgddg||j|jgtdd ddtg|dd iddigddidd ig|d dtggtgdd g||j|jgtgdd ddtg||j|jd ggdgg||j|jgddd g||j|jgdgd||j|jd ddiddgddiddgddhd dhg}|ddd}|||ttj dd}hd}| ||tj ggg}| |d dgfgttj dd}hd}| ||dS)Nrn)r1r2r@)r rbaz)rrr r2r1)r@2rr)rrTrr@d)rrTr@ )rrrrrFry@y@rr)r@r@r2)r@r@rrr)rrTrTZaaabccdZabbbcce>)r@rr)r@r1r)r1r@r)rr@r) rassertCountEqualr5r6iterdivmodrrr+utilZ_count_diff_all_purposer3Z_count_diff_hashable)rrrZdiffsrSrrrtestAssertCountEqualsn           ( $          z"Test_TestCase.testAssertCountEqualcCst}t}|||||j|jd|||j|jg|||j|j|d||j|j|gtdg}t}||j|j||tdg}tdg}|||tdg}tddg}||j|j||tdg}tddg}||j|j||tddg}tddg}|||t}d}||j|j||||j|j||tddg}tdg}||j|j||dS)Nrrr )rr@rr)rr)rassertSetEqualr5r6r)rZset1Zset2rrrtestAssertSetEquals:              z Test_TestCase.testAssertSetEqualcCs|dd|dd|dd|dd|dd|dd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd|dd|dd|dd|dd|dd|dd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd|dd|dd|dd|dd|dd|dd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd|dd|dd|dd|dd|dd|dd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdd||j|jdddS) Nr2r@g?g?ZbugZantsbugsant)rZassertGreaterEqualrZassertLessEqualr5r6rrrrtestInequalitysd                        zTest_TestCase.testInequalityc Csnd}d}d}d|_z|||WnF|jyh}z,t|ddd}|||WYd}~n d}~00dS)Nzxhttp://www.python.org/doc/2.3/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] zhttp://www.python.org/doc/2.4.1/lib/module-unittest.html test case A test case is the smallest unit of testing. [...] You may provide your own implementation that does not subclass from TestCase, of course. a- http://www.python.org/doc/2.3/lib/module-unittest.html ? ^ + http://www.python.org/doc/2.4.1/lib/module-unittest.html ? ^^^ test case - A test case is the smallest unit of testing. [...] + A test case is the smallest unit of testing. [...] You may provide your ? +++++++++++++++++++++ + own implementation that does not subclass from TestCase, of course. rr@)rrr6rsplitr3rZ sample_textZrevised_sample_textZsample_text_errorrerrorrrrtestAssertMultiLineEqualLs z&Test_TestCase.testAssertMultiLineEqualc Cshd}d}d}z|||WnF|jyb}z,t|ddd}|||WYd}~n d}~00dS)Nzladen swallows fly slowlyzunladen swallows fly quicklyzr- laden swallows fly slowly ? ^^^^ + unladen swallows fly quickly ? ++ ^^^^^ rr@)r3r6rr$r%rrrtestAssertEqualSingleLineksz'Test_TestCase.testAssertEqualSingleLinec sltjjrfdd}ndd}|HjddWdn1sT0YWdn1sr0Y|ddWdn1s0Yddg}ddg}|Hj||Wdn1s0YWdn1s0Y|Rj$t |t |Wdn1s^0YWdn1s~0Y|Nj  |t |Wdn1s0YWdn1s0Y|Nj  t ||Wdn1s*0YWdn1sJ0Y|Jj ddWdn1s0YWdn1s0Y|Rj$ t |t |Wdn1s0YWdn1s0Yj |t |Wdn1sT0Yj t ||Wdn1s0Yddg}dg}j||Wdn1s0Yj$t |t |Wdn1s0Yj  |t |Wdn1sZ0Yj  t ||Wdn1s0Yj$ t |t |Wdn1s0Ydg}ddg}j||Wdn1s"0Yj$t |t |Wdn1sd0Yj  |t |Wdn1s0Yj  t ||Wdn1s0Yj$ t |t |Wdn1s"0Y|Rj$ ddiddiWdn1sl0YWdn1s0Yj  iddiWdn1s0Yj  ddiiWdn1s0Yj$ddggdWdn1sJ0Y|$ddgddgWdn1s0Y|Rj$ddgddgWdn1s0YWdn1s0Y|Vj(ddggddggWdn1s>0YWdn1s^0YdS)Ncs tdS)Nz#Comparison between bytes and string)assertWarnsRegex BytesWarningrrrr bytes_warning}sz=Test_TestCase.testEqualityBytesWarning..bytes_warningcSstSr) contextlib ExitStackrrrrr+srar)r.r.r.)sysflagsr+r5r6r3ZassertNotEqualrrrrr!rrr)rr+rrrrrtestEqualityBytesWarning{s~H*JTPPLT00,4004,4004T0044Tz&Test_TestCase.testEqualityBytesWarningcCs<|d||j|jd|d||j|jddS)NFzDjZoPloGears on Rails)rr5r6ZassertIsNotNonerrrrtestAssertIsNones  zTest_TestCase.testAssertIsNonecCs$|dd||j|jdddS)NZ asdfabasdfzab+ZsaaasZaaaa)Z assertRegexr5r6rrrrtestAssertRegexs  zTest_TestCase.testAssertRegexcsGdddtfdd}|||tf||jttddd||j |dd Wdn1s|0Y|t|dWdn1s0Y||t|Wdn1s0YdS) Nc@s eZdZdS)z=Test_TestCase.testAssertRaisesCallable..ExceptionMockNrrrrrrr ExceptionMocksr5cs ddSN We expectrrr5rrStubsz4Test_TestCase.testAssertRaisesCallable..Stub19basecSsdSNrrrrrrr rz8Test_TestCase.testAssertRaisesCallable..) Exceptionr5r<intr6 TypeErrorrr9rr8rtestAssertRaisesCallables  . * z&Test_TestCase.testAssertRaisesCallablec s,Gdddtfdd}||Wdn1sB0Y|tf}|Wdn1sv0Y||j||jjdd|ttddd Wdn1s0Y||j<|Wdn1s0YWdn1s(0Y| |jd @|jd d Wdn1sh0YWdn1s0Y| t d @|jd d Wdn1s0YWdn1s0Y||t|Wdn1s0YdS)Nc@s eZdZdS)z.ExceptionMockNr4rrrrr5sr5cs ddSr6rrr8rrr9sz3Test_TestCase.testAssertRaisesContext..Stubrr7r:r;r<rr*r) r?r5r<rrr3rr@r6assertRaisesRegexrA)rr9rrr8rtestAssertRaisesContexts*  $$ * @@@ z%Test_TestCase.testAssertRaisesContextcCs|t|Wdn1s(0Y|t|dWdn1s\0Y|t|tWdn1s0Y|t|tdfWdn1s0Y|t|ttfWdn1s0YdSNr@)r5rArr<rrrrtestAssertRaisesNoExceptionTypes & ( ( , z-Test_TestCase.testAssertRaisesNoExceptionTypecCs4dd}t|}|t|||t|dS)NcSs$ztWntytYn0dSr)r<rrrrfuncs z4Test_TestCase.testAssertRaisesRefcount..func)r/ getrefcountr5r<r3)rrJZrefcountrrrtestAssertRaisesRefcounts  z&Test_TestCase.testAssertRaisesRefcountcszGdddtfdd}|td||d||t|ddWdn1sl0YdS)Nc@s eZdZdS)z:Test_TestCase.testAssertRaisesRegex..ExceptionMockNr4rrrrr5 sr5cs ddSr6rrr8rrr9#sz1Test_TestCase.testAssertRaisesRegex..Stubzexpect$)r?rFrecompiler5rArBrr8rtestAssertRaisesRegexs   z#Test_TestCase.testAssertRaisesRegexc Cs||jd|jttddd||jd|jtddd||jd@|jtdddWdn1st0YWdn1s0Y|td@|jtdd d Wdn1s0YWdn1s0YdS) Nz"^Exception not raised by $rcSsdSrrrrrrr /rz8Test_TestCase.testAssertNotRaisesRegex..cSsdSrrrrrrr 3rrexpectrrDrE)rFr6r?rMrNrArrrrtestAssertNotRaisesRegex+s <z&Test_TestCase.testAssertNotRaisesRegexcCs*Gdddt}|t|j|dddS)Nc@s eZdZdS)z>Test_TestCase.testAssertRaisesRegexInvalidRegex..MyExcNr4rrrrMyExc?srRcSsdSNTrrrrrr ArzATest_TestCase.testAssertRaisesRegexInvalidRegex..)r?r5rArF)rrRrrr!testAssertRaisesRegexInvalidRegex=sz/Test_TestCase.testAssertRaisesRegexInvalidRegexcCs*Gdddt}|t|j|dddS)Nc@s eZdZdS)z>Test_TestCase.testAssertWarnsRegexInvalidRegex..MyWarnNr4rrrrMyWarnEsrUcSsdSrSrrrrrr Grz@Test_TestCase.testAssertWarnsRegexInvalidRegex..)Warningr5rAr))rrUrrr testAssertWarnsRegexInvalidRegexCsz.Test_TestCase.testAssertWarnsRegexInvalidRegexc CsBdd}||jd|jtd|||jd|jttd|dS)NcSs tddS)NZ Unexpected)r?rrrrr9Jsz9Test_TestCase.testAssertRaisesRegexMismatch..Stubz*"\^Expected\$" does not match "Unexpected"z ^Expected$)rFr6r?rMrNrBrrrtestAssertRaisesRegexMismatchIs z+Test_TestCase.testAssertRaisesRegexMismatchcs~Gdddtfdd}d}|}|||Wdn1sL0Y|j}||||jd|dS)Nc@s eZdZdS)z=Test_TestCase.testAssertRaisesExcValue..ExceptionMockNr4rrrrr5Ysr5cs |dSrr)r r8rrr9\sz4Test_TestCase.testAssertRaisesExcValue..Stubzparticular valuer)r?r5rrr3r)rr9vctxrrr8rtestAssertRaisesExcValueXs  & z&Test_TestCase.testAssertRaisesExcValuecCsN|t|Wdn1s(0Y|t|tWdn1s\0Y|t|ddWdn1s0Y|t|tdWdn1s0Y|t |tdfdWdn1s0Y|t |ttfdWdn1s@0YdSNr@rP)r5rArFr<rrrrr$testAssertRaisesRegexNoExceptionTypegs & ( * * 0 z2Test_TestCase.testAssertRaisesRegexNoExceptionTypec Csdd}|t||t||ttf||jttjdtd||j |tddWdn1sv0Y|t|tdWdn1s0YtTt dt||j|t|Wdn1s0YWdn1s0YtTt dt|t|t|Wdn1sh0YWdn1s0YdS) NcSstdtdSrrwarnRuntimeWarningrrrr _runtime_warnvsz._runtime_warnr categorycSsdSr>rrrrrr rz7Test_TestCase.testAssertWarnsCallable..defaultr&) assertWarnsr`rrr_r5r6rArrrrarrrtestAssertWarnsCallableus&  . *  J   z%Test_TestCase.testAssertWarnsCallablec Csrdd}t|d}|t}|Wdn1s<0Y|ttf}|Wdn1sp0Y||jt||jjdd| d|j ||j |d|t||Wdn1s0Y|tt j dtdWdn1s"0Y||j<|tWdn1s\0YWdn1s|0Y||jd@|jtdd Wdn1s0YWdn1s0Y|td@|jtd d Wdn1s0YWdn1s:0Yt |t d t||jB|t|Wdn1s0YWdn1s0YWdn1s0Yt zt d t|tB|t|Wdn1s$0YWdn1sD0YWdn1sd0YdS)NcSstdtdSrr^rrrrrasz;Test_TestCase.testAssertWarnsContext.._runtime_warnr@rr test_case.pyrbrrrDrErdr&)inspectgetsourcelinesrer`rrwarningr3rrfilenamelinenorr_r5r6rFrArrrraZ_runtime_warn_linenorrrrtestAssertWarnsContextsD $$ $ . @@@   f    z$Test_TestCase.testAssertWarnsContextcCsJ|t|Wdn1s(0Y|t|dWdn1s\0Y|t|tWdn1s0Y|t|tdfWdn1s0Y|t|ttfWdn1s0Y|t|ttfWdn1s<0YdSrH)r5rArer UserWarningr?rrrrtestAssertWarnsNoExceptionTypes & ( ( , . z,Test_TestCase.testAssertWarnsNoExceptionTypec Csdd}|td|d||j"|tdddWdn1sL0Y|t|tddWdn1s0YtXtdt||j |td|dWdn1s0YWdn1s0Y||j |td|dWdn1s20Yt^td t|t|jf |td|dWdn1s0YWdn1s0YdS) NcSst|tdSrr^rrrrraszATest_TestCase.testAssertWarnsRegexCallable.._runtime_warno+fooxcSsdSr>rrrrrr rz.rdbarzr&) r)r`r5r6rArrrrrfrrrtestAssertWarnsRegexCallables4" ,  @$  z*Test_TestCase.testAssertWarnsRegexCallablec CsFdd}t|d}|td}|dWdn1s@0Y||jt||jjdd|d|j ||j |d| |j <|tdWdn1s0YWdn1s0Y| |j dB|jtddd Wdn1s0YWdn1s<0Y| tdB|jtdd d Wdn1s|0YWdn1s0Yttd t| |j F|td|dWdn1s0YWdn1s0YWdn1s60Y| |j F|td|d Wdn1sz0YWdn1s0Yttdt| t|j fF|td|d Wdn1s0YWdn1s0YWdn1s80YdS)NcSst|tdSrr^rrrrrasz@Test_TestCase.testAssertWarnsRegexContext.._runtime_warnr@rrrsrrhrrrDrErdrtr&)rirjr)r`rrkr3rrrlrmr5r6rFrArrrrrnrrrtestAssertWarnsRegexContexts<&<@@  hH  z)Test_TestCase.testAssertWarnsRegexContextcCs|t|Wdn1s(0Y|t|tWdn1s\0Y|t|ddWdn1s0Y|t|tdWdn1s0Y|t |tdfdWdn1s0Y|t |ttfdWdn1s@0Y|t |ttfdWdn1s|0YdSr\)r5rAr)rprr?rrrr#testAssertWarnsRegexNoExceptionTypes & ( * * 0 0 z1Test_TestCase.testAssertWarnsRegexNoExceptionTypeccs@t}dVWdn1s"0Y||ddS)Nr)r r3getvalue)rbufrrrassertNoStderr-s$zTest_TestCase.assertNoStderrcCs^|t|t|t||D]:\}}||tj|D]\}}|t|||q.)Fr@r2rr1)rrrr cSsidSrrrrrrr r)rrN) failIfEqualZassertNotEqualsfailUnlessEqualZ assertEqualsfailUnlessAlmostEqualZassertAlmostEqualsfailIfAlmostEqualZassertNotAlmostEquals failUnlessZassert_failUnlessRaisesrAfailIfrrZassertRaisesRegexpKeyErrorZassertRegexpMatchesrer)roldmethrrrrtestDeprecatedMethodNamess&  z'Test_TestCase.testDeprecatedMethodNamesc Cs`tjdddkrdSgd}|D]8}|tt||Wdq"1sP0Yq"dS)z9Test that the deprecated fail* methods get removed in 3.xNr2r)rrrrrrrr)r/ version_infor5r7r)rZdeprecated_namesZdeprecated_namerrr_testDeprecatedFailMethodss  z(Test_TestCase._testDeprecatedFailMethodscCs&Gdddtj}|d}t|dS)Nc@seZdZddZdS)z0Test_TestCase.testDeepcopy..TestableTestcSsdSrrrrrr testNothingsz.TestableTest.testNothingN)rrrrrrrr TestableTestsrr)r+r,r)rrrrrr testDeepcopyszTest_TestCase.testDeepcopycCsVtd}ttjdD]8}tj||d}t|}||||ttqdS)Nr8r@)protocol) r+r,rpickleHIGHEST_PROTOCOLdumpsloadsr3r)rrrZ pickled_testZunpickled_testrrr testPickles    zTest_TestCase.testPicklec sdddddGfdddtj}Gfdddtj}Gfd d d tj}Gfd d d tj}||||fD]:}|t|d Wdqz1s0YqzdS)NcSstdSr)KeyboardInterruptrrrr_raisesz3Test_TestCase.testKeyboardInterrupt.._raisecSsdSrrrrrrnothingsz4Test_TestCase.testKeyboardInterrupt..nothingcseZdZZdS)z2Test_TestCase.testKeyboardInterrupt..Test1Nrrrtest_somethingrrrrTest1srcseZdZZZdS)z2Test_TestCase.testKeyboardInterrupt..Test2Nrrrr%rrrrrrTest2srcseZdZZZdS)z2Test_TestCase.testKeyboardInterrupt..Test3Nrrrrr(rrrrTest3srcseZdZfddZdS)z2Test_TestCase.testKeyboardInterrupt..Test4cs|dSrrrrrrrszATest_TestCase.testKeyboardInterrupt..Test4.test_somethingNrrrrrTest4srr)N)r+r,r5rr8)rrrrrklassrrrtestKeyboardInterrupts  z#Test_TestCase.testKeyboardInterruptcsdddddGfdddtj}Gfdddtj}Gfd d d tj}Gfd d d tj}||||fD]:}t}|d ||t|jd||jdqzdS)NcSstddS)Nz some reason)r+ZSkipTestrrrr_skipsz3Test_TestCase.testSkippingEverywhere.._skipcSsdSrrrrrrrsz5Test_TestCase.testSkippingEverywhere..nothingcseZdZZdS)z3Test_TestCase.testSkippingEverywhere..Test1NrrrrrrsrcseZdZZZdS)z3Test_TestCase.testSkippingEverywhere..Test2NrrrrrrrsrcseZdZZZdS)z3Test_TestCase.testSkippingEverywhere..Test3NrrrrrrsrcseZdZfddZdS)z3Test_TestCase.testSkippingEverywhere..Test4cs|dSrrrrrrrszBTest_TestCase.testSkippingEverywhere..Test4.test_somethingNrrrrrrsrrr@)N)r+r,rFr8r3rZskippedtestsRunrrrrrrrGrrrtestSkippingEverywheres z$Test_TestCase.testSkippingEverywherecsdddddGfdddtj}Gfdddtj}Gfd d d tj}Gfd d d tj}||||fD]:}t}|d ||t|jd||jdqzdS)NcSstdSr) SystemExitrrrrrsz,Test_TestCase.testSystemExit.._raisecSsdSrrrrrrrsz-Test_TestCase.testSystemExit..nothingcseZdZZdS)z+Test_TestCase.testSystemExit..Test1NrrrrrrsrcseZdZZZdS)z+Test_TestCase.testSystemExit..Test2NrrrrrrsrcseZdZZZdS)z+Test_TestCase.testSystemExit..Test3Nrrrrrr srcseZdZfddZdS)z+Test_TestCase.testSystemExit..Test4cs|dSrrrrrrrsz:Test_TestCase.testSystemExit..Test4.test_somethingNrrrrrrsrrr@)N)r+r,rFr8r3rerrorsrrrrrtestSystemExits zTest_TestCase.testSystemExitcCsLt}t|}t~||Wdn1s>0YdSr)r+r,weakrefrefrZ disable_gcr)rrwrrrr testNoCycless   zTest_TestCase.testNoCyclescs\GfdddtGfdddtj}dD](}||}|t|jdq.dS)Ncs(eZdZdZfddZfddZdS)z9Test_TestCase.test_no_exception_leak..MyExceptionrcsjd7_t|dSrH) ninstancer?r!rr.rrr!&szBTest_TestCase.test_no_exception_leak..MyException.__init__csjd8_dSrH)rrr.rr__del__*szATest_TestCase.test_no_exception_leak..MyException.__del__N)rrrrr!rrr.rrr/#s r/cs*eZdZfddZejfddZdS)z6Test_TestCase.test_no_exception_leak..TestCasecs dSrrrr.rrr.sz.TestCase.test1cs dSrrrr.rrr1sz.TestCase.test2N)rrrrr+ZexpectedFailurerrr.rrr,-s r,)rrr)r?r+r,r8r r3r)rr,Z method_nameZtestcaserr.rtest_no_exception_leak s z$Test_TestCase.test_no_exception_leakN)qrrrrrZeq_pairsrZne_pairsr9r;r>rBrHrTrZr`rcrgrhrkrlrmryr|r}r~rrrrrrrrrrrrrrrr+ZskipIfr/r0optimizerrrrrrrrrrrrrrrrrrr r"r#r'r(r1r2r3rCrGrIrLrOrQrTrWrXr[r]rgrorqrurvrwr,contextmanagerrzrrrrrrrrrrrrrrrrrrZ cpython_onlyrrrrrrr-8s              %4(  $>(:L    0!,       r-__main__)"r,rrrrMr/r|rrricopyrrrr+Zunittest.test.supportrrrrrZ test.supportr r rrrrrrr,r-rmainrrrrsF