a :dg@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddlZddlmZmZmZmZmZddlmZedZedZedZGd d d eZGd d d ejeeZed kre dS)N)deepcopy)support) TestEquality TestHashing LoggingResultLegacyLoggingResult#ResultWithNoStartTestRunStopTestRun)captured_stderrfoofoo.barquuxc@s@eZdZGdddejZGdddeZGdddejZdS)Testc@seZdZddZddZdS)zTest.FoocCsdSNselfrr3/usr/local/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)superr LoggingTestCase__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 rN)rrrunittestTestCaserrrrrrrr sr c@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.testNrrrrrrrrrr Ssr iz .Test.runTest)r)r* assertEqualid assertRaisesfailureExceptionAttributeErrorrun)rr rrrrtest_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.rrrrr hsr riz .Test.test)r)r*r1r2rr rrrtest_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.rrrrr ssr ZtestfoozFailed to raise ValueError)r)r* ValueErrorfailr8rrrtest_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*r1ZcountTestCasesrrrrrtest_countTestCasessz!Test_TestCase.test_countTestCasescCs2Gdddtj}|}|t|tjdS)Nc@seZdZddZdS)z1Test_TestCase.test_defaultTestResult..FoocSsdSrrrrrrrsz9Test_TestCase.test_defaultTestResult..Foo.runTestNrrrrrrrrrsr)r)r*defaultTestResultr1type 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$addErrorstopTestrr rr6r1rr!rEexpectedrrKr#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!rrrrrBsz_Test_TestCase.test_run_call_order__error_in_setUp_default_result..Foo.defaultTestResultcst|tddSrGrHrrJrrr$szSTest_TestCase.test_run_call_order__error_in_setUp_default_result..Foo.setUp)rrrrBr$r(rrKr"rrsr) startTestRunrLr$rMrN stopTestRunr rr6r1rr!rQrrKr2test_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.testrrrIrrJrrrszBTest_TestCase.test_run_call_order__error_in_test..Foo.testrrrrr(rrKr"rrsrrLr$rr'rMrNrOrPrrKr"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|jSrrSrrrrrBsz^Test_TestCase.test_run_call_order__error_in_test_default_result..Foo.defaultTestResultcst|tddSrYr[rrJrrrszQTest_TestCase.test_run_call_order__error_in_test_default_result..Foo.testrrrrBrr(rrKr"rrsrrTrLr$rr'rMrNrUrVrWrrKr1test_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||ddSrYrrr;rrJrrrszDTest_TestCase.test_run_call_order__failure_in_test..Foo.testr\rrKr"rrsrrLr$rr' addFailurerNrOrPrrKr$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|jSrrSrrrrrBsz`Test_TestCase.test_run_call_order__failure_in_test_default_result..Foo.defaultTestResultcst||ddSrYrbrrJrrrszSTest_TestCase.test_run_call_order__failure_in_test_default_result..Foo.testr_rrKr"rrsr)rTrLr$rr'rdrNrUrV)rrQr!rrKr3test_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'rIrrJrrr'szJTest_TestCase.test_run_call_order__error_in_tearDown..Foo.tearDown)rrrr'r(rrKr"rrsrr]rOrPrrKr&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|jSrrSrrrrrBszbTest_TestCase.test_run_call_order__error_in_tearDown_default_result..Foo.defaultTestResultcst|tddSrgrhrrJrrr'szYTest_TestCase.test_run_call_order__error_in_tearDown_default_result..Foo.tearDown)rrrrBr'r(rrKr"rrsrr`rVrWrrKr5test_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)rrrrrrB-szOTest_TestCase.test_run_call_order_default_result..Foo.defaultTestResultcSsdSrrrrrrr/szBTest_TestCase.test_run_call_order_default_result..Foo.testN)rrrrBrrrrrr,srr)r)r*r6r?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>r0r/ir>failurer0r/jrZr)rrsubTestr;rIrrnrrrJrrr6s  Hz;Test_TestCase._check_call_order__subtests..Foo.testr\rrKr"rr5srrVrrEr!Zexpected_eventsrrKr_check_call_order__subtests4sz)Test_TestCase._check_call_order__subtestscCs&g}t|}gd}||||dS)N) rLr$rr'addSubTestFailureaddSubTestSuccessrxrxryrMrN)rrwrPrrrtest_run_call_order__subtestsLsz+Test_TestCase.test_run_call_order__subtestscCs&g}t|}gd}||||dS)Nrc)rrwrPrrr$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>r0rmrprq)rrrtrurJrrr`s zCTest_TestCase._check_call_order__subtests_success..Foo.testr\rrKr"rr_srrVrvrrKr#_check_call_order__subtests_success^s z1Test_TestCase._check_call_order__subtests_successcCs8g}t|}gdddgddg}||||dS)N)rLr$rr'rsry addSuccessrN)rr|rPrrr%test_run_call_order__subtests_successksz3Test_TestCase.test_run_call_order__subtests_successcCs&g}t|}gd}||||dS)N)rLr$rr'r}rN)rr|rPrrr,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>rmror0)rrrtr;rrJrrrs ((zFTest_TestCase.test_run_call_order__subtests_failfast..Foo.testr\rrKr"rrsr)rLr$rr'rxrN)rfailfastr rr6r1rPrrKr&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)rtr&rr!rrtest_as (z8Test_TestCase.test_subtests_failfast..Foo.test_acsr|dWdn1s(0Y||dWdn1sZ0YddS)Nb1rob2)rtr&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*rDrZ makeSuiter6r1)rrrEZsuiterQrrrtest_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&rtrrrrrs  z5Test_TestCase.test_subtests_debug..Foo.test_aN)rrrrrrrrrsrrrr)r)r*debugr1r?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*assertIsr4AssertionErrorr?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)rIrrrrrszRTest_TestCase.test_failureException__subclassing__explicit_raise..Foo.testNrrrrrIr4rrrrrsrrrLrdrNrr)r*rr4rIr6r1rr!rErrQrrr2test_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.runTestNrArrrrrsr)r)r*r$r?rrr test_setUpszTest_TestCase.test_setUpcCs Gdddtj}|dS)Nc@seZdZddZdS)z(Test_TestCase.test_tearDown..FoocSsdSrrrrrrrsz0Test_TestCase.test_tearDown..Foo.runTestNrArrrrrsr)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.runTestNrArrrrr sr)r)r*assertIsInstancer2strr?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) defaultResultrrrB szMTest_TestCase.test_run__uses_defaultTestResult..Foo.defaultTestResultN)rrrrrBrrr!rrrs rr)rTrLrr}rNrU)rr)r*r6rr1)rrrErQrrr 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*rDr6r)rrrEretvalrrrtest_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)rrEZresultInZ resultOutrrr6Cs zOTest_TestCase.test_call__invoking_an_instance_delegates_to_run..Foo.runN)rrrrr6rrrrr?srr)r)rDr*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.testShortDescriptionWithoutDocstringr0z)Docstrings are omitted with -O2 and abovecCs||ddS)Nz7Tests shortDescription() for a method with a docstring.r1rrrrr(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)rC)abmsgrrrAllSnakesCreatedEqualsszDTest_TestCase.testAddTypeEqualityFunc..AllSnakesCreatedEqual)N)object assertFalseZaddTypeEqualityFuncr1)rs1s2rrrrtestAddTypeEqualityFuncns  z%Test_TestCase.testAddTypeEqualityFunccCs,t}|||||j|j|tdSr)rrr3r4rthingrrr testAssertIs{s zTest_TestCase.testAssertIscCs,t}||t||j|j||dSr)rZ assertIsNotr3r4rrrrtestAssertIsNotszTest_TestCase.testAssertIsNotcCs(g}||t||j|j|tdSr)rlistr3r4dictrrrrtestAssertIsInstances   z"Test_TestCase.testAssertIsInstancecCs(g}||t||j|j|tdSr)ZassertNotIsInstancerr3r4rrrrrtestAssertNotIsInstances   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)monkeycowZsealrabcr0rlrdrZotterxZelephantrr>r)assertIn assertNotInr3r4)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>r0rroner)rrcss|]}t|VqdSr)chr).0rnrrr rz=Test_TestCase.testAssertDictContainsSubset..r u�) warningscatch_warnings simplefilterDeprecationWarningassertDictContainsSubsetr3r4joinrange)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>r0r/)set frozensetr1r4r;r3)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) assertListEqualassertTupleEqualassertSequenceEqualr3r)r*r4tupleextendassertDictEqualupdate)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>r0rz!assertSequenceEqual did not fail.)r1maxDiffrdifflibZndiffpprintZpformat splitlinesr)case DIFF_OMITTEDlenrr4argsr; assertLessr assertGreaterr)rZseq1Zseq2diffomittederrrrtestAssertSequenceEqualMaxDiffs>           z,Test_TestCase.testAssertSequenceEqualMaxDiffcCsrd|_|dd}tjjtd}||d|d|_|dd}||dd|_|dd}||ddS)Nr>r barfoobarr)r_truncateMessager)rrrr1)rmessagerrrrtestTruncateMessageEs    z!Test_TestCase.testTruncateMessagec Csrtd}dd}||_z|iddiWn6|jyb}z|t|dWYd}~nd}~00|ddS)Nr1cSsdSrrrrrrrtruncateUsz.truncater>rr zassertDictEqual did not fail)r)r*rrr4r1rr;rrrrrrrtestAssertDictEqualTruncatesSs &z*Test_TestCase.testAssertDictEqualTruncatesc Csntd}dd}||_z|ddWn6|jy^}z|t|dWYd}~nd}~00|ddS)Nr1cSsdSrrrrrrraszATest_TestCase.testAssertMultiLineEqualTruncates..truncater rz!assertMultiLineEqual did not fail)r)r*rassertMultiLineEqualr4r1rr;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) r1rr addCleanupr3r4rr exceptionrr)rscmr rrr)rr rrtestAssertEqual_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)rrr3r4r1rr)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)Nrl)r/r0r>)r rbaz)rrr r0r/)r>2rr)rrTrr>d)rrTr> )rrrrrFry@y@rr)r>r>r0)r>r>rrr)rrTrTZaaabccdZabbbcce>)r>rr)r/r>r)r>r/r)rr>r) rassertCountEqualr3r4iterdivmodrrr)utilZ_count_diff_all_purposer1Z_count_diff_hashable)rrrZdiffsrQrrrtestAssertCountEqualsn           ( $          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>rp)rr)rassertSetEqualr3r4r)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) Nr0r>g?g?ZbugZantsbugsant)rZassertGreaterEqualrZassertLessEqualr3r4rrrrtestInequalitysd                        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>)rrr4rsplitr1rZ 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>)r1r4rr#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*r3r4r1ZassertNotEqualrrrrr rrr)rr*rrrrrtestEqualityBytesWarning{s~H*JTPPLT00,4004,4004T0044Tz&Test_TestCase.testEqualityBytesWarningcCs<|d||j|jd|d||j|jddS)NFzDjZoPloGears on Rails)rr3r4ZassertIsNotNonerrrrtestAssertIsNones  zTest_TestCase.testAssertIsNonecCs$|dd||j|jdddS)NZ asdfabasdfzab+ZsaaasZaaaa)Z assertRegexr3r4rrrrtestAssertRegexs  zTest_TestCase.testAssertRegexcsGdddtfdd}|||tf||jttddd||j |dd Wdn1s|0Y|t|dWdn1s0Y||t|Wdn1s0YdS) Nc@s eZdZdS)z=Test_TestCase.testAssertRaisesCallable..ExceptionMockNrrrrr ExceptionMocksr3cs ddSN We expectrrr3rrStubsz4Test_TestCase.testAssertRaisesCallable..Stub19basecSsdSNrrrrrrr rz8Test_TestCase.testAssertRaisesCallable..) Exceptionr3r:intr4 TypeErrorrr7rr6rtestAssertRaisesCallables  . * 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.ExceptionMockNrrrrrr3sr3cs ddSr4rrr6rrr7sz3Test_TestCase.testAssertRaisesContext..Stubrr5r8r9r:rr*r) r=r3r:rrr1rr>r4assertRaisesRegexr?)rr7rrr6rtestAssertRaisesContexts*  $$ * @@@ z%Test_TestCase.testAssertRaisesContextcCs|t|Wdn1s(0Y|t|dWdn1s\0Y|t|tWdn1s0Y|t|tdfWdn1s0Y|t|ttfWdn1s0YdSNr>)r3r?rr:rrrrtestAssertRaisesNoExceptionTypes & ( ( , z-Test_TestCase.testAssertRaisesNoExceptionTypecCs4dd}t|}|t|||t|dS)NcSs$ztWntytYn0dSr)r:rrrrfuncs z4Test_TestCase.testAssertRaisesRefcount..func)r. getrefcountr3r:r1)rrHZrefcountrrrtestAssertRaisesRefcounts  z&Test_TestCase.testAssertRaisesRefcountcszGdddtfdd}|td||d||t|ddWdn1sl0YdS)Nc@s eZdZdS)z:Test_TestCase.testAssertRaisesRegex..ExceptionMockNrrrrrr3 sr3cs ddSr4rrr6rrr7#sz1Test_TestCase.testAssertRaisesRegex..Stubzexpect$)r=rDrecompiler3r?r@rr6rtestAssertRaisesRegexs   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 3rrexpectrrBrC)rDr4r=rKrLr?rrrrtestAssertNotRaisesRegex+s <z&Test_TestCase.testAssertNotRaisesRegexcCs*Gdddt}|t|j|dddS)Nc@s eZdZdS)z>Test_TestCase.testAssertRaisesRegexInvalidRegex..MyExcNrrrrrMyExc?srPcSsdSNTrrrrrr ArzATest_TestCase.testAssertRaisesRegexInvalidRegex..)r=r3r?rD)rrPrrr!testAssertRaisesRegexInvalidRegex=sz/Test_TestCase.testAssertRaisesRegexInvalidRegexcCs*Gdddt}|t|j|dddS)Nc@s eZdZdS)z>Test_TestCase.testAssertWarnsRegexInvalidRegex..MyWarnNrrrrrMyWarnEsrScSsdSrQrrrrrr Grz@Test_TestCase.testAssertWarnsRegexInvalidRegex..)Warningr3r?r()rrSrrr testAssertWarnsRegexInvalidRegexCsz.Test_TestCase.testAssertWarnsRegexInvalidRegexc CsBdd}||jd|jtd|||jd|jttd|dS)NcSs tddS)NZ Unexpected)r=rrrrr7Jsz9Test_TestCase.testAssertRaisesRegexMismatch..Stubz*"\^Expected\$" does not match "Unexpected"z ^Expected$)rDr4r=rKrLr@rrrtestAssertRaisesRegexMismatchIs z+Test_TestCase.testAssertRaisesRegexMismatchcs~Gdddtfdd}d}|}|||Wdn1sL0Y|j}||||jd|dS)Nc@s eZdZdS)z=Test_TestCase.testAssertRaisesExcValue..ExceptionMockNrrrrrr3Ysr3cs |dSrr)r r6rrr7\sz4Test_TestCase.testAssertRaisesExcValue..Stubzparticular valuer)r=r3rrr1r)rr7vctxrrr6rtestAssertRaisesExcValueXs  & z&Test_TestCase.testAssertRaisesExcValuecCsN|t|Wdn1s(0Y|t|tWdn1s\0Y|t|ddWdn1s0Y|t|tdWdn1s0Y|t |tdfdWdn1s0Y|t |ttfdWdn1s@0YdSNr>rN)r3r?rDr: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]r3r4r?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.pyr`rrrBrCrbr%)inspectgetsourcelinesrcr^rrwarningr1rrfilenamelinenorr]r3r4rDr?rrrr_Z_runtime_warn_linenorrrrtestAssertWarnsContextsD $$ $ . @@@   f    z$Test_TestCase.testAssertWarnsContextcCsJ|t|Wdn1s(0Y|t|dWdn1s\0Y|t|tWdn1s0Y|t|tdfWdn1s0Y|t|ttfWdn1s0Y|t|ttfWdn1s<0YdSrF)r3r?rcr 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.rbbarzr%) r(r^r3r4r?rrrrrdrrrtestAssertWarnsRegexCallables4" ,  @$  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>rprqrrfrrrBrCrbrrr%)rgrhr(r^rrir1rrrjrkr3r4rDr?rrrrrlrrrtestAssertWarnsRegexContexts<&<@@  hH  z)Test_TestCase.testAssertWarnsRegexContextcCs|t|Wdn1s(0Y|t|tWdn1s\0Y|t|ddWdn1s0Y|t|tdWdn1s0Y|t |tdfdWdn1s0Y|t |ttfdWdn1s@0Y|t |ttfdWdn1s|0YdSrZ)r3r?r(rnrr=rrrr#testAssertWarnsRegexNoExceptionTypes & ( * * 0 0 z1Test_TestCase.testAssertWarnsRegexNoExceptionTypeccs@t}dVWdn1s"0Y||ddS)Nr)r r1getvalue)rbufrrrassertNoStderr-s$zTest_TestCase.assertNoStderrcCs^|t|t|t||D]:\}}||tj|D]\}}|t|||q.)Fr>r0rr/)rrrr cSsidSrrrrrrr r)rr) failIfEqualZassertNotEqualsfailUnlessEqualZ assertEqualsfailUnlessAlmostEqualZassertAlmostEqualsfailIfAlmostEqualZassertNotAlmostEquals failUnlessZassert_failUnlessRaisesr?failIfrrZassertRaisesRegexpKeyErrorZassertRegexpMatchesrcr)roldmethrrrrtestDeprecatedMethodNamess&  z'Test_TestCase.testDeprecatedMethodNamesc Cs`tjdddkrdSgd}|D]8}|tt||Wdq"1sP0Yq"dS)Nr0r)rrrrrrrr)r. version_infor3r5r})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)Nr6r>)protocol) r)r*rpickleHIGHEST_PROTOCOLdumpsloadsr1r)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*r3rr6)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*rDr6r1rZskippedtestsRunrrrrrrrErrrtestSkippingEverywheres 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*rDr6r1rerrorsrrrrrtestSystemExits zTest_TestCase.testSystemExitcCsLt}t|}t~||Wdn1s>0YdSr)r)r*weakrefrefrZ disable_gcr)rrwrrrr testNoCycless   zTest_TestCase.testNoCyclescsVGfdddtGfdddtj}dD]"}||}||jdq.dS)Ncs(eZdZdZfddZfddZdS)z9Test_TestCase.test_no_exception_leak..MyExceptionrcsjd7_t|dSrF) ninstancer=r rr,rrr &szBTest_TestCase.test_no_exception_leak..MyException.__init__csjd8_dSrF)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*r6r1r)rr*Z method_nameZtestcaserr,rtest_no_exception_leak s  z$Test_TestCase.test_no_exception_leakN)qrrrr rZeq_pairsrZne_pairsr7r9r<r@rFrRrXr^rarerfrirjrkrwrzr{r|r~rrrrrrrrrrrrrrr)ZskipIfr.r/optimizerrrrrrrrrrrrrrrrrrrr!r"r&r'r0r1r2rArErGrJrMrOrRrUrVrYr[rermrorsrtrur+contextmanagerrxrrrrrrrrrrrrrrrrrrZ cpython_onlyrrrrrrr+8s              %4(  $>(:L    0!,       r+__main__)!r+rrrrKr.rzrrrgcopyrrrr)Zunittest.test.supportrrrrrZ test.supportr rrrrrr r*r+rmainrrrrsF