
XMc           @   s%  d  Z  d d l Z d d l m Z d d l m Z m Z d d l m Z m	 Z	 d d l
 m Z d d l m Z d d l m Z m Z m Z d	 e f d
     YZ d e j f d     YZ d e j f d     YZ d e j f d     YZ e e j  d    Z e e j d d d    Z d S(   sF   
Tests for assertions provided by L{twisted.trial.unittest.TestCase}.
iN(   t   pformat(   t   reflectt   failure(   t
   deprecatedt   getVersionString(   t   Version(   t   defer(   t   unittestt   runnert   reportert   MockEqualityc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   name(   t   selfR   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   __init__   s    c         C   s   d |  j  f S(   Ns   MockEquality(%s)(   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   __repr__   s    c         C   s@   t  | d  s( t d | |  f   n  |  j d | j d k S(   NR   s   %r not comparable to %ri    (   t   hasattrt
   ValueErrorR   (   R   t   other(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   __eq__   s    (   t   __name__t
   __module__R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR
      s   		t   TestAssertionsc           B   s  e  Z d  Z d e j f d     YZ d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d    Z# d!   Z$ d"   Z% d#   Z& d$   Z' d%   Z( d&   Z) d'   Z* d(   Z+ d)   Z, d*   Z- d+   Z. d,   Z/ d-   Z0 d.   Z1 d/   Z2 d0   Z3 d1   Z4 d2   Z5 d3   Z6 d4   Z7 d5   Z8 RS(6   s   
    Tests for TestCase's assertion methods.  That is, failUnless*,
    failIf*, assert*.

    This is pretty paranoid.  Still, a certain paranoia is healthy if you
    are testing a unit testing framework.
    t   FailingTestc           B   s   e  Z d    Z RS(   c         C   s   |  j     d  S(   N(   t   failureException(   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt
   test_fails(   s    (   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR   '   s   c         C   sn   y |  j  d  WnG |  j k
 rZ } t |  d k sj |  j d t |  d   qj n X|  j d   d  S(   Nt   faileds"   Exception had msg %s instead of %ss$   Call to self.fail() didn't fail test(   t   failR   t   str(   R   t   e(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   testFail+   s    	c         C   st   t  j   j t j  } t j   } | j |  |  j | j	    |  j
 | j g   |  j
 t | j  d  d  S(   Ni   (   R   t
   TestLoadert	   loadClassR   R   R	   t
   TestResultt   runt   failIft   wasSuccessfult   failUnlessEqualt   errorst   lent   failures(   R   t   testt   result(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failingException_fails5   s    c         C   s   x7 d d t  d  d
 g  g D] } |  j | d | f  q Wx d t d d d g d g D]k } y |  j | d | f  Wn3 |  j k
 r } |  j t |  d | f  qV X|  j d	 | f  qV Wd  S(   Ni    g        s   failed on %ri   t   cati   i   i   s   Call to failIf(%r) didn't fail(    (   i   i   (   t   Falset   NoneR"   t   TrueR   R$   R   R   (   R   t   notTruet   trueR   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failIf=   s    "!c         C   s   x d d t  d  d
 g  g D]k } y |  j | d | f  Wn3 |  j k
 ro } |  j t |  d | f  q X|  j d | f  q Wx: d t d d d g d g D] } |  j | d | f  q Wd  S(   Ni    g        s   failed on %rs"   Call to failUnless(%r) didn't faili   R+   i   i   i   (    (   i   i   (   R,   R-   t
   failUnlessR   R$   R   R   R.   (   R   R/   R   R0   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessH   s    !"c         C   s2   |  j  | |  } | | k r. |  j d  n  d  S(   Ns-   failUnlessEqual should return first parameter(   R$   R   (   R   t   firstt   secondt   x(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   _testEqualPairS   s    c         C   s   y |  j  | |  Wnd |  j k
 rz } d t |  t |  f } t |  | k r |  j d | t |  f  q n X|  j d | | f  d  S(   Ns   not equal:
a = %s
b = %s
s   Expected: %r; Got: %ss+   Call to failUnlessEqual(%r, %r) didn't fail(   R$   R   R    R   R   (   R   R4   R5   R   t   expected(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   _testUnequalPairX   s    $	c         C   sM   |  j  d d  |  j d d  |  j  d g d g  |  j d g d  d  S(   NR+   t   dogi   t   orange(   R7   R9   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessEqual_basicd   s    c         C   sh   t  d  } t  d  } t  d  } |  j | |  |  j | |  |  j | |  |  j | |  d  S(   NR4   R5   t   fecund(   R
   R7   R9   (   R   R6   t   yt   z(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessEqual_customj   s    c         C   s;   |  j  |  j |  j d d d  } |  j t |  d  d S(   sj   
        When a message is passed to L{assertEqual}, it is included in the
        error message.
        t   foot   bart   messages'   message
not equal:
a = 'foo'
b = 'bar'
N(   t   assertRaisesR   t   assertEqualR   (   R   t	   exception(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessEqualMessages   s    	c         C   s;   |  j  |  j |  j d d d  } |  j t |  d  d S(   sz   
        If a message is specified as C{None}, it is not included in the error
        message of L{assertEqual}.
        RA   RB   s   not equal:
a = 'foo'
b = 'bar'
N(   RD   R   RE   R-   R   (   R   RF   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessEqualNoneMessage   s    c         C   sx   t  d  } d g } y |  j | |  Wn1 |  j k
 rL |  j d  n( t k
 r\ n X|  j d | | f  d  S(   Nt   appleR;   s6   Fail raised when ValueError ought to have been raised.s3   Comparing %r and %r should have raised an exception(   R
   R$   R   R   R   (   R   RI   R;   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt!   test_failUnlessEqual_incomparable   s    		c         C   s
   |  d  S(   N(    (   R   t   error(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   _raiseError   s    c         C   s5   |  j  t |  j t  } |  j t | t  d  d  S(   Ns?   Expect failUnlessRaises to return instance of raised exception.(   t   failUnlessRaisesR   RL   R2   t
   isinstance(   R   R6   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessRaises_expected   s    c         C   s_   y |  j  t |  j t  Wn1 t k
 r: |  j d  n! |  j k
 rM n X|  j d  d  S(   Ns9   failUnlessRaises shouldn't re-raise unexpected exceptionss4   Expected exception wasn't raised. Should have failed(   RM   R   RL   t	   TypeErrorR   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt    test_failUnlessRaises_unexpected   s    c         C   sW   y |  j  t d    Wn, |  j k
 rE } |  j t |  d  n X|  j d  d  S(   Nc           S   s   d  S(   N(   R-   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   <lambda>   s    s%   ValueError not raised (None returned)s(   Exception not raised. Should have failed(   RM   R   R   R$   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt!   test_failUnlessRaises_noException   s    c         C   s   |  j  |  j |  j |  j  } |  j t | |  j  d |  j f  y |  j  |  j |  j t  } Wn |  j k
 ry n X|  j d  d  S(   Ns#   Expected %r instance to be returneds   Should have raised exception(   RM   R   RL   R2   RN   R   R   (   R   R6   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt&   test_failUnlessRaises_failureException   s    c         C   s~   d g d g d g } } } |  j  | |  } |  j | | d  |  j |  j |  j  | |  |  j |  j |  j  | |  d  S(   Ni   i   s)   failIfEqual should return first parameter(   t   failIfEqualR$   RM   R   (   R   R6   R>   R?   t   ret(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failIfEqual_basic   s    c         C   s|   t  d  } t  d  } t  d  } |  j | |  } |  j | | d  |  j |  j |  j | |  |  j | | d  d  S(   NR4   R5   R=   s)   failIfEqual should return first parameters    __ne__ not defined, so not equal(   R
   RU   R$   RM   R   (   R   R6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failIfEqual_customEq   s    c         C   s~   d g d g d g } } } |  j  | |  } |  j | | d  |  j |  j |  j  | |  |  j |  j |  j  | |  d  S(   Ni   i   s1   failUnlessIdentical should return first parameter(   t   failUnlessIdenticalR$   RM   R   (   R   R6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessIdentical   s    c         C   s   d \ } } } |  j  | | d  |  j  | | d  } |  j | | d  |  j |  j |  j  | | d  |  j |  j |  j  | | d  d  S(   Ng      ?g?g333333?g?s4   failUnlessApproximates should return first parameterg?(   g      ?g?g333333?(   t   failUnlessApproximatesR$   RM   R   (   R   R6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessApproximates   s    c         C   s   d } d } d } d } |  j  | | |  |  j  | | |  } |  j | | d | | f  |  j |  j |  j  | | |  d  S(   Ni   gA!   @gXO  @gC   @s<   failUnlessAlmostEqual should return first parameter (%r, %r)(   t   failUnlessAlmostEqualR$   RM   R   (   R   t	   precisionR6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessAlmostEqual   s    c         C   s   d } d } d } d } |  j  | | |  } |  j | | d | | f  |  j |  j |  j  | | |  |  j |  j |  j  | | |  d  S(   Ni   gA!   @gXO  @gC   @s8   failIfAlmostEqual should return first parameter (%r, %r)(   t   failIfAlmostEqualR$   RM   R   (   R   R^   R6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failIfAlmostEqual   s    c         C   s   d } d } d } |  j  | |  |  j  | |  } |  j | | d  |  j |  j |  j  | |  |  j |  j |  j  | |  d  S(   NR+   s   the dog sats   the cat sats   should return first parameter(   t   failUnlessSubstringR$   RM   R   (   R   R6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessSubstring
  s    c         C   s   d } d } d } |  j  | |  |  j  | |  } |  j | | d  |  j |  j |  j  | |  |  j |  j |  j  | |  d  S(   NR+   s   the dog sats   the cat sats   should return first parameter(   t   failIfSubstringR$   RM   R   (   R   R6   R>   R?   RV   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failIfSubstring  s    c         C   s"   t  j d    } |  j | t  S(   Nc           S   s   d d S(   Ni   i    (    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   #  s    (   R   t   maybeDeferredt   assertFailuret   ZeroDivisionError(   R   t   d(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertFailure"  s    c            sH   t  j d    }   j | t  | j   f d     f d    | S(   Nc           S   s   d d S(   Ni   i    (    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   '  s    c            s     j  d  S(   Ns   Should have failed(   R   (   R6   (   R   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   )  s    c            s   |  j    j  S(   N(   t   trapR   (   R6   (   R   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   *  s    (   R   Rf   Rg   t   OverflowErrort   addCallbacks(   R   Ri   (    (   R   sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt!   test_assertFailure_wrongException&  s
    c            sE   t  j d   }   j | t  | j   f d     f d    | S(   Nc            s     j  d  S(   Ns   Should have failed(   R   (   R6   (   R   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   0  s    c            s   |  j    j  S(   N(   Rk   R   (   R6   (   R   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   1  s    (   R   t   succeedR-   Rg   Rh   Rm   (   R   Ri   (    (   R   sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertFailure_noException-  s
    c         C   sd   y d d Wn, t  k
 r: t j   } t j |  } n X|  j | t  } | j |  j |  | S(   s   
        In the case of assertFailure failing, check that we get lots of
        information about the exception that was raised.
        i   i    (	   Rh   R   t   FailureR   R   Rg   t   RuntimeErrort
   addErrbackt
   _checkInfo(   R   t   fRi   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertFailure_moreInfo4  s    c         C   sT   | j  |  j  s t  | j   } |  j | j   |  |  j | j   |  d  S(   N(   t   checkR   t   AssertionErrort   getErrorMessaget   assertInt   getBriefTraceback(   R   t   assertionFailureRu   t   output(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRt   B  s    c            sw   d t  f d     Y  d t j f   f d     Y} | d  } t j   } | j |  |  j d t | j   d S(   sJ   
        A single wrong assertFailure should fail the whole test.
        t   ExampleFailurec           B   s   e  Z RS(    (   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR~   L  s   t   TCc              s   e  Z   Z d    Z RS(   c         S   s6   t  j d    } |  j | t  |  j | t  | S(   Nc           S   s   d d S(   Ni   i    (    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRR   R  s    (   R   Rf   Rg   Rl   Rh   (   R   Ri   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRj   Q  s    (   R   R   R   Rj   (    (   R~   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR   O  s   Rj   i   N(	   t	   ExceptionR   t   TestCaseR	   R    R!   RE   R&   R'   (   R   R   R(   R)   (    (   R~   sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertFailure_maskedH  s    c         C   s8   d   } |  j  t d t | d  } |  j | d  d S(   s0   
        Test basic assertWarns report.
        c         S   s   t  j d d t |  S(   Ns   Woo deprecatedt   category(   t   warningst   warnt   DeprecationWarning(   t   a(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR   a  s    s   Woo deprecatedi{   N(   t   assertWarnsR   t   __file__t   assertEquals(   R   R   t   r(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarns]  s    	c         C   sc   d   } |  j  t d t | d  } |  j | d  |  j  t d t | d  } |  j | d  d S(   s}   
        Test that assertWarns cleans the warning registry, so the warning is
        not swallowed the second time.
        c         S   s   t  j d d t |  S(   Ns   Woo deprecatedR   (   R   R   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR   n  s    s   Woo deprecatedi{   iA  N(   R   R   R   R   (   R   R   t   r1t   r2(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsRegistryCleani  s    	c         C   s2   d   } |  j  |  j |  j t d t | d  d S(   sH   
        Test assertWarns failure when no warning is generated.
        c         S   s   |  S(   N(    (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   normal~  s    s   Woo deprecatedi{   N(   RD   R   R   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsErrorz  s    	c         C   s2   d   } |  j  |  j |  j t d t | d  d S(   sF   
        Test assertWarns failure when the category is wrong.
        c         S   s   t  j d d t |  S(   Ns   Foo deprecatedR   (   R   R   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    s   Foo deprecatedi{   N(   RD   R   R   t   UserWarningR   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsWrongCategory  s    	c         C   s2   d   } |  j  |  j |  j t d t | d  d S(   sE   
        Test assertWarns failure when the message is wrong.
        c         S   s   t  j d d t |  S(   Ns   Foo deprecatedR   (   R   R   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    s   Bar deprecatedi{   N(   RD   R   R   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsWrongMessage  s    	c         C   s2   d   } |  j  |  j |  j t d t | d  d S(   s   
        If the warning emitted by a function refers to a different file than is
        passed to C{assertWarns}, C{failureException} is raised.
        c         S   s   t  j d d t d d d  S(   Ns   Foo deprecatedR   t
   stackleveli   (   R   R   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    
s   Foo deprecatedi{   N(   RD   R   R   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsWrongFile  s
    	c         C   ss   d d d     Y} |  j  t d t |  } |  j t | |   |  j  t d t |  } |  j t | |   d S(   sH   
        Test assertWarns works when creating a class instance.
        t   Warnc           B   s   e  Z d    Z RS(   c         S   s   t  j d d t d  S(   Ns   Do not call meR   (   R   R   t   RuntimeWarning(   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    (   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s   s   Do not call meN(    (   R   R   R   t
   assertTrueRN   (   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsOnClass  s    		c         C   s|   d d d     Y} |   } |  j  t d t | j d  } |  j | d  |  j  t d t | j d  } |  j | d  d S(   sI   
        Test assertWarns works when used on an instance method.
        R   c           B   s   e  Z d    Z RS(   c         S   s   t  j d d t | S(   Ns   Bar deprecatedR   (   R   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    (   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s   s   Bar deprecatediA  N(    (   R   R   R   R   R   (   R   R   t   wR   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsOnMethod  s    	c         C   sv   d d d     Y} |   } |  j  t d t | d  } |  j | d  |  j  t d t | d  } |  j | d  d S(   sM   
        Test assertWarns works on instance with C{__call__} method.
        R   c           B   s   e  Z d    Z RS(   c         S   s   t  j d d t | S(   Ns   Egg deprecatedR   (   R   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   __call__  s    (   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s   s   Egg deprecatediA  N(    (   R   R   R   R   (   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsOnCall  s    	c         C   s8   d   } |  j  t d t | d  } |  j | d  d S(   sC   
        Test assertWarns on a warning filterd by default.
        c         S   s   t  j d d t |  S(   Ns   Woo deprecatedR   (   R   R   t   PendingDeprecationWarning(   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    s   Woo deprecatedi{   N(   R   R   R   R   (   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertWarnsFilter  s    	c            s2   d       f d   } |  j  t d t |  d S(   s   
        C{assertWarns} does not raise an exception if the function it is passed
        triggers the same warning more than once.
        c           S   s   t  j d d t d  S(   Ns   Woo deprecatedR   (   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    c              s           d  S(   N(    (    (   R   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRu     s    s   Woo deprecatedN(   R   R   R   (   R   Ru   (    (   R   sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt    test_assertWarnsMultipleWarnings  s    	c         C   sJ   d   } |  j  |  j |  j t d t | d  } |  j t |  d  d S(   s   
        For now, assertWarns is unable to handle multiple different warnings,
        so it should raise an exception if it's the case.
        c         S   s*   t  j d d t t  j d d t d  S(   Ns   Woo deprecatedR   s   Another one(   R   R   R   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    s   Woo deprecatedi{   s   Can't handle different warningsN(   RD   R   R   R   R   R   R   (   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt!   test_assertWarnsDifferentWarnings  s
    	c            su   d t  f d     Y    f d   } | d  |  j   d t | d  |  j | g  \ } |  j | d d  d S(   s   
        Warnings emitted before L{TestCase.assertWarns} is called do not get
        flushed and do not alter the behavior of L{TestCase.assertWarns}.
        t
   TheWarningc           B   s   e  Z RS(    (   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s   c            s   t  j |  d   d  S(   NR   (   R   R   (   RC   (   R   (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyRu     s    RA   RB   RC   N(   t   WarningR   R   t   flushWarningsRE   (   R   Ru   t   warning(    (   R   sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt&   test_assertWarnsAfterUnassertedWarning  s    
c         C   s2   t  d t f i   } |   } |  j | |  d S(   s<   
        Test a true condition of assertIsInstance.
        t   AN(   t   typet   objectt   assertIsInstance(   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertIsInstance  s    	c         C   sM   t  d t f i   } t  d t f i   } |   } |  j | | | f  d S(   sR   
        Test a true condition of assertIsInstance with multiple classes.
        R   t   BN(   R   R   R   (   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt$   test_assertIsInstanceMultipleClasses'  s    	c         C   sS   t  d t f i   } t  d t f i   } |   } |  j |  j |  j | |  d S(   s6   
        Test an error with assertIsInstance.
        R   R   N(   R   R   RD   R   R   (   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertIsInstanceError0  s    	c         C   sn   t  d t f i   } t  d t f i   } t  d t f i   } |   } |  j |  j |  j | | | f  d S(   sK   
        Test an error with assertIsInstance and multiple classes.
        R   R   t   CN(   R   R   RD   R   R   (   R   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt)   test_assertIsInstanceErrorMultipleClasses9  s
    	c         C   sG   t  d t f i   } t  d t f i   } |   } |  j | |  d S(   s?   
        Test a true condition of assertNotIsInstance.
        R   R   N(   R   R   t   assertNotIsInstance(   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertNotIsInstanceC  s    	c         C   sb   t  d t f i   } t  d t f i   } t  d t f i   } |   } |  j | | | f  d S(   sT   
        Test a true condition of assertNotIsInstance and multiple classes.
        R   R   R   N(   R   R   R   (   R   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt'   test_assertNotIsInstanceMultipleClassesL  s
    	c         C   s`   t  d t f i   } |   } |  j |  j |  j | |  } |  j t |  d | | f  d S(   s9   
        Test an error with assertNotIsInstance.
        R   s   %r is an instance of %sN(   R   R   RD   R   R   R   R   (   R   R   R   RK   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_assertNotIsInstanceErrorV  s
    	c         C   sY   t  d t f i   } t  d t f i   } |   } |  j |  j |  j | | | f  d S(   sN   
        Test an error with assertNotIsInstance and multiple classes.
        R   R   N(   R   R   RD   R   R   (   R   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt,   test_assertNotIsInstanceErrorMultipleClasses`  s    	(9   R   R   t   __doc__R   R   R   R   R*   R1   R3   R7   R9   R<   R@   RG   RH   RJ   RL   RO   RQ   RS   RT   RW   RX   RZ   R\   R_   Ra   Rc   Re   Rj   Rn   Rp   Rv   Rt   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR      sj   	
										
								
																																
			
	
t   TestAssertionNamesc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   sK   
    Tests for consistency of naming within TestCase assertion methods
    c         C   sP   i  } t  j |  | d  g  | D], } | j d  r  | d k r  | | ^ q  S(   Nt   assertt   Nott   _(   R   t   accumulateMethodst
   startswith(   R   t   dctt   k(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   _getAssertso  s    c         C   s   | j  S(   N(   R   (   R   R6   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   _namet  s    c         C   sG   t  |  j    } t  t j |  d   } |  j | | j |   d S(   s  
        The C{failUnless*} test methods are a subset of the C{assert*} test
        methods.  This is intended to ensure that methods using the
        I{failUnless} naming scheme are not added without corresponding methods
        using the I{assert} naming scheme.  The I{assert} naming scheme is
        preferred, and new I{assert}-prefixed methods may be added without
        corresponding I{failUnless}-prefixed methods.
        R2   N(   t   setR   R   t   prefixedMethodsR   t   intersection(   R   t   assertst   failUnlesses(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failUnlessMatchesAssertx  s    	c         C   s\   t  j t j d  } t  j t j d  } |  j t | d |  j t | d |  j  d  S(   Nt	   assertNotR"   t   key(   R   R   R   R   R$   t   sortedR   (   R   R   t   failIfs(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failIf_matches_assertNot  s    c         C   s   x t  |   j   D] \ } } t |  s1 q n  | j d  r |  j t |  | d  d | | f  |  j | t |  | d   n  | j d  r |  j t |  | d   d | | d  f  |  j | t |  | d    q q Wd  S(   Nt   Equalt   ss   %s but no %sst   Equalsis   %s but no %s(   t   varst   itemst   callablet   endswithR2   R   R$   t   getattr(   R   R   t   value(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_equalSpelling  s     (   R   R   R   R   R   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR   k  s   				t   TestCallDeprecatedc           B   sb   e  Z d  Z e d d d d  Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z RS(   sQ   
    Test use of the L{TestCase.callDeprecated} method with version objects.
    t   Twistedi   i    c         C   s3   |  j  |  j t d  |  j |  j   g  d  d S(   sj   
        callDeprecated calls a deprecated callable, suppressing the
        deprecation warning.
        RA   s   No warnings should be shownN(   t   callDeprecatedt   versiont	   oldMethodRE   R   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt$   test_callDeprecatedSuppressesWarning  s    c         C   s,   |  j  |  j t d  } |  j d |  d S(   sn   
        L{callDeprecated} actually calls the callable passed to it, and
        forwards the result.
        RA   N(   R   R   R   RE   (   R   R)   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt    test_callDeprecatedCallsFunction  s    c         C   sH   d   } |  j  |  j |  j |  j |  } |  j d | t |   d S(   sd   
        L{callDeprecated} raises a test failure if the callable is not
        deprecated.
        c           S   s   d  S(   N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   notDeprecated  s    s   %r is not deprecated.N(   RD   R   R   R   RE   R   (   R   R   RF   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_failsWithoutDeprecation  s    	c         C   su   t  d d d d  } |  j |  j |  j | t d  } |  j t |  j  t |   |  j t |  t |   d S(   s   
        callDeprecated raises a test failure if the callable was deprecated
        at a different version to the one expected.
        t   Fooi   i   i   RA   N(	   R   RD   R   R   R   Rz   R   R   R   (   R   t   differentVersionRF   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt"   test_failsWithIncorrectDeprecation  s    c         C   si   t  d d d d  } d   } t |  |  } |  j | | d  |  j   } |  j t |  d  d S(   s:  
        L{callDeprecated} ignores all deprecations apart from the first.

        Multiple warnings are generated when a deprecated function calls
        another deprecated function. The first warning is the one generated by
        the explicitly called function. That's the warning that we care about.
        R   i   i   i   c          W   s
   t  |    S(   N(   R   (   t   args(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   nestedDeprecation  s    i   N(   R   R   R   R   RE   R&   (   R   R   R   t   warningsShown(    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_nestedDeprecation  s    	c         C   s    |  j  |  j d f t d  d S(   sj   
        L{callDeprecated} can take a message argument used to check the warning
        emitted.
        t	   newMethodi   N(   R   R   t   oldMethodReplaced(   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   test_callDeprecationWithMessage  s    c         C   sc   |  j  |  j |  j |  j d f t d  } |  j t |  j  t |   |  j d t |   d S(   s|   
        If the message passed to L{callDeprecated} doesn't match,
        L{callDeprecated} raises a test failure.
        s   something.wrongi   s   please use newMethod insteadN(   RD   R   R   R   R   Rz   R   R   (   R   RF   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt$   test_callDeprecationWithWrongMessage  s    (   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s   	
							c         C   s   |  S(   s(   
    Deprecated method for testing.
    (    (   R6   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR     s    t   replacementR   c         C   s   d |  S(   sh   
    Another deprecated method, which has been deprecated in favor of the
    mythical 'newMethod'.
    i   (    (   R6   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyR   	  s    (   R   R   t   pprintR    t   twisted.pythonR   R   t   twisted.python.deprecateR   R   t   twisted.python.versionsR   t   twisted.internetR   t   twisted.trialR   R   R	   R   R
   R   R   R   R   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_assertions.pyt   <module>   s     O0f