ó
ûR‹_c           @   s˜   d  d l  m Z d  d l m Z m Z m Z d  d l m Z d d l	 m
 Z
 m Z m Z d d l m Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿ(   t   dedent(   t
   Comparisont   ShouldRaiset   should_raise(   t   TestCasei   (   t   PY3t
   PY_36_PLUSt
   PY_37_PLUS(   t   ShouldAssertt   TestShouldAssertc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sI   y t  d ƒ  Wd  QXWn+ t k
 rD } t | ƒ d k sE t ‚ n Xd  S(   Nt   foos,   Expected AssertionError('foo'), None raised!(   R   t   AssertionErrort   str(   t   selft   e(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_no_exception   s
    
c         C   s8   y  t  d ƒ  t ƒ  ‚ Wd  QXWn t k
 r3 n Xd  S(   NR
   (   R   t   KeyError(   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_wrong_exception   s
    c         C   sa   y) t  d ƒ  t s" t d ƒ ‚ Wd  QXWn1 t k
 r\ } t | ƒ t d ƒ k s] t ‚ n Xd  S(   NR
   t   bars                   --- expected
                +++ actual
                @@ -1 +1,2 @@
                -foo
                +bar
                +assert False(   R   t   FalseR   R   R    (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_wrong_text   s    (   t   __name__t
   __module__R   R   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR	   
   s   		t   TestShouldRaisec           B   sC  e  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$ RS(#   c         C   s&   d „  } t  t d ƒ ƒ | ƒ ƒ  d  S(   Nc           S   s   t  d ƒ ‚ d  S(   Ns   wrong value supplied(   t
   ValueError(    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   to_test,   s    s   wrong value supplied(   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_no_params+   s    	c         C   s6   d „  } t  d ƒ  t t ƒ  ƒ | ƒ ƒ  Wd  QXd  S(   Nc           S   s   d  S(   N(    (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   1   s    s(   ValueError() (expected) != None (raised)(   R   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   0   s    	c         C   sN   d „  } t  r d } n d } t | ƒ  t t d ƒ ƒ | ƒ ƒ  Wd  QXd  S(   Nc           S   s   t  d ƒ ‚ d  S(   NR   (   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   7   s    s:   ValueError('foo') (expected) != ValueError('bar') (raised)s<   ValueError('foo',) (expected) != ValueError('bar',) (raised)R
   (   R   R   R   R   (   R   R   t   expected(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   6   s    		c         C   s    d „  } t  t ƒ | ƒ ƒ  d  S(   Nc           S   s   t  d ƒ ‚ d  S(   NR   (   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   A   s    (   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_only_exception_class@   s    	c         C   sW   d „  } t  r d } n t r' d } n d } t | ƒ  t t ƒ | ƒ ƒ  Wd  QXd  S(   Nc           S   s   t  d ƒ ‚ d  S(   NR   (   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   F   s    s;   <class 'KeyError'> (expected) != ValueError('bar') (raised)s<   <class 'KeyError'> (expected) != ValueError('bar',) (raised)sF   <type 'exceptions.KeyError'> (expected) != ValueError('bar',) (raised)(   R   R   R   R   R   (   R   R   t   message(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_wrong_exception_classE   s    			c         C   s0   d „  } t  d ƒ  t ƒ  | ƒ ƒ  Wd  QXd  S(   Nc           S   s   d  S(   N(    (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   X   s    s   No exception raised!(   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_no_supplied_or_raisedT   s    	c         C   s)   d „  } t  t d ƒ ƒ | ƒ d ƒ d  S(   Nc          W   s   t  d t |  ƒ ƒ ‚ d  S(   Ns   %s(   R   t   repr(   t   args(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   ^   s    s   (1,)i   (   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt	   test_args]   s    	c         C   s,   d „  } t  t d ƒ ƒ | ƒ d d ƒ d  S(   Nc         S   s   t  d |  ƒ ‚ d  S(   Ns   %s(   R   (   t   x(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   c   s    t   1R#   i   (   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_kw_to_argsb   s    	c         C   s,   d „  } t  t d ƒ ƒ | ƒ d d ƒ d  S(   Nc          [   s   t  d |  ƒ ‚ d  S(   Ns   %r(   R   (   t   kw(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   h   s    s   {'x': 1}R#   i   (   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_kwg   s    	c         C   s/   d „  } t  t d ƒ ƒ | ƒ d d d ƒd  S(   Nc          _   s   t  d |  | f ƒ ‚ d  S(   Ns   %r %r(   R   (   R!   R&   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   m   s    s   (1,) {'x': 2}i   R#   i   (   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt	   test_bothl   s    	c         C   sR   d d d „  ƒ  Y} | ƒ  } t  t ƒ | j ƒ d d d ƒ |  j | j d ƒ d  S(   Nt   Xc           B   s   e  Z d  „  Z RS(   c         W   s   | |  _  t ƒ  ‚ d  S(   N(   R!   R   (   R   R!   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   s   s    	(   R   R   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR)   r   s   i   i   i   (    (   i   i   i   (   R   R   R   t   assertEqualR!   (   R   R)   R#   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_method_argsq   s    	c         C   sc   d d d „  ƒ  Y} | ƒ  } t  t ƒ | j ƒ d d d d ƒ |  j | j i d d 6d d 6ƒ d  S(   NR)   c           B   s   e  Z d  „  Z RS(   c         [   s   | |  _  t ƒ  ‚ d  S(   N(   R&   R   (   R   R&   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   |   s    	(   R   R   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR)   {   s   R#   i   t   yi   (    (   R   R   R   R*   R&   (   R   R)   R#   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_method_kwz   s    	"c         C   sl   d d d „  ƒ  Y} | ƒ  } t  t ƒ | j ƒ d d d ƒ|  j | j d ƒ |  j | j i d d 6ƒ d  S(   NR)   c           B   s   e  Z d  „  Z RS(   c         _   s   | |  _  | |  _ t ƒ  ‚ d  S(   N(   R!   R&   R   (   R   R!   R&   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   …   s    		(   R   R   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR)   „   s   i   R,   i   (    (   i   (   R   R   R   R*   R!   R&   (   R   R)   R#   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_method_bothƒ   s
    	c         C   s*   d d d „  ƒ  Y} t  t ƒ | ƒ ƒ  d  S(   Nt   Testc           B   s   e  Z d  „  Z RS(   c         S   s   d  S(   N(    (   R   R#   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   __init__   s    (   R   R   R0   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR/      s   (    (   R   t	   TypeError(   R   R/   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_class_classŽ   s    c         C   sA   t  ƒ   } t d ƒ ‚ Wd  QX|  j | j t t d ƒ ƒ ƒ d  S(   Ns   wrong value supplied(   R   R   R*   t   raisedt   C(   R   t   s(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_raised–   s    c         C   s    t  t ƒ  t ƒ  ‚ Wd  QXd  S(   N(   R   t
   SystemExit(   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_catch_baseexception_1›   s    c         C   s    t  t ƒ  t ƒ  ‚ Wd  QXd  S(   N(   R   t   KeyboardInterrupt(   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_catch_baseexception_2Ÿ   s    c         C   s#   t  t ƒ  t d ƒ ‚ Wd  QXd  S(   Ns   foo bar(   R   R   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt"   test_with_exception_class_supplied£   s    c         C   s)   t  t d ƒ ƒ  t d ƒ ‚ Wd  QXd  S(   Ns   foo bar(   R   R   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_with_exception_supplied§   s    c      
   C   sQ   t  r d } n d } t | ƒ * t t d ƒ ƒ  t d ƒ ‚ Wd  QXWd  QXd  S(   Ns:   ValueError('foo') (expected) != ValueError('bar') (raised)s<   ValueError('foo',) (expected) != ValueError('bar',) (raised)R
   R   (   R   R   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt'   test_with_exception_supplied_wrong_args«   s    	c         C   s    t  ƒ   t d ƒ ‚ Wd  QXd  S(   Ns   foo bar(   R   R   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_neither_supplied´   s    
c      	   C   sE   t  r d } n d } t | ƒ  t t d ƒ ƒ  Wd  QXWd  QXd  S(   Ns-   ValueError('foo') (expected) != None (raised)s.   ValueError('foo',) (expected) != None (raised)R
   (   R   R   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt$   test_with_no_exception_when_expected¸   s    	c      	   C   s'   t  d ƒ  t ƒ   Wd  QXWd  QXd  S(   Ns   No exception raised!(   R   R   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt,   test_with_no_exception_when_neither_expectedÁ   s    
c         C   s=   t  d ƒ } t ƒ   } | ‚ Wd  QX| | j k s9 t ‚ d  S(   Ns   foo bar(   R   R   R3   R   (   R   R   R5   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt"   test_with_getting_raised_exceptionÆ   s    c         C   sP   t  r d } n d } t r! t n t } t | | ƒ ƒ  d d  l } Wd  QXd  S(   Ns   No module named 'textfixtures's$   No module named textfixtures.foo.bariÿÿÿÿ(   R   R   t   ModuleNotFoundErrort   ImportErrorR   t   textfixtures.foo.bar(   R   R   t	   exceptiont   textfixtures(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_import_errors_1Ì   s    	c         C   s)   t  t d ƒ ƒ  t d ƒ ‚ Wd  QXd  S(   NR)   (   R   RC   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_import_errors_2×   s    c         C   s?   d t  f d „  ƒ  Y} t | d ƒ ƒ  | d ƒ ‚ Wd  QXd  S(   Nt   FileTypeErrorc           B   s   e  Z d  „  Z RS(   c         S   s   | |  _  d  S(   N(   t   value(   R   RJ   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR0   Þ   s    (   R   R   R0   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyRI   Ý   s   R)   (   t	   ExceptionR   (   R   RI   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_custom_exceptionÛ   s    c      	   C   se   d t  f d „  ƒ  Y} t r% d } n d } t | ƒ ( t t d ƒ ƒ  | ƒ  j Wd  QXWd  QXd  S(   Nt   Dodgyc           B   s   e  Z d  „  Z RS(   c         S   s   |  | S(   N(    (   R   t   name(    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   __getattr__ç   s    (   R   R   RO   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyRM   æ   s   s<   AttributeError('foo') (expected) != KeyError('foo') (raised)s>   AttributeError('foo',) (expected) != KeyError('foo',) (raised)R
   (   t   dictR   R   R   t   AttributeErrorR
   (   R   RM   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_assert_keyerror_raisedä   s    	c         C   s&   t  t d ƒ ƒ d „  ƒ } | ƒ  d  S(   Nt   badc           S   s   t  d ƒ ‚ d  S(   NRS   (   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   õ   s    (   R   R   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_decorator_usageó   s    c         C   s#   t  d t ƒ  t ƒ  ‚ Wd  QXd  S(   Nt   unless(   R   R   RQ   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_unless_false_okayû   s    c      	   C   s-   t  d ƒ  t d t ƒ  Wd  QXWd  QXd  S(   Ns   No exception raised!RU   (   R   R   R   (   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_unless_false_badÿ   s    c         C   s   t  d t ƒ  Wd  QXd  S(   NRU   (   R   t   True(   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_unless_true_okay  s    c      
   C   sN   t  r d } n d } t | ƒ ' t d t ƒ  t d ƒ ‚ Wd  QXWd  QXd  S(   Ns3   AttributeError('foo') raised, no exception expecteds4   AttributeError('foo',) raised, no exception expectedRU   R
   (   R   R   R   RX   RQ   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_unless_true_not_okay  s    	c         C   s#   t  d t ƒ d „  ƒ } | ƒ  d  S(   NRU   c           S   s   d  S(   N(    (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR     s    (   R   RX   (   R   R   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_unless_decorator_usage  s    c         C   sX   d t  f d „  ƒ  Y} t d ƒ 0 t | d d ƒ ƒ  | d d ƒ ‚ Wd  QXWd  QXd  S(   Nt   AnnoyingExceptionc           B   s   e  Z d  „  Z RS(   c         [   s   | j  d ƒ |  _ d  S(   Nt   other(   t   getR]   (   R   R&   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR0     s    (   R   R   R0   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR\     s   s¹   AnnoyingException not as expected:

attributes same:
['args']

attributes differ:
'other': 'bar' (expected) != 'baz' (raised)

While comparing .other: 'bar' (expected) != 'baz' (raised)R]   R   t   baz(   RK   R   R   (   R   R\   (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   test_identical_reprs  s
    
(%   R   R   R   R   R   R   R   R   R"   R%   R'   R(   R+   R-   R.   R2   R6   R8   R:   R;   R<   R=   R>   R?   R@   RA   RG   RH   RL   RR   RT   RV   RW   RY   RZ   R[   R`   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyR   )   sF   			
																																						N(   t   textwrapR    t   testfixturesR   R4   R   R   t   unittestR   t   compatR   R   R   t   shouldraiseR   t   objectR	   R   (    (    (    s]   /var/www/syncserver/local/lib/python2.7/site-packages/testfixtures/tests/test_should_raise.pyt   <module>   s   