fc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z m Z mZmZeZdZGdddeZGd d d eZGd d d eZGd ddeZddZddZddZddZddZddZddZGdddeZ Gdd d e Z!Gd!d"d"e Z"Gd#d$d$eZ#Gd%d&d&e#Z$dS('uTest case implementationiNi(uresult(ustrclassu safe_repru_count_diff_all_purposeu_count_diff_hashableu@ Diff is %s characters long. Set self.maxDiff to None to see it.cBs|EeZdZdZdS(uSkipTestu Raise this exception in a test to skip it. Usually you can use TestCase.skipTest() or one of the skipping decorators instead of raising this directly. N(u__name__u __module__u __qualname__u__doc__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuSkipTestsuSkipTestcs,|EeZdZdZfddZS(u_ExpectedFailureu\ Raise this when a test is expected to fail. This is an implementation detail. cs tt|j||_dS(N(usuperu_ExpectedFailureu__init__uexc_info(uselfuexc_info(u __class__(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__init__%su_ExpectedFailure.__init__(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u __class__u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_ExpectedFailuresu_ExpectedFailurecBs|EeZdZdZdS(u_UnexpectedSuccessu7 The test was supposed to fail, but it didn't! N(u__name__u __module__u __qualname__u__doc__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_UnexpectedSuccess)su_UnexpectedSuccesscBs |EeZdZddZdS(u_OutcomecCs:d|_d|_d|_d|_g|_g|_dS(NT(uTrueusuccessuNoneuskippeduunexpectedSuccessuexpectedFailureuerrorsufailures(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__init__0s      u_Outcome.__init__N(u__name__u __module__u __qualname__u__init__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_Outcome/su_OutcomecCs|S(N((uobj((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_id9su_idcsfdd}|S(u& Unconditionally skip a test. csOt|ts9tj|fdd}|}nd|_|_|S(NcstdS(N(uSkipTest(uargsukwargs(ureason(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu skip_wrapperBsu-skip..decorator..skip_wrapperT(u isinstanceutypeu functoolsuwrapsuTrueu__unittest_skip__u__unittest_skip_why__(u test_itemu skip_wrapper(ureason(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu decorator@s !   uskip..decorator((ureasonu decorator((ureasonu2/opt/alt/python33/lib64/python3.3/unittest/case.pyuskip<s uskipcCs|rt|StS(u/ Skip a test if the condition is true. (uskipu_id(u conditionureason((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuskipIfLs uskipIfcCs|st|StS(u3 Skip a test unless the condition is true. (uskipu_id(u conditionureason((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu skipUnlessTs u skipUnlesscs%tjfdd}|S(Nc sBy||Wn$tk r7ttjYnXtdS(N(u Exceptionu_ExpectedFailureusysuexc_infou_UnexpectedSuccess(uargsukwargs(ufunc(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuwrapper^s  u expectedFailure..wrapper(u functoolsuwraps(ufuncuwrapper((ufuncu2/opt/alt/python33/lib64/python3.3/unittest/case.pyuexpectedFailure]s!uexpectedFailurecCs!dtjkrt|StSdS(u Non-standard/downstream-only decorator for marking a specific unit test to be skipped when run within the %check of an rpmbuild. Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within the environment, and has no effect otherwise. uWITHIN_PYTHON_RPM_BUILDN(uosuenvironuskipu_id(ureason((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_skipInRpmBuildks u_skipInRpmBuildcs%tjfdd}|S(u  Non-standard/downstream-only decorator for marking a specific unit test as expected to fail within the %check of an rpmbuild. Specifically, this takes effect when WITHIN_PYTHON_RPM_BUILD is set within the environment, and has no effect otherwise. c sadtjkrPy||Wn$tk rFttjYnXtn ||dS(NuWITHIN_PYTHON_RPM_BUILD(uosuenvironu Exceptionu_ExpectedFailureusysuexc_infou_UnexpectedSuccess(uargsukwargs(ufunc(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuwrappers  u+_expectedFailureInRpmBuild..wrapper(u functoolsuwraps(ufuncuwrapper((ufuncu2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_expectedFailureInRpmBuildxs! u_expectedFailureInRpmBuildcBs>|EeZdZddddZddZddZdS(u_AssertRaisesBaseContextc Cs||_||_|dk rUy|j|_Wq^tk rQt||_Yq^Xn d|_t|ttfrt j |}n||_ d|_ dS(N( uexpectedu test_caseuNoneu__name__uobj_nameuAttributeErrorustru isinstanceubytesureucompileuexpected_regexumsg(uselfuexpectedu test_caseu callable_objuexpected_regex((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__init__s      u!_AssertRaisesBaseContext.__init__cCs.|jj|j|}|jj|dS(N(u test_caseu_formatMessageumsgufailureException(uselfu standardMsgumsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu _raiseFailuresu&_AssertRaisesBaseContext._raiseFailurec CsC|dkr%|jdd|_|S||||WdQXdS(u If callable_obj is None, assertRaises/Warns is being used as a context manager, so check for a 'msg' kwarg and return self. If callable_obj is not None, call it passing args and kwargs. umsgN(uNoneupopumsg(uselfunameu callable_objuargsukwargs((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuhandles  u_AssertRaisesBaseContext.handleN(u__name__u __module__u __qualname__uNoneu__init__u _raiseFailureuhandle(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_AssertRaisesBaseContexts u_AssertRaisesBaseContextcBs2|EeZdZdZddZddZdS(u_AssertRaisesContextuCA context manager used to implement TestCase.assertRaises* methods.cCs|S(N((uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu __enter__su_AssertRaisesContext.__enter__c Cs|dkry|jj}Wn!tk r?t|j}YnX|jrh|jdj||jq|jdj|nt||jsdS|j d|_ |j dkrdS|j }|jt|s|jdj|jt|ndS(Nu{} not raised by {}u {} not raisedu"{}" does not match "{}"FT(uNoneuexpectedu__name__uAttributeErrorustruobj_nameu _raiseFailureuformatu issubclassuFalseuwith_tracebacku exceptionuexpected_regexuTrueusearchupattern(uselfuexc_typeu exc_valueutbuexc_nameuexpected_regex((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__exit__s&     u_AssertRaisesContext.__exit__N(u__name__u __module__u __qualname__u__doc__u __enter__u__exit__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_AssertRaisesContexts u_AssertRaisesContextcBs2|EeZdZdZddZddZdS(u_AssertWarnsContextuBA context manager used to implement TestCase.assertWarns* methods.cCsvx5tjjD]$}t|ddri|_qqWtjdd|_ |j j |_tj d|j |S(Nu__warningregistry__urecordualwaysT( usysumodulesuvaluesugetattruNoneu__warningregistry__uwarningsucatch_warningsuTrueuwarnings_manageru __enter__u simplefilteruexpected(uselfuv((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu __enter__su_AssertWarnsContext.__enter__c Csp|jj||||dk r&dSy|jj}Wn!tk rYt|j}YnXd}x|jD]}|j}t ||jsqjn|dkr|}n|j dk r|j j t| rqjn||_ |j |_ |j|_dSW|dk r.|jdj|j jt|n|jrV|jdj||jn|jdj|dS(Nu"{}" does not match "{}"u{} not triggered by {}u{} not triggered(uwarnings_manageru__exit__uNoneuexpectedu__name__uAttributeErrorustruwarningsumessageu isinstanceuexpected_regexusearchuwarningufilenameulinenou _raiseFailureuformatupatternuobj_name(uselfuexc_typeu exc_valueutbuexc_nameufirst_matchingumuw((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__exit__s8           u_AssertWarnsContext.__exit__N(u__name__u __module__u __qualname__u__doc__u __enter__u__exit__(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_AssertWarnsContexts u_AssertWarnsContextcBs|EeZdZdZeZdZdZdZ dZ dddZ d d Z d d Zd dZddZeddZeddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zdd'd(Zdd)d*Zd+d,Z d-d.Z!d/d0Z"d1d2Z#dd3d4Z$dd5d6Z%dd7d8Z&d9d:Z'dd;d<Z(dd=d>Z)d?d@Z*ddAdBZ+ddCdDZ,ddEdFZ-ddddGdHZ.ddddIdJZ/dddKdLZ0dMdNZ1ddOdPZ2ddQdRZ3ddSdTZ4ddUdVZ5ddWdXZ6ddYdZZ7dd[d\Z8dd]d^Z9dd_d`Z:ddadbZ;ddcddZ<ddedfZ=ddgdhZ>ddidjZ?ddkdlZ@ddmdnZAddodpZBddqdrZCddsdtZDddudvZEddwdxZFddydzZGdd{d|ZHd}d~ZIeIe,ZJZKeIe-ZLZMeIe.ZNZOeIe/ZPZQeIe&ZRZSeIe(ZTeIe%ZUeIeEZVeIeGZWdS(uTestCaseuWA class whose instances are single test cases. By default, the test code itself should be placed in a method named 'runTest'. If the fixture may be used for many test cases, create as many test methods as are needed. When instantiating such a TestCase subclass, specify in the constructor arguments the name of the test method that the instance is to execute. Test authors should subclass TestCase for their own tests. Construction and deconstruction of the test's environment ('fixture') can be implemented by overriding the 'setUp' and 'tearDown' methods respectively. If it is necessary to override the __init__ method, the base class __init__ method must always be called. It is important that subclasses should not change the signature of their __init__ method, since instances of the classes are instantiated automatically by parts of the framework in order to be run. When subclassing TestCase, you can set these attributes: * failureException: determines which exception will be raised when the instance's assertion methods fail; test methods raising this exception will be deemed to have 'failed' rather than 'errored'. * longMessage: determines whether long messages (including repr of objects used in assert methods) will be printed on failure in *addition* to any explicit message passed. * maxDiff: sets the maximum length of a diff in failure messages by assert methods using difflib. It is looked up as an instance attribute so can be configured by individual tests if required. iPiiiurunTestc Cs||_d |_d|_yt||}Wn:tk rj|dkrftd|j|fnYn X|j|_g|_ i|_ |j t d|j t d|j td|j td|j td|j tdd S( uCreate an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. uNo testurunTestuno such test method in %s: %suassertDictEqualuassertListEqualuassertTupleEqualuassertSetEqualuassertMultiLineEqualN(u_testMethodNameuNoneu_outcomeForDoCleanupsu_testMethodDocugetattruAttributeErroru ValueErroru __class__u__doc__u _cleanupsu_type_equality_funcsuaddTypeEqualityFuncudictulistutupleusetu frozensetustr(uselfu methodNameu testMethod((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__init__1s$        uTestCase.__init__cCs||j|(ustrclassu __class__u_testMethodName(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__repr__suTestCase.__repr__cCsRt|dd}|dk r.|||n tjdtd|j|dS(NuaddSkipu4TestResult has no addSkip method, skips not reportedi(ugetattruNoneuwarningsuwarnuRuntimeWarningu addSuccess(uselfuresultureasonuaddSkip((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_addSkips    uTestCase._addSkipcCsXy |WnFtk r"Yn2tk r^}zd|_t||_WYdd}~Xntk rtj}d|_|r||_ n|j j |Ynt k rd|_tj}|r||_ n|j j |Ynf|jk r-d|_|jj tjtj}Yn'd|_|j j tjYnXdS(NF(uKeyboardInterruptuSkipTestuFalseusuccessustruskippedu_UnexpectedSuccessusysuexc_infouunexpectedSuccessuerrorsuappendu_ExpectedFailureuexpectedFailureufailureExceptionufailures(uselfufunctionuoutcomeuisTestueuexc_info((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_executeTestParts4   !          uTestCase._executeTestPartc Cs|}|dkrI|j}t|dd}|dk rI|qIn|j|t||j}t|jdd st|dd rz;t|jddpt|dd}|j||Wd|j|XdSzt }||_ |j |j ||j r<|j ||dd |j |j|n|j|j r_|j|n-|jdk r|j||jnx!|jD]}|j||qWx!|jD]}|j||qW|jdk r,t|dd}|dk r||q,tjdt|j||jn|jdk rt|dd} | dk rl| ||jqtjd t|j|n|SWd|j||dkrt|d d} | dk r| qnXdS( Nu startTestRunu__unittest_skip__u__unittest_skip_why__uuisTestuaddUnexpectedSuccessuDTestResult has no addUnexpectedSuccess method, reporting as failuresuaddExpectedFailureu@TestResult has no addExpectedFailure method, reporting as passesu stopTestRunFT(uNoneudefaultTestResultugetattru startTestu_testMethodNameu __class__uFalseu_addSkipustopTestu_Outcomeu_outcomeForDoCleanupsu_executeTestPartusetUpusuccessuTrueutearDownu doCleanupsu addSuccessuskippeduerrorsuaddErrorufailuresu addFailureuunexpectedSuccessuwarningsuwarnuRuntimeWarninguexpectedFailure( uselfuresultu orig_resultu startTestRunu testMethoduskip_whyuoutcomeuexc_infouaddUnexpectedSuccessuaddExpectedFailureu stopTestRun((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyurunsh                  u TestCase.runcsi|jpt}xM|jra|jj\fdd}|j||qW|jS(uNExecute all cleanup functions. Normally called for you after tearDown.cs S(N(((uargsufunctionukwargs(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu su%TestCase.doCleanups..(u_outcomeForDoCleanupsu_Outcomeu _cleanupsupopu_executeTestPartusuccess(uselfuoutcomeupart((uargsufunctionukwargsu2/opt/alt/python33/lib64/python3.3/unittest/case.pyu doCleanupss  uTestCase.doCleanupscOs|j||S(N(urun(uselfuargsukwds((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__call__suTestCase.__call__cCsc|jt||j|jx5|jr^|jjd\}}}|||q*WdS(u6Run the test without collecting errors in a TestResultiNi(usetUpugetattru_testMethodNameutearDownu _cleanupsupop(uselfufunctionuargsukwargs((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyudebugs    uTestCase.debugcCst|dS(uSkip this test.N(uSkipTest(uselfureason((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuskipTestsuTestCase.skipTestcCs|j|dS(u)Fail immediately, with the given message.N(ufailureException(uselfumsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyufail su TestCase.failcCs8|r4|j|dt|}|j|ndS(u#Check that the expression is false.u%s is not falseN(u_formatMessageu safe_reprufailureException(uselfuexprumsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertFalse$suTestCase.assertFalsecCs8|s4|j|dt|}|j|ndS(u"Check that the expression is true.u%s is not trueN(u_formatMessageu safe_reprufailureException(uselfuexprumsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertTrue*suTestCase.assertTruec Csh|js|p|S|dkr#|Syd||fSWn,tk rcdt|t|fSYnXdS(uHonour the longMessage attribute when generating failure messages. If longMessage is False this means: * Use only an explicit message if it is provided * Otherwise use the standard message for the assert If longMessage is True: * Use the standard message * If an explicit message is provided, plus ' : ' and the explicit message u%s : %sN(u longMessageuNoneuUnicodeDecodeErroru safe_repr(uselfumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_formatMessage0s    uTestCase._formatMessagecOs(t|||}|jd|||S(u,Fail unless an exception of class excClass is raised by callableObj when invoked with arguments args and keyword arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception. If called with callableObj omitted or None, will return a context object used like this:: with self.assertRaises(SomeException): do_something() An optional keyword argument 'msg' can be provided when assertRaises is used as a context object. The context manager keeps a reference to the exception as the 'exception' attribute. This allows you to inspect the exception after the assertion:: with self.assertRaises(SomeException) as cm: do_something() the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) u assertRaises(u_AssertRaisesContextuhandle(uselfuexcClassu callableObjuargsukwargsucontext((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertRaisesEsuTestCase.assertRaisescOs(t|||}|jd|||S(uFail unless a warning of class warnClass is triggered by callable_obj when invoked with arguments args and keyword arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception. If called with callable_obj omitted or None, will return a context object used like this:: with self.assertWarns(SomeWarning): do_something() An optional keyword argument 'msg' can be provided when assertWarns is used as a context object. The context manager keeps a reference to the first matching warning as the 'warning' attribute; similarly, the 'filename' and 'lineno' attributes give you information about the line of Python code from which the warning was triggered. This allows you to inspect the warning after the assertion:: with self.assertWarns(SomeWarning) as cm: do_something() the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) u assertWarns(u_AssertWarnsContextuhandle(uselfuexpected_warningu callable_objuargsukwargsucontext((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertWarnsbsuTestCase.assertWarnscCskt|t|krd|jjt|}|dk rdt|tr]t||}n|Sn|jS(uGet a detailed comparison function for the types of the two args. Returns: A callable accepting (first, second, msg=None) that will raise a failure exception if first != second with a useful human readable error message for those types. N(utypeu_type_equality_funcsugetuNoneu isinstanceustrugetattru_baseAssertEqual(uselfufirstuseconduasserter((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_getAssertEqualityFuncs uTestCase._getAssertEqualityFunccCsP||ksLdt|t|f}|j||}|j|ndS(u:The default assertEqual implementation, not type specific.u%s != %sN(u safe_repru_formatMessageufailureException(uselfufirstusecondumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_baseAssertEquals uTestCase._baseAssertEqualcCs)|j||}|||d|dS(u[Fail if the two objects are unequal as determined by the '==' operator. umsgN(u_getAssertEqualityFunc(uselfufirstusecondumsguassertion_func((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertEqualsuTestCase.assertEqualcCsJ||ksF|j|dt|t|f}|j|ndS(uYFail if the two objects are equal as determined by the '!=' operator. u%s == %sN(u_formatMessageu safe_reprufailureException(uselfufirstusecondumsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertNotEquals uTestCase.assertNotEqualcCs||krdS|dk r7|dk r7tdn|dk rt|||kr]dSdt|t|t|f}nW|dkrd}ntt|||dkrdSdt|t||f}|j||}|j|dS(uFail if the two objects are unequal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is more than the given delta. Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit). If the two objects compare equal then they will automatically compare almost equal. Nu specify delta or places not bothu%s != %s within %s deltaiiu%s != %s within %r places(uNoneu TypeErroruabsu safe_repruroundu_formatMessageufailureException(uselfufirstuseconduplacesumsgudeltau standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertAlmostEquals&         uTestCase.assertAlmostEqualcCs |dk r'|dk r'tdn|dk r||k rZt|||krZdSdt|t|t|f}nd|dkrd}n||k rtt|||dkrdSdt|t||f}|j||}|j|dS(uFail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is less than the given delta. Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit). Objects that are equal automatically fail. u specify delta or places not bothNu%s == %s within %s deltaiiu%s == %s within %r places(uNoneu TypeErroruabsu safe_repruroundu_formatMessageufailureException(uselfufirstuseconduplacesumsgudeltau standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertNotAlmostEquals"  #    ,   uTestCase.assertNotAlmostEqualc&Cs|dk rz|j}t||sF|jd|t|fnt||s|jd|t|fqnd}d}yt|}Wn"ttfk rd|}YnX|dkryt|}Wqttfk rd|}YqXn|dkr||krdSt|} t|} t| dkr\| ddd} nt| dkr| ddd} n|j| | f} d | }xt t ||D]} y|| } Wn0tt tfk r|d | |f7}PYnXy|| }Wn0tt tfk rA|d | |f7}PYnX| |kr|d | | |f7}PqqW||kr|dkrt |t |krdS||kr|d |||f7}y|d|||f7}Wqtt tfk r|d||f7}YqXq||kr|d|||f7}y|d|||f7}Wqtt tfk r|d||f7}YqXqn|}ddj tjtj|jtj|j}|j||}|j||}|j|dS(uAAn equality assertion for ordered sequences (like lists and tuples). For the purposes of this function, a valid ordered sequence type is one which can be indexed, has a length, and has an equality operator. Args: seq1: The first sequence to compare. seq2: The second sequence to compare. seq_type: The expected datatype of the sequences, or None if no datatype should be enforced. msg: Optional message to use on failure instead of a list of differences. uFirst sequence is not a %s: %suSecond sequence is not a %s: %susequenceu(First %s has no length. Non-sequence?u)Second %s has no length. Non-sequence?Niu...u%ss differ: %s != %s u( Unable to index element %d of first %s u) Unable to index element %d of second %s u# First differing element %d: %s %s u+ First %s contains %d additional elements. uFirst extra element %d: %s u'Unable to index element %d of first %s u, Second %s contains %d additional elements. u(Unable to index element %d of second %s u (uNoneu__name__u isinstanceufailureExceptionu safe_reprulenu TypeErroruNotImplementedErroru capitalizeurangeuminu IndexErrorutypeujoinudifflibundiffupprintupformatu splitlinesu_truncateMessageu_formatMessageufail(uselfuseq1useq2umsguseq_typeu seq_type_nameu differingulen1ulen2u seq1_repru seq2_repruelementsuiuitem1uitem2u standardMsgudiffMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertSequenceEquals               uTestCase.assertSequenceEqualcCsA|j}|dks't||kr/||S|tt|S(N(umaxDiffuNoneulenu DIFF_OMITTED(uselfumessageudiffumax_diff((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu_truncateMessagebs uTestCase._truncateMessagecCs|j|||dtdS(uA list-specific equality assertion. Args: list1: The first list to compare. list2: The second list to compare. msg: Optional message to use on failure instead of a list of differences. useq_typeN(uassertSequenceEqualulist(uselfulist1ulist2umsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertListEqualhs uTestCase.assertListEqualcCs|j|||dtdS(uA tuple-specific equality assertion. Args: tuple1: The first tuple to compare. tuple2: The second tuple to compare. msg: Optional message to use on failure instead of a list of differences. useq_typeN(uassertSequenceEqualutuple(uselfutuple1utuple2umsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertTupleEqualts uTestCase.assertTupleEqualc !Csy|j|}Wnktk rK}z|jd|WYdd}~Xn6tk r}z|jd|WYdd}~XnXy|j|}Wnktk r}z|jd|WYdd}~Xn6tk r}z|jd|WYdd}~XnX|p |sdSg}|rR|jdx$|D]}|jt|q2Wn|r|jdx$|D]}|jt|qlWndj|} |j|j|| dS(uA set-specific equality assertion. Args: set1: The first set to compare. set2: The second set to compare. msg: Optional message to use on failure instead of a list of differences. assertSetEqual uses ducktyping to support different types of sets, and is optimized for sets specifically (parameters must support a difference method). u/invalid type when attempting set difference: %sNu2first argument does not support set difference: %su3second argument does not support set difference: %su*Items in the first set but not the second:u*Items in the second set but not the first:u (u differenceu TypeErrorufailuAttributeErroruappendureprujoinu_formatMessage( uselfuset1uset2umsgu difference1ueu difference2ulinesuitemu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertSetEquals2 #$#$     uTestCase.assertSetEqualcCsH||krDdt|t|f}|j|j||ndS(uDJust like self.assertTrue(a in b), but with a nicer default message.u%s not found in %sN(u safe_reprufailu_formatMessage(uselfumemberu containerumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertIns  uTestCase.assertIncCsH||krDdt|t|f}|j|j||ndS(uHJust like self.assertTrue(a not in b), but with a nicer default message.u%s unexpectedly found in %sN(u safe_reprufailu_formatMessage(uselfumemberu containerumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertNotIns  uTestCase.assertNotIncCsH||k rDdt|t|f}|j|j||ndS(uDJust like self.assertTrue(a is b), but with a nicer default message.u %s is not %sN(u safe_reprufailu_formatMessage(uselfuexpr1uexpr2umsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertIss  uTestCase.assertIscCs?||kr;dt|f}|j|j||ndS(uHJust like self.assertTrue(a is not b), but with a nicer default message.uunexpectedly identical: %sN(u safe_reprufailu_formatMessage(uselfuexpr1uexpr2umsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertIsNots uTestCase.assertIsNotcCs|j|td|j|td||krdt|dt|df}ddjtjtj|j tj|j }|j ||}|j |j ||ndS(Nu"First argument is not a dictionaryu#Second argument is not a dictionaryu%s != %su T( uassertIsInstanceudictu safe_repruTrueujoinudifflibundiffupprintupformatu splitlinesu_truncateMessageufailu_formatMessage(uselfud1ud2umsgu standardMsgudiff((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertDictEquals "uTestCase.assertDictEqualc Cs'tjdtg}g}xy|jD]k\}}||krQ|j|q)|||kr)|jdt|t|t||fq)q)W|p|sdSd}|rddjdd|D}n|r |r|d 7}n|d dj|7}n|j|j||dS( u2Checks whether dictionary is a superset of subset.u&assertDictContainsSubset is deprecatedu%s, expected: %s, actual: %sNuu Missing: %su,css|]}t|VqdS(N(u safe_repr(u.0um((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu su4TestCase.assertDictContainsSubset..u; uMismatched values: %s( uwarningsuwarnuDeprecationWarninguitemsuappendu safe_reprujoinufailu_formatMessage( uselfusubsetu dictionaryumsgumissingu mismatchedukeyuvalueu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertDictContainsSubsets,     u!TestCase.assertDictContainsSubsetc Cst|t|}}y"tj|}tj|}Wn!tk r^t||}Yn X||krodSt||}|rd}dd|D}dj|} |j|| }|j||}|j |ndS(uAn unordered sequence comparison asserting that the same elements, regardless of order. If the same element occurs more than once, it verifies that the elements occur the same number of times. self.assertEqual(Counter(list(first)), Counter(list(second))) Example: - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal. NuElement counts were not equal: cSsg|]}d|qS(u First has %d, Second has %d: %r((u.0udiff((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu s u-TestCase.assertCountEqual..u ( ulistu collectionsuCounteru TypeErroru_count_diff_all_purposeu_count_diff_hashableujoinu_truncateMessageu_formatMessageufail( uselfufirstusecondumsgu first_sequ second_sequ differencesu standardMsgulinesudiffMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertCountEquals   uTestCase.assertCountEqualcCsM|j|td|j|td||krIt||jks\t||jkrr|j|||n|jdd }|jdd }t|dkr|jd|kr|dg}|dg}ndt|d t|d f}ddj t j ||}|j ||}|j |j||nd S( u-Assert that two multi-line strings are equal.uFirst argument is not a stringuSecond argument is not a stringukeependsiu u u%s != %suNT(uassertIsInstanceustrulenu_diffThresholdu_baseAssertEqualu splitlinesuTrueustripu safe_reprujoinudifflibundiffu_truncateMessageufailu_formatMessage(uselfufirstusecondumsgu firstlinesu secondlinesu standardMsgudiff((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertMultiLineEquals  ' uTestCase.assertMultiLineEqualcCsH||ksDdt|t|f}|j|j||ndS(uCJust like self.assertTrue(a < b), but with a nicer default message.u%s not less than %sN(u safe_reprufailu_formatMessage(uselfuaubumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertLess$s uTestCase.assertLesscCsH||ksDdt|t|f}|j|j||ndS(uDJust like self.assertTrue(a <= b), but with a nicer default message.u%s not less than or equal to %sN(u safe_reprufailu_formatMessage(uselfuaubumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertLessEqual*s uTestCase.assertLessEqualcCsH||ksDdt|t|f}|j|j||ndS(uCJust like self.assertTrue(a > b), but with a nicer default message.u%s not greater than %sN(u safe_reprufailu_formatMessage(uselfuaubumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertGreater0s uTestCase.assertGreatercCsH||ksDdt|t|f}|j|j||ndS(uDJust like self.assertTrue(a >= b), but with a nicer default message.u"%s not greater than or equal to %sN(u safe_reprufailu_formatMessage(uselfuaubumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertGreaterEqual6s uTestCase.assertGreaterEqualcCs?|dk r;dt|f}|j|j||ndS(uCSame as self.assertTrue(obj is None), with a nicer default message.u%s is not NoneN(uNoneu safe_reprufailu_formatMessage(uselfuobjumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertIsNone<s uTestCase.assertIsNonecCs2|dkr.d}|j|j||ndS(u(Included for symmetry with assertIsNone.uunexpectedly NoneN(uNoneufailu_formatMessage(uselfuobjumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertIsNotNoneBs uTestCase.assertIsNotNonecCsEt||sAdt||f}|j|j||ndS(uTSame as self.assertTrue(isinstance(obj, cls)), with a nicer default message.u%s is not an instance of %rN(u isinstanceu safe_reprufailu_formatMessage(uselfuobjuclsumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertIsInstanceHsuTestCase.assertIsInstancecCsEt||rAdt||f}|j|j||ndS(u,Included for symmetry with assertIsInstance.u%s is an instance of %rN(u isinstanceu safe_reprufailu_formatMessage(uselfuobjuclsumsgu standardMsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertNotIsInstanceOsuTestCase.assertNotIsInstancecOs+t||||}|jd|||S(uAsserts that the message in a raised exception matches a regex. Args: expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertRaisesRegex is used as a context manager. args: Extra args. kwargs: Extra kwargs. uassertRaisesRegex(u_AssertRaisesContextuhandle(uselfuexpected_exceptionuexpected_regexu callable_objuargsukwargsucontext((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertRaisesRegexUs  uTestCase.assertRaisesRegexcOs+t||||}|jd|||S(uAsserts that the message in a triggered warning matches a regexp. Basic functioning is similar to assertWarns() with the addition that only warnings whose messages also match the regular expression are considered successful matches. Args: expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. args: Extra args. kwargs: Extra kwargs. uassertWarnsRegex(u_AssertWarnsContextuhandle(uselfuexpected_warninguexpected_regexu callable_objuargsukwargsucontext((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertWarnsRegexhs  uTestCase.assertWarnsRegexcCsnt|ttfr'tj|}n|j|sj|p?d}d||j|f}|j|ndS(u=Fail the test unless the text matches the regular expression.uRegex didn't matchu%s: %r not found in %rN(u isinstanceustrubytesureucompileusearchupatternufailureException(uselfutextuexpected_regexumsg((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu assertRegex}s  uTestCase.assertRegexcCst|ttfr'tj|}n|j|}|r|pEd}d|||j|j|j|f}|j |ndS(u9Fail the test if the text matches the regular expression.u Regex matchedu%s: %r matches %r in %rN( u isinstanceustrubytesureucompileusearchustartuendupatternufailureException(uselfutextuunexpected_regexumsgumatch((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuassertNotRegexs  uTestCase.assertNotRegexcsfdd}|S(Ncs,tjdjjtd||S(NuPlease use {0} instead.i(uwarningsuwarnuformatu__name__uDeprecationWarning(uargsukwargs(u original_func(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyudeprecated_funcs u,TestCase._deprecate..deprecated_func((u original_funcudeprecated_func((u original_funcu2/opt/alt/python33/lib64/python3.3/unittest/case.pyu _deprecatesuTestCase._deprecateNTiiF(Xu__name__u __module__u __qualname__u__doc__uAssertionErrorufailureExceptionuTrueu longMessageumaxDiffu_diffThresholduFalseu_classSetupFailedu__init__uaddTypeEqualityFuncu addCleanupusetUputearDownu classmethodu setUpClassu tearDownClassucountTestCasesudefaultTestResultushortDescriptionuidu__eq__u__hash__u__str__u__repr__u_addSkipu_executeTestPartuNoneurunu doCleanupsu__call__udebuguskipTestufailu assertFalseu assertTrueu_formatMessageu assertRaisesu assertWarnsu_getAssertEqualityFuncu_baseAssertEqualu assertEqualuassertNotEqualuassertAlmostEqualuassertNotAlmostEqualuassertSequenceEqualu_truncateMessageuassertListEqualuassertTupleEqualuassertSetEqualuassertInu assertNotInuassertIsu assertIsNotuassertDictEqualuassertDictContainsSubsetuassertCountEqualuassertMultiLineEqualu assertLessuassertLessEqualu assertGreateruassertGreaterEqualu assertIsNoneuassertIsNotNoneuassertIsInstanceuassertNotIsInstanceuassertRaisesRegexuassertWarnsRegexu assertRegexuassertNotRegexu _deprecateufailUnlessEqualu assertEqualsu failIfEqualuassertNotEqualsufailUnlessAlmostEqualuassertAlmostEqualsufailIfAlmostEqualuassertNotAlmostEqualsu failUnlessuassert_ufailUnlessRaisesufailIfuassertRaisesRegexpuassertRegexpMatches(u __locals__((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuTestCases            A     & h   + !     uTestCasecs|EeZdZdZdddfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZS(uFunctionTestCaseuIA test case that wraps a test function. This is useful for slipping pre-existing test functions into the unittest framework. Optionally, set-up and tidy-up functions can be supplied. As with TestCase, the tidy-up ('tearDown') function will always be called if the set-up ('setUp') function ran successfully. cs;tt|j||_||_||_||_dS(N(usuperuFunctionTestCaseu__init__u _setUpFuncu _tearDownFuncu _testFuncu _description(uselfutestFuncusetUputearDownu description(u __class__(u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__init__s    uFunctionTestCase.__init__cCs |jdk r|jndS(N(u _setUpFuncuNone(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyusetUpsuFunctionTestCase.setUpcCs |jdk r|jndS(N(u _tearDownFuncuNone(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyutearDownsuFunctionTestCase.tearDowncCs|jdS(N(u _testFunc(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyurunTestsuFunctionTestCase.runTestcCs |jjS(N(u _testFuncu__name__(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuidsuFunctionTestCase.idcCs\t||jstS|j|jko[|j|jko[|j|jko[|j|jkS(N(u isinstanceu __class__uNotImplementedu _setUpFuncu _tearDownFuncu _testFuncu _description(uselfuother((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__eq__s uFunctionTestCase.__eq__cCs ||k S(N((uselfuother((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__ne__suFunctionTestCase.__ne__cCs+tt||j|j|j|jfS(N(uhashutypeu _setUpFuncu _tearDownFuncu _testFuncu _description(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__hash__suFunctionTestCase.__hash__cCsdt|j|jjfS(Nu%s (%s)(ustrclassu __class__u _testFuncu__name__(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__str__suFunctionTestCase.__str__cCsdt|j|jfS(Nu <%s tec=%s>(ustrclassu __class__u _testFunc(uself((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyu__repr__suFunctionTestCase.__repr__cCsE|jdk r|jS|jj}|rA|jddjpDdS(Nu i(u _descriptionuNoneu _testFuncu__doc__usplitustrip(uselfudoc((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyushortDescriptions u!FunctionTestCase.shortDescriptionN(u__name__u __module__u __qualname__u__doc__uNoneu__init__usetUputearDownurunTestuidu__eq__u__ne__u__hash__u__str__u__repr__ushortDescription(u __locals__((u __class__u2/opt/alt/python33/lib64/python3.3/unittest/case.pyuFunctionTestCases        uFunctionTestCase(%u__doc__usysu functoolsudifflibuosupprintureuwarningsu collectionsuuresultuutilustrclassu safe_repru_count_diff_all_purposeu_count_diff_hashableuTrueu __unittestu DIFF_OMITTEDu ExceptionuSkipTestu_ExpectedFailureu_UnexpectedSuccessuobjectu_Outcomeu_iduskipuskipIfu skipUnlessuexpectedFailureu_skipInRpmBuildu_expectedFailureInRpmBuildu_AssertRaisesBaseContextu_AssertRaisesContextu_AssertWarnsContextuTestCaseuFunctionTestCase(((u2/opt/alt/python33/lib64/python3.3/unittest/case.pyus>        "      $ 1