ó
[³XMc           @   sÐ   d  d l  Z  d  d l Z d  d l m Z d  d l m Z d  d l m 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 e d	 ƒ Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t
   implements(   t   reflect(   t   Failure(   t   util(   t   TestCaset   PyUnitResultAdapter(   t	   IReportert	   ITestCase(   t	   erroneoust   unittestt   TestPyUnitTestCasec           B   sZ   e  Z d  e j f d „  ƒ  YZ d „  Z d „  Z e j d e	 d d ƒ g e _ d „  Z
 RS(   t
   PyUnitTestc           B   s   e  Z d  „  Z RS(   c         C   s   d  S(   N(    (   t   self(    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt	   test_pass   s    (   t   __name__t
   __module__R   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR      s   c         C   s(   |  j  d ƒ |  _ t |  j ƒ |  _ d  S(   NR   (   R   t   originalR   t   test(   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   setUp   s    c            s?   g  ‰  ‡  f d †  } |  j  j | ƒ |  j ˆ  |  j  g ƒ d S(   sB   
        Trial assumes that test cases implement visit().
        c            s   ˆ  j  |  ƒ d  S(   N(   t   append(   R   (   t   log(    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   visitor(   s    N(   R   t   visitt   assertEqual(   R   R   (    (   R   sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt
   test_visit#   s    t   categoryt   messages'   Test visitors deprecated in Twisted 8.0c         C   s'   |  j  t |  j ƒ d |  j f ƒ d S(   sW   
        Tests must be callable in order to be used with Python's unittest.py.
        s   %r is not callable.N(   t
   assertTruet   callableR   (   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_callable1   s    (   R   R   t   pyunitR   R   R   R   R   t   suppresst   DeprecationWarningR   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR
      s   		
t   TestPyUnitResultc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s¹   
    Tests to show that PyUnitResultAdapter wraps TestResult objects from the
    standard library 'unittest' module in such a way as to make them usable and
    useful from Trial.
    c         C   sV   d t  f d „  ƒ  Y} t j d ƒ } | ƒ  } | j | ƒ |  j | j d t ƒ d S(   sƒ   
        The L{PyUnitResultAdapter} is only used when the result passed to
        C{run} does *not* provide L{IReporter}.
        t   StubReporterc           B   s<   e  Z d  Z e e ƒ d „  Z d „  Z d „  Z d „  Z RS(   sÆ   
            A reporter which records data about calls made to it.

            @ivar errors: Errors passed to L{addError}.
            @ivar failures: Failures passed to L{addFailure}.
            c         S   s   g  |  _  g  |  _ d  S(   N(   t   errorst   failures(   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   __init__O   s    	c         S   s   d S(   s-   
                Do nothing.
                N(    (   R   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt	   startTestS   s    c         S   s   d S(   s-   
                Do nothing.
                N(    (   R   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   stopTestX   s    c         S   s   |  j  j | ƒ d S(   s3   
                Record the error.
                N(   R#   R   (   R   R   t   error(    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   addError]   s    (	   R   R   t   __doc__R    R   R%   R&   R'   R)   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR"   E   s   
			t   test_fooi    N(   t   objectR   t	   ErrorTestt   runt   assertIsInstanceR#   R   (   R   R"   R   t   result(    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt0   test_dontUseAdapterWhenReporterProvidesIReporter@   s
    	c         C   su   d t  f d „  ƒ  Y} | d ƒ } t j ƒ  } | j | ƒ |  j | j ƒ |  j d | j ƒ |  j | j ƒ  ƒ d  S(   Nt   SuccessTestc           B   s   e  Z e Z d  „  Z RS(   c         S   s   t  |  _ d  S(   N(   t   Truet   ran(   t   s(    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR+   l   s    (   R   R   t   FalseR4   R+   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR2   j   s   R+   i   (	   R   R   t
   TestResultR.   t
   failUnlessR4   R   t   testsRunt   wasSuccessful(   R   R2   R   R0   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_successi   s    c         C   sŽ   d t  f d „  ƒ  Y} | d ƒ } t j ƒ  } | j | ƒ |  j | j ƒ |  j d | j ƒ |  j d t | j	 ƒ ƒ |  j
 | j ƒ  ƒ d  S(   Nt   FailureTestc           B   s   e  Z e Z d  „  Z RS(   c         S   s   t  |  _ |  j d ƒ d  S(   Ns   boom!(   R3   R4   t   fail(   R5   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR+   y   s    	(   R   R   R6   R4   R+   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR<   w   s   R+   i   (   R   R   R7   R.   R8   R4   R   R9   t   lenR$   t   failIfR:   (   R   R<   R   R0   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_failurev   s    c         C   s{   t  j d ƒ } t j ƒ  } | j | ƒ |  j | j ƒ |  j d | j ƒ |  j d t	 | j
 ƒ ƒ |  j | j ƒ  ƒ d  S(   NR+   i   (   R   R-   R   R7   R.   R8   R4   R   R9   R>   R#   R?   R:   (   R   R   R0   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt
   test_error…   s    c         C   sŽ   d t  f d „  ƒ  Y} | d ƒ } t j ƒ  } | j | ƒ |  j | j ƒ |  j d | j ƒ |  j d t | j	 ƒ ƒ |  j | j
 ƒ  ƒ d  S(   NR-   c           B   s    e  Z e Z d  „  Z d „  Z RS(   c         S   s   d d d  S(   Ni   i    (    (   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR   ’   s    c         S   s   t  |  _ d  S(   N(   R3   R4   (   R5   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR+   ”   s    (   R   R   R6   R4   R   R+   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR-      s   	R+   i   (   R   R   R7   R.   R?   R4   R   R9   R>   R#   R:   (   R   R-   R   R0   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_setUpError   s    c         C   sŽ   y d d Wn& t  k
 r4 t j ƒ  } t ƒ  } n Xt j ƒ  } t | ƒ } | j |  | ƒ |  j | j	 d d d j
 t j | Œ  ƒ ƒ d S(   s‘   
        Errors added through the L{PyUnitResultAdapter} have the same traceback
        information as if there were no adapter at all.
        i   i    t    N(   t   ZeroDivisionErrort   syst   exc_infoR   R   R7   R   R)   R   R#   t   joint	   tracebackt   format_exception(   R   RF   t   ft   pyresultR0   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_tracebackFromFailureŸ   s    c         C   s©   d t  f d „  ƒ  Y} | d ƒ } t j ƒ  } | j | ƒ d j t j | j d ƒ ƒ } d j | j d d j	 ƒ  d	  ƒ } |  j
 | j ƒ  | t | ƒ j ƒ  ƒ d
 S(   sG   
        As test_tracebackFromFailure, but covering more code.
        R-   c           B   s   e  Z d Z d  „  Z RS(   c         S   s6   y d d Wn# t  k
 r1 t j ƒ  |  _ ‚  n Xd  S(   Ni   i    (   RD   RE   RF   (   R   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR+   ¶   s
    N(   R   R   t   NoneRF   R+   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR-   ´   s   R+   RC   i   s   
i    i   iÿÿÿÿN(   R   R   R7   R.   RG   RH   t	   format_tbRF   R#   t
   splitlinesR   t   stripR>   (   R   R-   R   R0   t   expected_stackt   observed_stack(    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_traceback°   s    	$c         C   s˜   y d d Wn& t  k
 r4 t j ƒ  } t ƒ  } n X| j ƒ  t j ƒ  } t | ƒ } | j |  | ƒ |  j	 | j
 d d d j t j | Œ  ƒ ƒ d S(   sÙ   
        Errors added through the L{PyUnitResultAdapter} have the same
        traceback information as if there were no adapter at all, even
        if the Failure that held the information has been cleaned.
        i   i    RC   N(   RD   RE   RF   R   t   cleanFailureR   R7   R   R)   R   R#   RG   RH   RI   (   R   RF   RJ   RK   R0   (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   test_tracebackFromCleanFailureÎ   s    
(   R   R   R*   R1   R;   R@   RA   RB   RL   RS   RU   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyR!   9   s   	)			
			(   RE   RH   t   zope.interfaceR    t   twisted.pythonR   t   twisted.python.failureR   t   twisted.trialR   t   twisted.trial.unittestR   R   t   twisted.trial.itrialR   R   t   twisted.trial.testR   t
   __import__R   R
   R!   (    (    (    sH   /usr/lib/python2.7/dist-packages/twisted/trial/test/test_pyunitcompat.pyt   <module>   s   #