ó
ß‘Uc           @   s  d  d l  Z  d  d l Z d  d l Z d  d l m Z d  d l Z d „  Z d e f d „  ƒ  YZ d e j	 f d „  ƒ  YZ
 d e
 f d	 „  ƒ  YZ d
 e
 f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e  j d „  ƒ Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   StringIOc          G   s
   t  j ƒ  S(   N(   t	   unittest2t
   TestResult(   t   _(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   resultFactory
   s    t   OldTestResultc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s?   An object honouring TestResult before startTestRun/stopTestRun.c         G   s(   g  |  _  g  |  _ d |  _ t |  _ d  S(   Ni    (   t   failurest   errorst   testsRunt   Falset
   shouldStop(   t   selfR   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   __init__   s    			c         C   s   |  j  d 7_  d  S(   Ni   (   R   (   R   t   test(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt	   startTest   s    c         C   s   d  S(   N(    (   R   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   stopTest   s    c         C   s   |  j  j | | f ƒ d  S(   N(   R   t   append(   R   R   t   err(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   addError   s    c         C   s   |  j  j | | f ƒ d  S(   N(   R   R   (   R   R   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt
   addFailure    s    c         C   s   d  S(   N(    (   R   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt
   addSuccess#   s    c         C   s   t  S(   N(   t   True(   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   wasSuccessful&   s    c         C   s   d  S(   N(    (   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   printErrors)   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR      s   							t   _BaseLoggingResultc           B   sk   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z RS(   c         C   s    | |  _  t t |  ƒ j ƒ  d  S(   N(   t   _eventst   superR   R   (   R   t   log(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   -   s    	c         C   s*   |  j  j d ƒ t t |  ƒ j | ƒ d  S(   NR   (   R   R   R   R   R   (   R   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   1   s    c         C   s'   |  j  j d ƒ t t |  ƒ j ƒ  d  S(   Nt   startTestRun(   R   R   R   R   R   (   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   5   s    c         C   s*   |  j  j d ƒ t t |  ƒ j | ƒ d  S(   NR   (   R   R   R   R   R   (   R   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   9   s    c         C   s'   |  j  j d ƒ t t |  ƒ j ƒ  d  S(   Nt   stopTestRun(   R   R   R   R   R    (   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR    =   s    c         G   s*   |  j  j d ƒ t t |  ƒ j | Œ  d  S(   NR   (   R   R   R   R   R   (   R   t   args(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   A   s    c         G   s*   |  j  j d ƒ t t |  ƒ j | Œ  d  S(   NR   (   R   R   R   R   R   (   R   R!   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   E   s    c         G   s*   |  j  j d ƒ t t |  ƒ j | Œ  d  S(   NR   (   R   R   R   R   R   (   R   R!   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   I   s    c         G   s*   |  j  j d ƒ t t |  ƒ j | Œ  d  S(   Nt   addSkip(   R   R   R   R   R"   (   R   R!   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR"   M   s    c         G   s*   |  j  j d ƒ t t |  ƒ j | Œ  d  S(   Nt   addExpectedFailure(   R   R   R   R   R#   (   R   R!   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR#   Q   s    c         G   s*   |  j  j d ƒ t t |  ƒ j | Œ  d  S(   Nt   addUnexpectedSuccess(   R   R   R   R   R$   (   R   R!   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR$   U   s    (   R   R   R   R   R   R   R    R   R   R   R"   R#   R$   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR   ,   s   										t   LegacyLoggingResultc           B   s   e  Z d  Z e d „  ƒ Z RS(   so   
    A legacy TestResult implementation, without an addSubTest method,
    which records its method calls.
    c         C   s
   t  ‚ d  S(   N(   t   AttributeError(   R   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt
   addSubTest`   s    (   R   R   R   t   propertyR'   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR%   Z   s   t   LoggingResultc           B   s   e  Z d  Z d „  Z RS(   sE   
    A TestResult implementation which records its method calls.
    c         C   sO   | d  k r |  j j d ƒ n |  j j d ƒ t t |  ƒ j | | | ƒ d  S(   Nt   addSubTestSuccesst   addSubTestFailure(   t   NoneR   R   R   R)   R'   (   R   R   t   subtestR   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR'   j   s    (   R   R   R   R'   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR)   e   s   t   EqualityMixinc           B   s    e  Z d  Z d „  Z d „  Z RS(   s   Used as a mixin for TestCasec         C   s>   x7 |  j  D], \ } } |  j | | ƒ |  j | | ƒ q
 Wd  S(   N(   t   eq_pairst   assertEqual(   R   t   obj_1t   obj_2(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   test_eqv   s    c         C   s>   x7 |  j  D], \ } } |  j | | ƒ |  j | | ƒ q
 Wd  S(   N(   t   ne_pairst   assertNotEqual(   R   R1   R2   (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   test_ne|   s    (   R   R   R   R3   R6   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR.   r   s   	t   HashingMixinc           B   s   e  Z d  Z d „  Z RS(   s   Used as a mixin for TestCasec         C   s   x‹ |  j  D]€ \ } } y6 t | ƒ t | ƒ k sK |  j d | | f ƒ n  Wq
 t k
 r‰ t j ƒ  d } |  j d | | | f ƒ q
 Xq
 Wx‹ |  j D]€ \ } } y6 t | ƒ t | ƒ k rÙ |  j d | | f ƒ n  Wq˜ t k
 rt j ƒ  d } |  j d | | | f ƒ q˜ Xq˜ Wd  S(   Ns   %r and %r do not hash equali   s   Problem hashing %r and %r: %ss#   %s and %s hash equal, but shouldn'ts   Problem hashing %s and %s: %s(   R/   t   hasht   failt	   Exceptiont   syst   exc_infoR4   (   R   R1   R2   t   e(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt	   test_hash…   s    "	(   R   R   R   R>   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyR7      s   c         c   sL   t  t |  ƒ } t t |  t ƒ  ƒ z t  t |  ƒ VWd t t |  | ƒ Xd S(   s‰   Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.N(   t   getattrR;   t   setattrR    (   t   stream_namet   orig_stdout(    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   captured_output˜   s
    c           C   s
   t  d ƒ S(   sŸ   Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print("hello")
       self.assertEqual(stdout.getvalue(), "hello
")
    t   stdout(   RC   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   captured_stdout£   s    c           C   s
   t  d ƒ S(   s°   Capture the output of sys.stderr:

       with captured_stderr() as stderr:
           print("hello", file=sys.stderr)
       self.assertEqual(stderr.getvalue(), "hello
")
    t   stderr(   RC   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   captured_stderr¬   s    c           C   s
   t  d ƒ S(   s  Capture the input to sys.stdin:

       with captured_stdin() as stdin:
           stdin.write('hello
')
           stdin.seek(0)
           # call test code that consumes from sys.stdin
           captured = input()
       self.assertEqual(captured, "hello")
    t   stdin(   RC   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   captured_stdinµ   s    
(   t
   contextlibR;   t   warningst	   six.movesR    R   R   t   objectR   R   R   R%   R)   R.   R7   t   contextmanagerRC   RE   RG   RI   (    (    (    s5   lib/python2.7/site-packages/unittest2/test/support.pyt   <module>   s   	.				