Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/unittest/case.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s_dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZmZeZdZdefd��YZd	efd
��YZdefd��YZd
�Zd�Zd�Zd�Zd�Zdefd��YZdefd��YZdefd��YZ dS(sTest case implementationi�Ni(tresult(tstrclasst	safe_reprtunorderable_list_differencet_count_diff_all_purposet_count_diff_hashables@
Diff is %s characters long. Set self.maxDiff to None to see it.tSkipTestcBseZdZRS(s�
    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.
    (t__name__t
__module__t__doc__(((s#/sys/lib/python2.7/unittest/case.pyRst_ExpectedFailurecBseZdZd�ZRS(s\
    Raise this when a test is expected to fail.

    This is an implementation detail.
    cCs tt|�j�||_dS(N(tsuperR
t__init__texc_info(tselfR
((s#/sys/lib/python2.7/unittest/case.pyR)s(RRR	R(((s#/sys/lib/python2.7/unittest/case.pyR
"st_UnexpectedSuccesscBseZdZRS(s7
    The test was supposed to fail, but it didn't!
    (RRR	(((s#/sys/lib/python2.7/unittest/case.pyR-scCs|S(N((tobj((s#/sys/lib/python2.7/unittest/case.pyt_id3scs�fd�}|S(s&
    Unconditionally skip a test.
    csUt|ttjf�s?tj|��fd��}|}nt|_�|_|S(Ncst���dS(N(R(targstkwargs(treason(s#/sys/lib/python2.7/unittest/case.pytskip_wrapper<s(	t
isinstancettypettypest	ClassTypet	functoolstwrapstTruet__unittest_skip__t__unittest_skip_why__(t	test_itemR(R(s#/sys/lib/python2.7/unittest/case.pyt	decorator:s			((RR ((Rs#/sys/lib/python2.7/unittest/case.pytskip6s
cCs|rt|�StS(s/
    Skip a test if the condition is true.
    (R!R(t	conditionR((s#/sys/lib/python2.7/unittest/case.pytskipIfFs
cCs|st|�StS(s3
    Skip a test unless the condition is true.
    (R!R(R"R((s#/sys/lib/python2.7/unittest/case.pyt
skipUnlessNs
cs"tj���fd��}|S(NcsAy�||�Wn#tk
r6ttj���nXt�dS(N(t	ExceptionR
tsysR
R(RR(tfunc(s#/sys/lib/python2.7/unittest/case.pytwrapperXs

(RR(R'R(((R's#/sys/lib/python2.7/unittest/case.pytexpectedFailureWst_AssertRaisesContextcBs,eZdZdd�Zd�Zd�ZRS(sCA context manager used to implement TestCase.assertRaises* methods.cCs"||_|j|_||_dS(N(texpectedtfailureExceptiontexpected_regexp(RR+t	test_caseR-((s#/sys/lib/python2.7/unittest/case.pyRes	cCs|S(N((R((s#/sys/lib/python2.7/unittest/case.pyt	__enter__jscCs�|dkrZy|jj}Wn tk
r>t|j�}nX|jdj|���nt||j�sptS||_	|j
dkr�tS|j
}|jt|��s�|jd|j
t|�f��ntS(Ns{0} not raiseds"%s" does not match "%s"(tNoneR+RtAttributeErrortstrR,tformatt
issubclasstFalset	exceptionR-Rtsearchtpattern(Rtexc_typet	exc_valuettbtexc_nameR-((s#/sys/lib/python2.7/unittest/case.pyt__exit__ms"
			N(RRR	R0RR/R=(((s#/sys/lib/python2.7/unittest/case.pyR*bs	tTestCasecBs)eZdZeZeZd@ZdAZeZ	dd�Z
d�Zd�Zd	�Z
d
�Zed��Zed��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdBd�Zd�Zd�Zd�Z d�Z!dBd�Z"dBd�Z#dBd�Z$d�Z%dBd �Z&d!�Z'dBd"�Z(dBd#�Z)dBd$�Z*dBdBdBd%�Z+dBdBdBd&�Z,e)Z-e*Z.e+Z/e,Z0e$Z1d'�Z2e2e)�Z3e2e*�Z4e2e+�Z5e2e,�Z6e2e$�Z7e2e&�Z8e2e#�Z9dBdBd(�Z:d)�Z;dBd*�Z<dBd+�Z=dBd,�Z>dBd-�Z?dBd.�Z@dBd/�ZAdBd0�ZBdBd1�ZCdBd2�ZDdBd3�ZEdBd4�ZFdBd5�ZGdBd6�ZHdBd7�ZIdBd8�ZJdBd9�ZKdBd:�ZLdBd;�ZMdBd<�ZNdBd=�ZOdBd>�ZPdBd?�ZQRS(CsWA 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.
    iPiiitrunTestcCs�||_d|_yt||�}Wn*tk
rQtd|j|f��nX|j|_g|_	i|_
|jtd�|jt
d�|jtd�|jtd�|jtd�y|jtd�Wntk
r�nXdS(s�Create 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.
        sno such test method in %s: %stassertDictEqualtassertListEqualtassertTupleEqualtassertSetEqualtassertMultiLineEqualN(t_testMethodNameR0t_resultForDoCleanupstgetattrR1t
ValueErrort	__class__R	t_testMethodDoct	_cleanupst_type_equality_funcstaddTypeEqualityFunctdicttlistttupletsett	frozensettunicodet	NameError(Rt
methodNamet
testMethod((s#/sys/lib/python2.7/unittest/case.pyR�s&		
		
cCs||j|<dS(s[Add a type specific assertEqual style function to compare a type.

        This method is for use by TestCase subclasses that need to register
        their own type equality functions to provide nicer error messages.

        Args:
            typeobj: The data type to call this function on when both values
                    are of the same type in assertEqual().
            function: The callable taking two arguments and an optional
                    msg= argument that raises self.failureException with a
                    useful error message when the two arguments are not equal.
        N(RL(Rttypeobjtfunction((s#/sys/lib/python2.7/unittest/case.pyRM�s
cOs|jj|||f�dS(sAdd a function, with arguments, to be called when the test is
        completed. Functions added are called on a LIFO basis and are
        called after tearDown on test failure or success.

        Cleanup items are called even if setUp fails (unlike tearDown).N(RKtappend(RRXRR((s#/sys/lib/python2.7/unittest/case.pyt
addCleanup�scCsdS(sAHook method for setting up the test fixture before exercising it.N((R((s#/sys/lib/python2.7/unittest/case.pytsetUp�scCsdS(sAHook method for deconstructing the test fixture after testing it.N((R((s#/sys/lib/python2.7/unittest/case.pyttearDown�scCsdS(sKHook method for setting up class fixture before running tests in the class.N((tcls((s#/sys/lib/python2.7/unittest/case.pyt
setUpClass�scCsdS(sVHook method for deconstructing the class fixture after running all tests in the class.N((R]((s#/sys/lib/python2.7/unittest/case.pyt
tearDownClass�scCsdS(Ni((R((s#/sys/lib/python2.7/unittest/case.pytcountTestCases�scCs
tj�S(N(Rt
TestResult(R((s#/sys/lib/python2.7/unittest/case.pytdefaultTestResult�scCs,|j}|r(|jd�dj�p+dS(s�Returns a one-line description of the test, or None if no
        description has been provided.

        The default implementation of this method returns the first line of
        the specified test method's docstring.
        s
iN(RJtsplittstripR0(Rtdoc((s#/sys/lib/python2.7/unittest/case.pytshortDescription�s	cCsdt|j�|jfS(Ns%s.%s(RRIRE(R((s#/sys/lib/python2.7/unittest/case.pytidscCs,t|�t|�k	rtS|j|jkS(N(RtNotImplementedRE(Rtother((s#/sys/lib/python2.7/unittest/case.pyt__eq__scCs||kS(N((RRi((s#/sys/lib/python2.7/unittest/case.pyt__ne__scCstt|�|jf�S(N(thashRRE(R((s#/sys/lib/python2.7/unittest/case.pyt__hash__scCsd|jt|j�fS(Ns%s (%s)(RERRI(R((s#/sys/lib/python2.7/unittest/case.pyt__str__scCsdt|j�|jfS(Ns<%s testMethod=%s>(RRIRE(R((s#/sys/lib/python2.7/unittest/case.pyt__repr__scCsRt|dd�}|dk	r.|||�n tjdtd�|j|�dS(NtaddSkips4TestResult has no addSkip method, skips not reportedi(RGR0twarningstwarntRuntimeWarningt
addSuccess(RRRRp((s#/sys/lib/python2.7/unittest/case.pyt_addSkips	
cCsr|}|dkrI|j�}t|dd�}|dk	rI|�qIn||_|j|�t||j�}t|jdt�s�t|dt�r�;t|jdd�p�t|dd�}|j||�Wd|j	|�XdSz>t}y|j
�WnXtk
r*}|j|t|��n�t
k
r=�n�|j|tj��n�Xy|�WnBt
k
r{�n5|jk
r�|j|tj��ntk
r}t|dd�}|dk	r�||j�q�tjdt�|j|�n�tk
ret|dd�}	|	dk	r<|	|�q�tjdt�|j|tj��nKtk
r�}|j|t|��n#|j|tj��nXt}y|j�Wn6t
k
r��n#|j|tj��t}nX|j�}
|o|
}|r%|j|�nWd|j	|�|dkrmt|d	d�}|dk	rm|�qmnXdS(
NtstartTestRunRRttaddExpectedFailures@TestResult has no addExpectedFailure method, reporting as passestaddUnexpectedSuccesssDTestResult has no addUnexpectedSuccess method, reporting as failureststopTestRun(R0RbRGRFt	startTestRERIR5RutstopTestR[RR2tKeyboardInterrupttaddErrorR&R
R,t
addFailureR
RqRrRsRtRRR\t
doCleanups(RRtorig_resultRvRVtskip_whytsuccessteRxRytcleanUpSuccessRz((s#/sys/lib/python2.7/unittest/case.pytrun's�
	


	

	


cCs�|j}t}xr|jr�|jjd�\}}}y|||�Wqtk
r]�qt}|j|tj��qXqW|S(sNExecute all cleanup functions. Normally called for you after
        tearDown.i�(	RFRRKtpopR}R5R~R&R
(RRtokRXRR((s#/sys/lib/python2.7/unittest/case.pyR�xs	
cOs|j||�S(N(R�(RRtkwds((s#/sys/lib/python2.7/unittest/case.pyt__call__�scCsc|j�t||j��|j�x5|jr^|jjd�\}}}|||�q*WdS(s6Run the test without collecting errors in a TestResulti�N(R[RGRER\RKR�(RRXRR((s#/sys/lib/python2.7/unittest/case.pytdebug�s

cCst|��dS(sSkip this test.N(R(RR((s#/sys/lib/python2.7/unittest/case.pytskipTest�scCs|j|��dS(s)Fail immediately, with the given message.N(R,(Rtmsg((s#/sys/lib/python2.7/unittest/case.pytfail�scCs8|r4|j|dt|��}|j|��ndS(s#Check that the expression is false.s%s is not falseN(t_formatMessageRR,(RtexprR�((s#/sys/lib/python2.7/unittest/case.pytassertFalse�scCs8|s4|j|dt|��}|j|��ndS(s"Check that the expression is true.s%s is not trueN(R�RR,(RR�R�((s#/sys/lib/python2.7/unittest/case.pyt
assertTrue�scCsd|js|p|S|dkr#|Syd||fSWn(tk
r_dt|�t|�fSXdS(s�Honour 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
        s%s : %sN(tlongMessageR0tUnicodeDecodeErrorR(RR�tstandardMsg((s#/sys/lib/python2.7/unittest/case.pyR��s
	

cOs=t||�}|dkr|S|�|||�WdQXdS(s�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()

           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)
        N(R*R0(RtexcClasstcallableObjRRtcontext((s#/sys/lib/python2.7/unittest/case.pytassertRaises�s
cCskt|�t|�krd|jjt|��}|dk	rdt|t�r]t||�}n|Sn|jS(sGet 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(RRLtgetR0Rt
basestringRGt_baseAssertEqual(Rtfirsttsecondtasserter((s#/sys/lib/python2.7/unittest/case.pyt_getAssertEqualityFunc�scCsP||ksLdt|�t|�f}|j||�}|j|��ndS(s:The default assertEqual implementation, not type specific.s%s != %sN(RR�R,(RR�R�R�R�((s#/sys/lib/python2.7/unittest/case.pyR��scCs)|j||�}|||d|�dS(s[Fail if the two objects are unequal as determined by the '=='
           operator.
        R�N(R�(RR�R�R�tassertion_func((s#/sys/lib/python2.7/unittest/case.pytassertEqual�scCsJ||ksF|j|dt|�t|�f�}|j|��ndS(sYFail if the two objects are equal as determined by the '!='
           operator.
        s%s == %sN(R�RR,(RR�R�R�((s#/sys/lib/python2.7/unittest/case.pytassertNotEqualscCs||krdS|dk	r7|dk	r7td��n|dk	r�t||�|kr]dSdt|�t|�t|�f}nW|dkr�d}ntt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS(sFail 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.
        Ns specify delta or places not boths%s != %s within %s deltaiis%s != %s within %r places(R0t	TypeErrortabsRtroundR�R,(RR�R�tplacesR�tdeltaR�((s#/sys/lib/python2.7/unittest/case.pytassertAlmostEqual
s&			
cCs|dk	r'|dk	r'td��n|dk	r�||krZt||�|krZdSdt|�t|�t|�f}nd|dkr�d}n||kr�tt||�|�dkr�dSdt|�t|�|f}|j||�}|j|��dS(s�Fail 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.
        s specify delta or places not bothNs%s == %s within %s deltaiis%s == %s within %r places(R0R�R�RR�R�R,(RR�R�R�R�R�R�((s#/sys/lib/python2.7/unittest/case.pytassertNotAlmostEqual3s"#		,	
cs�fd�}|S(Ncs,tjdj�j�td��||�S(NsPlease use {0} instead.i(RqRrR3RtPendingDeprecationWarning(RR(t
original_func(s#/sys/lib/python2.7/unittest/case.pytdeprecated_func`s
((R�R�((R�s#/sys/lib/python2.7/unittest/case.pyt
_deprecate_scCs�|dk	rz|j}t||�sF|jd|t|�f��nt||�s�|jd|t|�f��q�nd}d}yt|�}Wn!ttfk
r�d|}nX|dkr�t|�}Wq�tfk
r�d|}q�|dkr|||krdSt|�}	t|�}
t|	�dkrT|	d d}	nt|
�dkrw|
d d}
n|j�|	|
f}d	|}x�t
||��D]�}y||}
Wn/tttfk
r�|d
||f7}PnXy||}Wn/tttfk
r1|d||f7}PnX|
|kr�|d||
|f7}Pq�q�W||kr�|dkr�t|�t|�kr�dS||kr|d
|||f7}y|d|||f7}Wqytttfk
r|d||f7}qyXq|||kr||d|||f7}y|d|||f7}Wqytttfk
ru|d||f7}qyXq|n|}ddj
tjtj|�j�tj|�j���}|j||�}|j||�}|j|�dS(sAAn 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.
        sFirst sequence is not a %s: %ssSecond sequence is not a %s: %stsequences(First %s has no length.    Non-sequence?s)Second %s has no length.    Non-sequence?Nis...s%ss differ: %s != %s
s(
Unable to index element %d of first %s
s)
Unable to index element %d of second %s
s#
First differing element %d:
%s
%s
s+
First %s contains %d additional elements.
sFirst extra element %d:
%s
s'Unable to index element %d of first %s
s,
Second %s contains %d additional elements.
s(Unable to index element %d of second %s
s
(R0RRR,RtlenR�tNotImplementedErrort
capitalizetxrangetmint
IndexErrorRtjointdifflibtndifftpprinttpformatt
splitlinest_truncateMessageR�R�(Rtseq1tseq2R�tseq_typet
seq_type_namet	differingtlen1tlen2t	seq1_reprt	seq2_reprtelementstititem1titem2R�tdiffMsg((s#/sys/lib/python2.7/unittest/case.pytassertSequenceEqualos�			
	cCsA|j}|dks't|�|kr/||S|tt|�S(N(tmaxDiffR0R�tDIFF_OMITTED(Rtmessagetdifftmax_diff((s#/sys/lib/python2.7/unittest/case.pyR��s	cCs|j|||dt�dS(sA 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.

        R�N(R�RO(Rtlist1tlist2R�((s#/sys/lib/python2.7/unittest/case.pyRA�s
cCs|j|||dt�dS(sA 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.
        R�N(R�RP(Rttuple1ttuple2R�((s#/sys/lib/python2.7/unittest/case.pyRB�s	c
Cspy|j|�}WnGtk
r9}|jd|�n$tk
r\}|jd|�nXy|j|�}WnGtk
r�}|jd|�n$tk
r�}|jd|�nX|p�|s�dSg}|r
|jd�x$|D]}|jt|��q�n|rD|jd�x$|D]}|jt|��q$Wndj|�}	|j|j||	��dS(s�A 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).
        s/invalid type when attempting set difference: %ss2first argument does not support set difference: %ss3second argument does not support set difference: %sNs*Items in the first set but not the second:s*Items in the second set but not the first:s
(t
differenceR�R�R1RYtreprR�R�(
Rtset1tset2R�tdifference1R�tdifference2tlinestitemR�((s#/sys/lib/python2.7/unittest/case.pyRC�s2




cCsH||krDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a in b), but with a nicer default message.s%s not found in %sN(RR�R�(Rtmembert	containerR�R�((s#/sys/lib/python2.7/unittest/case.pytassertInscCsH||krDdt|�t|�f}|j|j||��ndS(sHJust like self.assertTrue(a not in b), but with a nicer default message.s%s unexpectedly found in %sN(RR�R�(RR�R�R�R�((s#/sys/lib/python2.7/unittest/case.pytassertNotIn%scCsH||k	rDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a is b), but with a nicer default message.s%s is not %sN(RR�R�(Rtexpr1texpr2R�R�((s#/sys/lib/python2.7/unittest/case.pytassertIs,scCs?||kr;dt|�f}|j|j||��ndS(sHJust like self.assertTrue(a is not b), but with a nicer default message.sunexpectedly identical: %sN(RR�R�(RR�R�R�R�((s#/sys/lib/python2.7/unittest/case.pytassertIsNot3scCs�|j|td�|j|td�||kr�dt|t�t|t�f}ddjtjtj|�j	�tj|�j	���}|j
||�}|j|j||��ndS(Ns"First argument is not a dictionarys#Second argument is not a dictionarys%s != %ss
(
tassertIsInstanceRNRRR�R�R�R�R�R�R�R�R�(Rtd1td2R�R�R�((s#/sys/lib/python2.7/unittest/case.pyR@9s"c	Csg}g}xy|j�D]k\}}||krA|j|�q|||kr|jdt|�t|�t||�f�qqW|p�|s�dSd}|r�ddjd�|D��}n|r�r�|d7}n|ddj|�7}n|j|j||��dS(	s0Checks whether actual is a superset of expected.s%s, expected: %s, actual: %sNRwsMissing: %st,css|]}t|�VqdS(N(R(t.0tm((s#/sys/lib/python2.7/unittest/case.pys	<genexpr>Vss; sMismatched values: %s(t	iteritemsRYRR�R�R�(	RR+tactualR�tmissingt
mismatchedtkeytvalueR�((s#/sys/lib/python2.7/unittest/case.pytassertDictContainsSubsetEs(	
c	Cs9t|�t|�}}tj��tjr_x-dddgD]}tjd|t�q?Wny"tj|�}tj|�}Wn t	k
r�t
||�}	n X||kr�dSt||�}	WdQX|	r5d}
g|	D]}d|^q�}dj|�}
|j
|
|
�}
|j||
�}|j|�ndS(	s�An unordered sequence specific comparison. It asserts that
        actual_seq and expected_seq have the same element counts.
        Equivalent to::

            self.assertEqual(Counter(iter(actual_seq)),
                             Counter(iter(expected_seq)))

        Asserts that each element has the same count in both sequences.
        Example:
            - [0, 1, 1] and [1, 0, 1] compare equal.
            - [0, 0, 1] and [0, 1] compare unequal.
        s'(code|dict|type) inequality comparisonss,builtin_function_or_method order comparisonsscomparing unequal typestignoreNsElement counts were not equal:
s First has %d, Second has %d:  %rs
(RORqtcatch_warningsR&tpy3kwarningtfilterwarningstDeprecationWarningtcollectionstCounterR�RRR�R�R�R�(Rtexpected_seqt
actual_seqR�t	first_seqt
second_seqt_msgR�R�tdifferencesR�R�R�R�((s#/sys/lib/python2.7/unittest/case.pytassertItemsEqual_s,

	

cCsG|j|td�|j|td�||krCt|�|jks\t|�|jkrr|j|||�n|jt�}|jt�}t|�dkr�|jd�|kr�|dg}|dg}ndt|t�t|t�f}ddj	t
j||��}|j||�}|j
|j||��ndS(	s-Assert that two multi-line strings are equal.sFirst argument is not a stringsSecond argument is not a stringis
s
s%s != %sRwN(R�R�R�t_diffThresholdR�R�RRdRR�R�R�R�R�R�(RR�R�R�t
firstlinestsecondlinesR�R�((s#/sys/lib/python2.7/unittest/case.pyRD�s$'
cCsH||ksDdt|�t|�f}|j|j||��ndS(sCJust like self.assertTrue(a < b), but with a nicer default message.s%s not less than %sN(RR�R�(RtatbR�R�((s#/sys/lib/python2.7/unittest/case.pyt
assertLess�scCsH||ksDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a <= b), but with a nicer default message.s%s not less than or equal to %sN(RR�R�(RRRR�R�((s#/sys/lib/python2.7/unittest/case.pytassertLessEqual�scCsH||ksDdt|�t|�f}|j|j||��ndS(sCJust like self.assertTrue(a > b), but with a nicer default message.s%s not greater than %sN(RR�R�(RRRR�R�((s#/sys/lib/python2.7/unittest/case.pyt
assertGreater�scCsH||ksDdt|�t|�f}|j|j||��ndS(sDJust like self.assertTrue(a >= b), but with a nicer default message.s"%s not greater than or equal to %sN(RR�R�(RRRR�R�((s#/sys/lib/python2.7/unittest/case.pytassertGreaterEqual�scCs?|dk	r;dt|�f}|j|j||��ndS(sCSame as self.assertTrue(obj is None), with a nicer default message.s%s is not NoneN(R0RR�R�(RRR�R�((s#/sys/lib/python2.7/unittest/case.pytassertIsNone�scCs2|dkr.d}|j|j||��ndS(s(Included for symmetry with assertIsNone.sunexpectedly NoneN(R0R�R�(RRR�R�((s#/sys/lib/python2.7/unittest/case.pytassertIsNotNone�scCsEt||�sAdt|�|f}|j|j||��ndS(sTSame as self.assertTrue(isinstance(obj, cls)), with a nicer
        default message.s%s is not an instance of %rN(RRR�R�(RRR]R�R�((s#/sys/lib/python2.7/unittest/case.pyR��scCsEt||�rAdt|�|f}|j|j||��ndS(s,Included for symmetry with assertIsInstance.s%s is an instance of %rN(RRR�R�(RRR]R�R�((s#/sys/lib/python2.7/unittest/case.pytassertNotIsInstance�scOs^|dk	rtj|�}nt|||�}|dkr@|S|�|||�WdQXdS(s�Asserts that the message in a raised exception matches a regexp.

        Args:
            expected_exception: Exception class expected to be raised.
            expected_regexp: Regexp (re pattern object or string) expected
                    to be found in error message.
            callable_obj: Function to be called.
            args: Extra args.
            kwargs: Extra kwargs.
        N(R0tretcompileR*(Rtexpected_exceptionR-tcallable_objRRR�((s#/sys/lib/python2.7/unittest/case.pytassertRaisesRegexp�scCsht|t�r!tj|�}n|j|�sd|p9d}d||j|f}|j|��ndS(s=Fail the test unless the text matches the regular expression.sRegexp didn't matchs%s: %r not found in %rN(RR�RR
R7R8R,(RttextR-R�((s#/sys/lib/python2.7/unittest/case.pytassertRegexpMatches�scCs�t|t�r!tj|�}n|j|�}|r�|p?d}d|||j�|j�!|j|f}|j|��ndS(s9Fail the test if the text matches the regular expression.sRegexp matcheds%s: %r matches %r in %rN(	RR�RR
R7tstarttendR8R,(RRtunexpected_regexpR�tmatch((s#/sys/lib/python2.7/unittest/case.pytassertNotRegexpMatches�s
i�iN(RRRR	tAssertionErrorR,R5R�R�Rt_classSetupFailedRRMRZR[R\tclassmethodR^R_R`RbRfRgRjRkRmRnRoRuR0R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�tassertEqualstassertNotEqualstassertAlmostEqualstassertNotAlmostEqualstassert_R�tfailUnlessEqualtfailIfEqualtfailUnlessAlmostEqualtfailIfAlmostEqualt
failUnlesstfailUnlessRaisestfailIfR�R�RARBRCR�R�R�R�R@R�R�RDRRRRR	R
R�RRRR(((s#/sys/lib/python2.7/unittest/case.pyR>�s�															Q							
&$	g	+(	tFunctionTestCasecBszeZdZdddd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�ZRS(
sIA 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.
    cCs;tt|�j�||_||_||_||_dS(N(RR'Rt
_setUpFunct
_tearDownFunct	_testFunct_description(RttestFuncR[R\tdescription((s#/sys/lib/python2.7/unittest/case.pyRs
			cCs |jdk	r|j�ndS(N(R(R0(R((s#/sys/lib/python2.7/unittest/case.pyR[
scCs |jdk	r|j�ndS(N(R)R0(R((s#/sys/lib/python2.7/unittest/case.pyR\scCs|j�dS(N(R*(R((s#/sys/lib/python2.7/unittest/case.pyR?scCs
|jjS(N(R*R(R((s#/sys/lib/python2.7/unittest/case.pyRgscCs\t||j�stS|j|jko[|j|jko[|j|jko[|j|jkS(N(RRIRhR(R)R*R+(RRi((s#/sys/lib/python2.7/unittest/case.pyRjscCs||kS(N((RRi((s#/sys/lib/python2.7/unittest/case.pyRk!scCs+tt|�|j|j|j|jf�S(N(RlRR(R)R*R+(R((s#/sys/lib/python2.7/unittest/case.pyRm$scCsdt|j�|jjfS(Ns%s (%s)(RRIR*R(R((s#/sys/lib/python2.7/unittest/case.pyRn(scCsdt|j�|jfS(Ns<%s tec=%s>(RRIR*(R((s#/sys/lib/python2.7/unittest/case.pyRo,scCsE|jdk	r|jS|jj}|rA|jd�dj�pDdS(Ns
i(R+R0R*R	RcRd(RRe((s#/sys/lib/python2.7/unittest/case.pyRf0sN(RRR	R0RR[R\R?RgRjRkRmRnRoRf(((s#/sys/lib/python2.7/unittest/case.pyR'�s										(!R	R�R&RR�R�RRRqRwRtutilRRRRRRt
__unittestR�R%RR
RRR!R#R$R)tobjectR*R>R'(((s#/sys/lib/python2.7/unittest/case.pyt<module>s4(							!�

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].