Ñò
à"Ic           @   s¸   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k l Z l Z l	 Z	 l
 Z
 d  d k l Z d e i f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   TESTFNt   unlinkt   run_unittestt   captured_output(   t   ignore_message_warningt   ExceptionTestsc           B   st   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 RS(   c         C   sG   y d d  k  } t | ƒ Wn& t j
 o } |  i d | ƒ n Xd  S(   Niÿÿÿÿs   reloading exceptions: %s(   t
   exceptionst   reloadt   ImportErrort   fail(   t   selfR   t   e(    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt
   testReload   s
    c      	   C   sŒ   y | d ‚ Wn! | j
 o } t  | ƒ } n Xy | d ƒ ‚ Wn! | j
 o } t  | ƒ } n X|  i | | ƒ |  i | i | ƒ d  S(   Nt   spam(   t   strt   assertEqualst   __name__(   R
   t   exct   excnamet   errt   buf1t   buf2(    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   raise_catch   s    c         B   s;  |  i  e d ƒ |  i e e e d ƒ |  i  e d ƒ e e d ƒ } | i ƒ  e e d ƒ } e i	 } z0 y | e _	 e
 ƒ  } Wn e j
 o n XWd  | e _	 | i ƒ  e e ƒ X|  i  e d ƒ |  i e e d d ƒ |  i  e d ƒ |  i e e d	 ƒ |  i  e d
 ƒ g  } |  i e | i d ƒ |  i  e d ƒ h  } |  i e | i d ƒ |  i  e d ƒ |  i  e d ƒ |  i  e d ƒ y
 e } Wn e j
 o n X|  i  e d ƒ d } x e d ƒ D] } | | 7} qÌW|  i  e d ƒ |  i  e d ƒ y d d  UWn e j
 o n X|  i  e d ƒ |  i  e d ƒ |  i  e d ƒ |  i  e d ƒ |  i e e i d ƒ |  i  e d ƒ y g  d! Wn e j
 o n X|  i  e  d ƒ |  i e  e! d ƒ |  i  e" d ƒ y d d } Wn e" j
 o n X|  i  e# d  ƒ y d d } Wn e# j
 o	 } n Xd  S("   Nt   AttributeErrort   undefined_attributet   EOFErrort   wt   rt   IOErrors   this file does not existR   t   undefined_modulet
   IndexErrori
   t   KeyErrort   keyt   KeyboardInterruptt   MemoryErrort	   NameErrort   OverflowErrori   i€   t   RuntimeErrort   SyntaxErrors   /
t   IndentationErrort   TabErrort   SystemErrort
   SystemExiti    t	   TypeErrort
   ValueErrori'  t   ZeroDivisionErrort	   Exception(    ($   R   R   t   assertRaisest   getattrt   sysR   t   openR    t   closet   stdint	   raw_inputR   R   R   t
   __import__R   t   __getitem__R   R!   R"   R#   t   undefined_variableR$   t   rangeR%   R&   R'   R(   R)   R*   t   exitR+   R,   t   chrR-   R.   (   R
   t   fpt	   savestdint   xt   dummyR   (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testRaising%   s„    
				
 
          c            s]   ‡  f d †  } d } t  i i d ƒ p | | d ƒ n d } | | d ƒ | d d ƒ d  S(   Nc            sk   y t  |  d d ƒ WnC t j
 o7 } | i | j o ˆ  i d | | i f ƒ qg n Xˆ  i d ƒ d  S(   Ns
   <fragment>t   execs   expected %s, got %ss"   failed to get expected SyntaxError(   t   compileR&   t   msgR	   (   t   srcRC   R   (   R
   (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   ckmsgz   s    #s\   while 1:
            try:
                pass
            finally:
                continuet   javas0   'continue' not supported inside 'finally' clausesH   if 1:
        try:
            continue
        except:
            passs   'continue' not properly in loops	   continue
(   R1   t   platformt
   startswith(   R
   RE   t   s(    (   R
   s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testSyntaxErrorMessagev   s    c            s`   d d d „  ƒ  Y‰  ‡  ‡ f d †  } ‡  ‡ f d †  } t  i i d ƒ p | ƒ  | ƒ  n d  S(   Nt   BadExceptionc           B   s   e  Z d  „  Z RS(   c         S   s   t  d ‚ d  S(   Ns   can't instantiate BadException(   R%   (   t   self_(    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   __init__š   s    (   R   t
   __module__RM   (    (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyRK   ™   s   c             s¡   d d  k  }  y |  i ˆ  d ƒ Wnm t j
 oa } t i ƒ  \ } } } | i i } ˆ i | i d ƒ ˆ i	 | i
 i d t i d ƒ ƒ n Xˆ i d ƒ d  S(   Niÿÿÿÿi   t
   test_capi1t   test_exceptionst   pys   Expected exception(   t	   _testcapit   raise_exceptionR+   R1   t   exc_infot   tb_framet   f_codeR   t   co_namet   assert_t   co_filenamet   endswitht   ost   extsepR	   (   RR   R   R   t   tbt   co(   RK   R
   (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyRO      s    )c             sÃ   d d  k  }  y |  i ˆ  d ƒ Wn t j
 oƒ } t i ƒ  \ } } } | i i } ˆ i | i d ƒ ˆ i	 | i
 i d t i d ƒ ƒ | i i i } ˆ i | i d ƒ n Xˆ i d ƒ d  S(   Niÿÿÿÿi    RM   RP   RQ   t
   test_capi2s   Expected exception(   RR   RS   R%   R1   RT   RU   RV   R   RW   RX   RY   RZ   R[   R\   t   f_backR	   (   RR   R   R   R]   R^   t   co2(   RK   R
   (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR_   ©   s    $RF   (    (   R1   RG   RH   (   R
   RO   R_   (    (   RK   R
   s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testSettingException•   s    c         C   s•   y t  Wn t j
 o nu X|  i t t  d ƒ ƒ d ƒ |  i t t  d d ƒ ƒ d ƒ |  i t  d d ƒ i d ƒ |  i t  d d ƒ i d ƒ d  S(   Nié  t   1001t   messages   [Error 1001] messagei   (   t   WindowsErrorR#   t   failUnlessEqualR   t   errnot   winerror(   R
   (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   test_WindowsError»   s    c         C   sY  t  d+ h d d 6d, d 6f t  d- h d d 6d. d 6f t  d/ h d d 6d0 d 6f t  d1 h d d 6d2 d 6f t d3 h d d 6d4 d 6d d 6f t d5 h d d 6d6 d 6d  d 6d  d 6d  d	 6f t d7 h d d 6d8 d 6d  d 6d d 6d
 d	 6f t d9 h d d 6d: d 6d d 6d d 6d
 d	 6f t d; h d d 6d< d 6f t d= h d d 6d> d 6d d	 6d d 6d d 6f t d? h d d 6d@ d 6d d 6d d	 6d d 6f t dA h d d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6f t dB h d d 6dC d 6d  d 6d  d 6d d 6d  d 6d  d 6d  d 6f t d dD f h d d 6d d 6d d 6d dE f d 6d  d 6d d 6d d 6d d 6f t dF h d d 6d  d 6dG d 6d  d 6d d 6d  d 6d  d 6d  d 6f t dH h d d 6dI d 6f t dJ h d d 6dK d 6d d 6d d 6d d  6d d! 6f t dL h d d 6dM d 6d d 6d" d 6d d  6d d! 6f t	 dN h d d 6dO d 6d# d 6d$ d! 6d d  6d d% 6f g } yD | i
 t dP h d d 6dQ d 6d d	 6d d& 6d' d 6d d 6f ƒ Wn t j
 o n Xt i ƒ  i i ƒ  z|t ƒ  xn| D]f\ } } } y | | Œ  ‚ Wqåt  j
 o8} t | ƒ | j	 o ‚  n |  i t | ƒ i d( ƒ t | ƒ } xJ | D]B } |  i t t | | ƒ ƒ t | | ƒ d) t | ƒ | f ƒ q]Wx¥ t t f D]’ } x‰ t | i d ƒ D]t }	 | i | i | |	 ƒ ƒ }
 xP | D]H } t t |
 | ƒ ƒ } t | | ƒ } |  i | | d* | | f ƒ qòWqÊWq°WqåXqåWWd  QXd  S(R   Nt    Rd   t   argsi   t   foot   codet   filenameRg   t   strerrort   bart   bazt   quuxt   errnoStrt   strErrorStrt   filenameStrRC   t   textt   linenot   offsett   print_file_and_linet   msgStrt	   linenoStrt	   offsetStrt   textStrt   print_file_and_lineStrt   asciiu   ai    s   ordinal not in ranget   encodingt   objectt   startt   reasons   ÿu   ã‚t   oucht   endRh   i   R   s   exception "%s", attribute "%s"s   pickled "%r", attribute "%s"(    (    (   i   (   i   (   Rl   (   Rl   (   Rl   i   (   Rl   i   (   Rl   (   Rl   (   Rl   (   Rl   (   Rl   Rp   (   Rl   Rp   (   Rl   Rp   Rq   (   Rl   Rp   (   Rl   Rp   Rq   Rr   (   Rl   Rp   Rq   Rr   (   Rs   Rt   Ru   (   Rs   Rt   (   i   Rt   Ru   (   i   Rt   (    (   Rz   (   Rz   (   Ru   R{   R|   R}   (   Ru   R{   R|   R}   (   Rz   Ru   R{   R|   R}   R~   (   Rz   Ru   R{   R|   R}   R~   (    (    (   s   asciiu   ai    i   s   ordinal not in range(   s   asciiu   ai    i   s   ordinal not in range(   s   asciis   ÿi    i   s   ordinal not in range(   s   asciis   ÿi    i   s   ordinal not in range(   u   ã‚i    i   R„   (   u   ã‚i    i   R„   (   i   Rt   Ru   (   i   Rt   (   t   BaseExceptionR*   R   t   Nonet   EnvironmentErrorR&   t   UnicodeErrort   UnicodeEncodeErrort   UnicodeDecodeErrort   UnicodeTranslateErrort   appendRe   R#   t   warningst   catch_warningst   __exit__t	   __enter__R   t   typeR   RN   R   t   reprR0   t   picklet   cPickleR9   t   HIGHEST_PROTOCOLt   loadst   dumps(   R
   t   exceptionListR   Rk   t   expectedR   RI   t   checkArgNamet   pt   protocolt   newt   gott   want(    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testAttributesÈ   sÆ    


 

     c         C   s'   d } t  | Œ  } |  i | | ƒ d  S(   Ni   i   i   (   i   i   i   (   R†   Rf   (   R
   Rk   R   (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testSlicing2  s    c         C   sR   |  i  t t d d ƒd t f d „  ƒ  Y} | d d ƒ } |  i | i d ƒ d  S(   Nt   ai   t   DerivedExceptionc           B   s   e  Z d  „  Z RS(   c         S   s   t  i |  ƒ | |  _ d  S(   N(   R†   RM   t	   fancy_arg(   R
   R¥   (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyRM   ?  s    (   R   RN   RM   (    (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR¤   >  s   R¥   i*   (   R/   R+   R†   R   R¥   (   R
   R¤   R>   (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testKeywordArgs9  s    c            s‘   ‡ f d †  ‰ |  i  t ˆ ƒ ‡  f d †  ‰  t d ƒ i i ƒ  zE y ˆ  ƒ  Wn& t j
 o n" |  i d ƒ n X|  i d ƒ Wd  QXd  S(   Nc              s   ˆ  ƒ  S(   N(    (    (   t   f(    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR§   G  s    c              s&   y ˆ  ƒ  SWn t  j
 o d SXd  S(   Niÿÿÿÿ(   R,   (    (   t   g(    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR¨   K  s    t   stderrs   Should have raised KeyError(   R/   R%   R   R   R‘   R	   (   R
   (    (   R¨   R§   s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testInfiniteRecursionF  s    	c         C   su   |  i  t t ƒ ƒ |  i  t t ƒ ƒ |  i  t t d ƒ ƒ ƒ |  i  t t d ƒ ƒ ƒ |  i  t t d ƒ ƒ ƒ d  S(   NR£   u   au   Ã¡(   t
   failUnlessR   R.   t   unicode(   R
   (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   testUnicodeStrUsage^  s
    c            s?  d t  f d „  ƒ  Y‰ d t f ‡ f d †  ƒ  Y} t d ƒ i i ƒ  } zq | ~ } y t ƒ  ‚ WnG | j
 o } |  i d ƒ n4 t j
 o n" |  i d ƒ n X|  i d ƒ Wd  QXt d ƒ i i ƒ  } z` | ~ } ‡  f d †  ‰  ˆ  ƒ  \ } } } |  i | t j | ƒ |  i d	 t	 | ƒ j | ƒ Wd  QXd  S(
   Nt   Metac           B   s   e  Z d  „  Z RS(   c         S   s   t  ƒ  ‚ d  S(   N(   R,   (   t   clst   subclass(    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   __subclasscheck__k  s    (   R   RN   R±   (    (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR®   j  s   t   MyExceptionc              s   e  Z ˆ  Z RS(    (   R   RN   t   __metaclass__(    (   R®   (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR²   n  s   R©   s%   exception should not be a MyExceptions   Should have raised KeyErrorc              s,   y ˆ  ƒ  SWn t  j
 o t i ƒ  SXd  S(   N(   R%   R1   RT   (    (   R¨   (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR¨     s    s    maximum recursion depth exceeded(
   R’   R.   R   R   R‘   R   R	   RX   R%   R   (   R
   R²   t   _[1]R©   R   t   _[2]t   vR]   (    (   R¨   R®   s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   test_badisinstanceg  s"    ##(   R   RN   R   R   R@   RJ   Rb   Ri   R¡   R¢   R¦   Rª   R­   R·   (    (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyR      s   				Q		&		j					c           C   s   t  t ƒ d  S(   N(   R   R   (    (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt	   test_main‰  s    t   __main__(   R[   R1   t   unittestR”   R•   RŽ   t   test.test_supportR    R   R   R   t   test.test_pep352R   t   TestCaseR   R¸   R   (    (    (    s1   /mit/python/lib/python2.6/test/test_exceptions.pyt   <module>   s   "ÿ |	