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@s@eZdZGdddejZGdddeZGdddejZdS)Testc@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$srcs4eZdZfddZddZddZddZZS) zTest.LoggingTestCasecsttj|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)rrrr!r%rr( __classcell__rrr#rr 's r N)rrrunittestTestCaserrr 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.testNr/rrrrrhsrriz .Test.test)r*r+r2r3rrrrrtest_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.testNr/rrrrrssrZtestfoozFailed to raise ValueError)r*r+ ValueErrorfailr9rrrtest_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+r2ZcountTestCasesrrrrrtest_countTestCasessz!Test_TestCase.test_countTestCasescCs2Gdddtj}|}|t|tjdS)Nc@seZdZddZdS)z1Test_TestCase.test_defaultTestResult..FoocSsdSrrrrrrrsz9Test_TestCase.test_defaultTestResult..Foo.runTestNrrrrrrrrrsr)r*r+defaultTestResultr2type 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 r7r2rr"rFexpectedrrLr#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"rrrrrCsz_Test_TestCase.test_run_call_order__error_in_setUp_default_result..Foo.defaultTestResultcst|tddSrHrIrrKrrr%szSTest_TestCase.test_run_call_order__error_in_setUp_default_result..Foo.setUp)rrrrCr%r)rrLr#rrsr) startTestRunrMr%rNrO stopTestRunrr r7r2rr"rRrrLr2test_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.testrrrJrrKrrrszBTest_TestCase.test_run_call_order__error_in_test..Foo.testrrrrr)rrLr#rrsrrMr%rr(rNrOrPrQrrLr"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|jSrrTrrrrrCsz^Test_TestCase.test_run_call_order__error_in_test_default_result..Foo.defaultTestResultcst|tddSrZr\rrKrrrszQTest_TestCase.test_run_call_order__error_in_test_default_result..Foo.testrrrrCrr)rrLr#rrsrrUrMr%rr(rNrOrVrWrXrrLr1test_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||ddSrZrrr<rrKrrrszDTest_TestCase.test_run_call_order__failure_in_test..Foo.testr]rrLr#rrsrrMr%rr( addFailurerOrPrQrrLr$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|jSrrTrrrrrCsz`Test_TestCase.test_run_call_order__failure_in_test_default_result..Foo.defaultTestResultcst||ddSrZrcrrKrrrszSTest_TestCase.test_run_call_order__failure_in_test_default_result..Foo.testr`rrLr#rrsr)rUrMr%rr(rerOrVrW)rrRr"rrLr3test_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(rJrrKrrr(szJTest_TestCase.test_run_call_order__error_in_tearDown..Foo.tearDown)rrrr(r)rrLr#rrsrr^rPrQrrLr&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|jSrrTrrrrrCszbTest_TestCase.test_run_call_order__error_in_tearDown_default_result..Foo.defaultTestResultcst|tddSrhrirrKrrr(szYTest_TestCase.test_run_call_order__error_in_tearDown_default_result..Foo.tearDown)rrrrCr(r)rrLr#rrsrrarWrXrrLr5test_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)rrrrrrC-szOTest_TestCase.test_run_call_order_default_result..Foo.defaultTestResultcSsdSrrrrrrr/szBTest_TestCase.test_run_call_order_default_result..Foo.testN)rrrrCrrrrrr,srr)r*r+r7r@rrr"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?r1r0ir?failurer1r0jr[r)rrsubTestr<rJrrorsrKrrr6s  Hz;Test_TestCase._check_call_order__subtests..Foo.testr]rrLr#rr5srrWrrFr"Zexpected_eventsrrLr_check_call_order__subtests4sz)Test_TestCase._check_call_order__subtestscCs&g}t|}gd}||||dS)N) rMr%rr(addSubTestFailureaddSubTestSuccessryryrzrNrO)rrxrQrrrtest_run_call_order__subtestsLsz+Test_TestCase.test_run_call_order__subtestscCs&g}t|}gd}||||dS)Nrd)rrxrQrrr$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?r1rnrqrr)rrrurvrKrrr`s zCTest_TestCase._check_call_order__subtests_success..Foo.testr]rrLr#rr_srrWrwrrLr#_check_call_order__subtests_success^s z1Test_TestCase._check_call_order__subtests_successcCs8g}t|}gdddgddg}||||dS)N)rMr%rr(rtrz addSuccessrO)rr}rQrrr%test_run_call_order__subtests_successksz3Test_TestCase.test_run_call_order__subtests_successcCs&g}t|}gd}||||dS)N)rMr%rr(r~rO)rr}rQrrr,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?rnrpr1)rrrur<rrKrrrs ((zFTest_TestCase.test_run_call_order__subtests_failfast..Foo.testr]rrLr#rrsr)rMr%rr(ryrO)rfailfastrr r7r2rQrrLr&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)rur'rr"rrtest_as (z8Test_TestCase.test_subtests_failfast..Foo.test_acsr|dWdn1s(0Y||dWdn1sZ0YddS)Nb1rpb2)rur'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+rErZ makeSuiter7r2)rrrFZsuiterRrrrtest_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'rurrrrrs  z5Test_TestCase.test_subtests_debug..Foo.test_aN)rrrrrrrrrsrrrr)r*r+debugr2r@rrrtest_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+assertIsr5AssertionErrorr@rrrtest_failureException__defaultsz,Test_TestCase.test_failureException__defaultcCsVg}t|}Gdddtj}||djt|d|gd}|||dS)Nc@seZdZddZeZdS)zMTest_TestCase.test_failureException__subclassing__explicit_raise..FoocSs tdSr)rJrrrrrszRTest_TestCase.test_failureException__subclassing__explicit_raise..Foo.testNrrrrrJr5rrrrrsrrrMrerOrr*r+rr5rJr7r2rr"rFrrRrrr2test_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.runTestNrBrrrrrsr)r*r+r%r@rrr test_setUpszTest_TestCase.test_setUpcCs Gdddtj}|dS)Nc@seZdZddZdS)z(Test_TestCase.test_tearDown..FoocSsdSrrrrrrrsz0Test_TestCase.test_tearDown..Foo.runTestNrBrrrrrsr)r*r+r(r@rrr test_tearDownszTest_TestCase.test_tearDowncCs(Gdddtj}||tdS)Nc@seZdZddZdS)z"Test_TestCase.test_id..FoocSsdSrrrrrrrsz*Test_TestCase.test_id..Foo.runTestNrBrrrrr sr)r*r+assertIsInstancer3strr@rrrtest_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) defaultResultrrrC szMTest_TestCase.test_run__uses_defaultTestResult..Foo.defaultTestResultN)rrrrrCrrr"rrrs rr)rUrMrr~rOrV)rr*r+r7rr2)rrrFrRrrr 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+rEr7r)rrrFretvalrrrtest_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)rrFZresultInZ resultOutrrr7Cs zOTest_TestCase.test_call__invoking_an_instance_delegates_to_run..Foo.runN)rrrrr7rrrrr?srr)r*rEr+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.testShortDescriptionWithoutDocstringr1z)Docstrings are omitted with -O2 and abovecCs||ddS)Nz7Tests shortDescription() for a method with a docstring.r2rrrrr(testShortDescriptionWithOneLineDocstringOsz6Test_TestCase.testShortDescriptionWithOneLineDocstringcCs||ddS)Nz>Tests shortDescription() for a method with a longer docstring.rrrrr*testShortDescriptionWithMultiLineDocstringWs z8Test_TestCase.testShortDescriptionWithMultiLineDocstringcCs||ddS)NzATests shortDescription() whitespace is trimmed, so that the firstrrrrr&testShortDescriptionWhitespaceTrimmingesz4Test_TestCase.testShortDescriptionWhitespaceTrimmingcsVGdddt}}|||kdfdd }|||||dS)Nc@s eZdZdS)z7Test_TestCase.testAddTypeEqualityFunc..SadSnakeNrrrrrrrSadSnakeosrcs t|t|kokSSr)rD)abmsgrrrAllSnakesCreatedEqualsszDTest_TestCase.testAddTypeEqualityFunc..AllSnakesCreatedEqual)N)object assertFalseZaddTypeEqualityFuncr2)rs1s2rrrrtestAddTypeEqualityFuncns  z%Test_TestCase.testAddTypeEqualityFunccCs,t}|||||j|j|tdSr)rrr4r5rthingrrr testAssertIs{s zTest_TestCase.testAssertIscCs,t}||t||j|j||dSr)rZ assertIsNotr4r5rrrrtestAssertIsNotszTest_TestCase.testAssertIsNotcCs(g}||t||j|j|tdSr)rlistr4r5dictrrrrtestAssertIsInstances   z"Test_TestCase.testAssertIsInstancecCs(g}||t||j|j|tdSr)ZassertNotIsInstancerr4r5rrrrrtestAssertNotIsInstances   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)monkeycowZsealrabcr1rmrdrZotterxZelephantrr?r)assertIn assertNotInr4r5)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?r1rroner)rrcss|]}t|VqdSr)chr).0rorrr rz=Test_TestCase.testAssertDictContainsSubset..r u�) warningscatch_warnings simplefilterDeprecationWarningassertDictContainsSubsetr4r5joinrange)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?r1r0)set frozensetr2r5r<r4)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) assertListEqualassertTupleEqualassertSequenceEqualr4r*r+r5tupleextendassertDictEqualupdate)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?r1rz!assertSequenceEqual did not fail.)r2maxDiffrdifflibZndiffpprintZpformat splitlinesr*case DIFF_OMITTEDlenrr5argsr< assertLessr assertGreaterr)rZseq1Zseq2diffomittederrrrtestAssertSequenceEqualMaxDiffs>           z,Test_TestCase.testAssertSequenceEqualMaxDiffcCsrd|_|dd}tjjtd}||d|d|_|dd}||dd|_|dd}||ddS)Nr?r barfoobarr)r_truncateMessager*rrrr2)rmessagerrrrtestTruncateMessageEs    z!Test_TestCase.testTruncateMessagec Csrtd}dd}||_z|iddiWn6|jyb}z|t|dWYd}~nd}~00|ddS)Nr2cSsdSrrrrrrrtruncateUsz.truncater?rr zassertDictEqual did not fail)r*r+rrr5r2rr<rrrrrrrtestAssertDictEqualTruncatesSs &z*Test_TestCase.testAssertDictEqualTruncatesc Csntd}dd}||_z|ddWn6|jy^}z|t|dWYd}~nd}~00|ddS)Nr2cSsdSrrrrrrraszATest_TestCase.testAssertMultiLineEqualTruncates..truncater rz!assertMultiLineEqual did not fail)r*r+rassertMultiLineEqualr5r2rr<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) r2rr addCleanupr4r5rr 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)rrr4r5r2rr)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)Nrm)r0r1r?)r rbaz)rrr r1r0)r?2rr)rrTrr?d)rrTr? )rrrrrFry@y@rr)r?r?r1)r?r?rrr)rrTrTZaaabccdZabbbcce>)r0r?r)r?rr)r?r0r)rr?r) rassertCountEqualr4r5iterdivmodrrr*utilZ_count_diff_all_purposer2Z_count_diff_hashable)rrrZdiffsrRrrrtestAssertCountEqualsn           ( $          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?rq)rr)rassertSetEqualr4r5r)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) Nr1r?g?g?ZbugZantsbugsant)rZassertGreaterEqualrZassertLessEqualr4r5rrrrtestInequalitysd                        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?)rrr5rsplitr2rZ 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?)r2r5rr$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+r4r5r2ZassertNotEqualrrrrr!rrr)rr+rrrrrtestEqualityBytesWarning{s~H*JTPPLT00,4004,4004T0044Tz&Test_TestCase.testEqualityBytesWarningcCs<|d||j|jd|d||j|jddS)NFzDjZoPloGears on Rails)rr4r5ZassertIsNotNonerrrrtestAssertIsNones  zTest_TestCase.testAssertIsNonecCs$|dd||j|jdddS)NZ asdfabasdfzab+ZsaaasZaaaa)Z assertRegexr4r5rrrrtestAssertRegexs  zTest_TestCase.testAssertRegexcsGdddtfdd}|||tf||jttddd||j |dd Wdn1s|0Y|t|dWdn1s0Y||t|Wdn1s0YdS) Nc@s eZdZdS)z=Test_TestCase.testAssertRaisesCallable..ExceptionMockNrrrrr ExceptionMocksr4cs ddSN We expectrrr4rrStubsz4Test_TestCase.testAssertRaisesCallable..Stub19basecSsdSNrrrrrrr rz8Test_TestCase.testAssertRaisesCallable..) Exceptionr4r;intr5 TypeErrorrr8rr7rtestAssertRaisesCallables  . * 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.ExceptionMockNrrrrrr4sr4cs ddSr5rrr7rrr8sz3Test_TestCase.testAssertRaisesContext..Stubrr6r9r:r;rr*r) r>r4r;rrr2rr?r5assertRaisesRegexr@)rr8rrr7rtestAssertRaisesContexts*  $$ * @@@ z%Test_TestCase.testAssertRaisesContextcCs|t|Wdn1s(0Y|t|dWdn1s\0Y|t|tWdn1s0Y|t|tdfWdn1s0Y|t|ttfWdn1s0YdSNr?)r4r@rr;rrrrtestAssertRaisesNoExceptionTypes & ( ( , z-Test_TestCase.testAssertRaisesNoExceptionTypecCs4dd}t|}|t|||t|dS)NcSs$ztWntytYn0dSr)r;rrrrfuncs z4Test_TestCase.testAssertRaisesRefcount..func)r/ getrefcountr4r;r2)rrIZrefcountrrrtestAssertRaisesRefcounts  z&Test_TestCase.testAssertRaisesRefcountcszGdddtfdd}|td||d||t|ddWdn1sl0YdS)Nc@s eZdZdS)z:Test_TestCase.testAssertRaisesRegex..ExceptionMockNrrrrrr4 sr4cs ddSr5rrr7rrr8#sz1Test_TestCase.testAssertRaisesRegex..Stubzexpect$)r>rErecompiler4r@rArr7rtestAssertRaisesRegexs   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 3rrexpectrrCrD)rEr5r>rLrMr@rrrrtestAssertNotRaisesRegex+s <z&Test_TestCase.testAssertNotRaisesRegexcCs*Gdddt}|t|j|dddS)Nc@s eZdZdS)z>Test_TestCase.testAssertRaisesRegexInvalidRegex..MyExcNrrrrrMyExc?srQcSsdSNTrrrrrr ArzATest_TestCase.testAssertRaisesRegexInvalidRegex..)r>r4r@rE)rrQrrr!testAssertRaisesRegexInvalidRegex=sz/Test_TestCase.testAssertRaisesRegexInvalidRegexcCs*Gdddt}|t|j|dddS)Nc@s eZdZdS)z>Test_TestCase.testAssertWarnsRegexInvalidRegex..MyWarnNrrrrrMyWarnEsrTcSsdSrRrrrrrr Grz@Test_TestCase.testAssertWarnsRegexInvalidRegex..)Warningr4r@r))rrTrrr testAssertWarnsRegexInvalidRegexCsz.Test_TestCase.testAssertWarnsRegexInvalidRegexc CsBdd}||jd|jtd|||jd|jttd|dS)NcSs tddS)NZ Unexpected)r>rrrrr8Jsz9Test_TestCase.testAssertRaisesRegexMismatch..Stubz*"\^Expected\$" does not match "Unexpected"z ^Expected$)rEr5r>rLrMrArrrtestAssertRaisesRegexMismatchIs z+Test_TestCase.testAssertRaisesRegexMismatchcs~Gdddtfdd}d}|}|||Wdn1sL0Y|j}||||jd|dS)Nc@s eZdZdS)z=Test_TestCase.testAssertRaisesExcValue..ExceptionMockNrrrrrr4Ysr4cs |dSrr)r r7rrr8\sz4Test_TestCase.testAssertRaisesExcValue..Stubzparticular valuer)r>r4rrr2r)rr8vctxrrr7rtestAssertRaisesExcValueXs  & z&Test_TestCase.testAssertRaisesExcValuecCsN|t|Wdn1s(0Y|t|tWdn1s\0Y|t|ddWdn1s0Y|t|tdWdn1s0Y|t |tdfdWdn1s0Y|t |ttfdWdn1s@0YdSNr?rO)r4r@rEr;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^r4r5r@rrrr`rrrtestAssertWarnsCallableus&  . *  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]rrrrr`sz;Test_TestCase.testAssertWarnsContext.._runtime_warnr?rr test_case.pyrarrrCrDrcr&)inspectgetsourcelinesrdr_rrwarningr2rrfilenamelinenorr^r4r5rEr@rrrr`Z_runtime_warn_linenorrrrtestAssertWarnsContextsD $$ $ . @@@   f    z$Test_TestCase.testAssertWarnsContextcCsJ|t|Wdn1s(0Y|t|dWdn1s\0Y|t|tWdn1s0Y|t|tdfWdn1s0Y|t|ttfWdn1s0Y|t|ttfWdn1s<0YdSrG)r4r@rdr 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]rrrrr`szATest_TestCase.testAssertWarnsRegexCallable.._runtime_warno+fooxcSsdSr=rrrrrr rz.rcbarzr&) r)r_r4r5r@rrrrrerrrtestAssertWarnsRegexCallables4" ,  @$  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]rrrrr`sz@Test_TestCase.testAssertWarnsRegexContext.._runtime_warnr?rqrrrrgrrrCrDrcrsr&)rhrir)r_rrjr2rrrkrlr4r5rEr@rrrrrmrrrtestAssertWarnsRegexContexts<&<@@  hH  z)Test_TestCase.testAssertWarnsRegexContextcCs|t|Wdn1s(0Y|t|tWdn1s\0Y|t|ddWdn1s0Y|t|tdWdn1s0Y|t |tdfdWdn1s0Y|t |ttfdWdn1s@0Y|t |ttfdWdn1s|0YdSr[)r4r@r)rorr>rrrr#testAssertWarnsRegexNoExceptionTypes & ( * * 0 0 z1Test_TestCase.testAssertWarnsRegexNoExceptionTypeccs@t}dVWdn1s"0Y||ddS)Nr)r r2getvalue)rbufrrrassertNoStderr-s$zTest_TestCase.assertNoStderrcCs^|t|t|t||D]:\}}||tj|D]\}}|t|||q.)Fr?r1rr0)rrrr cSsidSrrrrrrr r)rr) failIfEqualZassertNotEqualsfailUnlessEqualZ assertEqualsfailUnlessAlmostEqualZassertAlmostEqualsfailIfAlmostEqualZassertNotAlmostEquals failUnlessZassert_failUnlessRaisesr@failIfrrZassertRaisesRegexpKeyErrorZassertRegexpMatchesrdr)roldmethrrrrtestDeprecatedMethodNamess&  z'Test_TestCase.testDeprecatedMethodNamesc Cs`tjdddkrdSgd}|D]8}|tt||Wdq"1sP0Yq"dS)Nr1r)rrrrrrrr)r/ version_infor4r6r~)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)Nr7r?)protocol) r*r+rpickleHIGHEST_PROTOCOLdumpsloadsr2r)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+r4rr7)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+rEr7r2rZskippedtestsRunrrrrrrrFrrrtestSkippingEverywheres 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+rEr7r2rerrorsrrrrrtestSystemExits 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|dSrG) ninstancer>r!rr-rrr!&szBTest_TestCase.test_no_exception_leak..MyException.__init__csjd8_dSrG)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+r7r r2r)rr+Z method_nameZtestcaserr-rtest_no_exception_leak s z$Test_TestCase.test_no_exception_leakN)qrrrrrZeq_pairsrZne_pairsr8r:r=rArGrSrYr_rbrfrgrjrkrlrxr{r|r}rrrrrrrrrrrrrrrr*ZskipIfr/r0optimizerrrrrrrrrrrrrrrrrrr r"r#r'r(r1r2r3rBrFrHrKrNrPrSrVrWrZr\rfrnrprtrurvr,contextmanagerryrrrrrrrrrrrrrrrrrrZ cpython_onlyrrrrrrr,8s              %4(  $>(:L    0!,       r,__main__)"r,rrrrLr/r{rrrhcopyrrrr*Zunittest.test.supportrrrrrZ test.supportr r rrrrrrr+r,rmainrrrrsF