ó
ŒwÛjc           @   sà   d  Z  d d l m Z d d l Z d d l Z d d l m Z d d l m Z m Z m	 Z	 m
 Z
 m Z d d l Z d e j f d „  ƒ  YZ d e j f d	 „  ƒ  YZ d
 e j f d „  ƒ  YZ d „  Z e d k rÜ e ƒ  n  d S(   s   Test cases for traceback moduleiÿÿÿÿ(   t   StringION(   t   reload(   t   run_unittestt	   is_jythont   Errort   cpython_onlyt   captured_outputt   TracebackCasesc           B   s˜   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 RS(   c         C   s;   y | ƒ  Wn  | k
 r- } t  j | | ƒ SXt d ‚ d  S(   Ns   call did not raise exception(   t	   tracebackt   format_exception_onlyt
   ValueError(   t   selft   funct   exct   value(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   get_exception_format   s
    c         C   s   t  d d d ƒ d  S(   Ns   def fact(x):
	return x!
t   ?t   exec(   t   compile(   R   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   syntax_error_with_caret   s    c         C   s   t  d d d ƒ d  S(   Ns   1 +
R   R   (   R   (   R   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   syntax_error_with_caret_2   s    c         C   s   d d  l  } d  S(   Niÿÿÿÿ(   t   test.badsyntax_nocaret(   R   t   test(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   syntax_error_without_caret   s    c         C   s   t  d d d ƒ d  S(   Ns   def spam():
  print 1
 print 2R   R   (   R   (   R   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   syntax_error_bad_indentation#   s    c         C   s   t  d d d ƒ d  S(   Ns	    print(2)R   R   (   R   (   R   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   syntax_error_bad_indentation2&   s    c         C   s  |  j  |  j t ƒ } |  j t | ƒ d k ƒ |  j | d j ƒ  d k ƒ |  j d | d ƒ |  j | d j d ƒ | d j d ƒ k ƒ |  j  |  j t ƒ } |  j d | d ƒ |  j | d j	 d ƒ d k ƒ |  j | d j d ƒ | d j d ƒ k ƒ d  S(	   Ni   i   s	   return x!t   ^i   t   !s   
t   +(
   R   R   t   SyntaxErrort
   assertTruet   lent   stript   assertInt   findR   t   count(   R   t   err(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt
   test_caret)   s    	-	 c         C   sY   t  r
 d  S|  j |  j t ƒ } |  j t | ƒ d k ƒ |  j | d j ƒ  d k ƒ d  S(   Ni   i   s   [x for x in x] = x(   R   R   R   R   R   R   R    (   R   R$   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_nocaret7   s    	c         C   s�   |  j  |  j t ƒ } |  j t | ƒ d k ƒ |  j | d j ƒ  d k ƒ |  j d | d ƒ |  j | d j d ƒ | d j d ƒ k ƒ d  S(   Ni   i   s   print 2R   i   t   2(   R   R   t   IndentationErrorR   R   R    R!   R"   (   R   R$   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_bad_indentation@   s    	c         C   s!  d d  l  } d d  l } d d  l } t j } | j ƒ  } zt j j d | ƒ | j j | d ƒ } t | d ƒ d IJd t j	 k r” t j	 d =n  d d  l
 } y | j ƒ  Wn! t k
 rÑ t j t j ƒ n X| j d ƒ t | d ƒ d IJt | ƒ y | j ƒ  Wn; t k
 rGt j t j ƒ d d } |  j | d	 ƒ n XWd  | t j (x3 | j | ƒ D]" }	 | j | j j | |	 ƒ ƒ qfW| j | ƒ X|  j |  j t ƒ }
 |  j t |
 ƒ d ƒ |  j |
 d
 j ƒ  d ƒ |  j d |
 d ƒ |  j |
 d
 j d ƒ |
 d j d ƒ ƒ d  S(   Niÿÿÿÿi    s   test_bug737473.pyt   ws!   
def test():
    raise ValueErrort   test_bug737473i   s*   
def test():
    raise NotImplementedErrors   raise NotImplementedErrori   s   print(2)R   i   t   p(   t   ost   tempfilet   timet   syst   patht   mkdtempt   insertt   joint   opent   modulesR+   R   R
   R   t
   extract_tbt   exc_tracebackt   sleepR   t   NotImplementedErrort   assertEqualt   listdirt   unlinkt   rmdirR   R   R(   R   R    R!   R"   (   R   R-   R.   R/   t	   savedpatht   testdirt   testfileR+   t   srct   fR$   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyR+   H   sD    $


 	c         C   s5   t  ƒ  } t j | j | ƒ } |  j | d g ƒ d  S(   Ns   KeyboardInterrupt
(   t   KeyboardInterruptR   R	   t	   __class__R;   (   R   t   et   lst(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_base_exception|   s    	c         C   sJ   d } t  j | d  ƒ } |  j t | ƒ d ƒ |  j | d | d ƒ d  S(   Ns   String Exceptioni   i    s   
(   R   R	   t   NoneR;   R   (   R   t   str_typeR$   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_string_exception1’   s    c         C   sX   d } d } t  j | | ƒ } |  j t | ƒ d ƒ |  j | d | d | d ƒ d  S(   Ns   String Exceptions   String Valuei   i    s   : s   
(   R   R	   R;   R   (   R   RJ   t	   str_valueR$   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_string_exception2˜   s
    c         C   su   d t  f d „  ƒ  Y} t j | | ƒ  ƒ } |  j t | ƒ d ƒ d | j } |  j | d | j d | d ƒ d  S(   Nt   Xc           B   s   e  Z d  „  Z RS(   c         S   s   d d d  S(   Ni   i    (    (   R   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   __str__¡   s    (   t   __name__t
   __module__RO   (    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyRN       s   i   s   <unprintable %s object>i    s   : s   
(   t	   ExceptionR   R	   R;   R   RP   (   R   RN   R$   RL   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt%   test_format_exception_only_bad__str__Ÿ   s
    c         C   s)   t  j d  d  ƒ } |  j | d g ƒ d  S(   Ns   None
(   R   R	   RI   R;   (   R   R$   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_without_exception¨   s    c         C   sr   t  d ƒ } t j t | ƒ | ƒ } |  j | d g ƒ t  d ƒ } t j t | ƒ | ƒ } |  j | d g ƒ d  S(   Ns   ÿs   AssertionError: ÿ
u   Ã©s   AssertionError: \xe9
(   t   AssertionErrorR   R	   t   typeR;   (   R   R$   t   lines(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_unicode¬   s    (   RP   RQ   R   R   R   R   R   R   R%   R&   R)   R+   RH   RK   RM   RS   RT   RX   (    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyR      s    											4						t   TracebackFormatTestsc           B   s)   e  Z e d  „  ƒ Z d „  Z d „  Z RS(   c         C   s  d d l  m } y t d ƒ ‚ Wnd t k
 r† t j ƒ  \ } } } d d j t j | ƒ ƒ } t ƒ  } | | | ƒ | j	 ƒ  } n Xt
 d ƒ ‚ |  j | | ƒ | j ƒ  } |  j t | ƒ d ƒ | \ }	 }
 } |  j |	 j d ƒ ƒ |  j |
 j d	 ƒ ƒ |  j | j d
 ƒ ƒ d  S(   Niÿÿÿÿ(   t   traceback_printt   blahs#   Traceback (most recent call last):
t    s&   unable to create test traceback stringi   t	   Tracebacks     Files	       raise(   t	   _testcapiRZ   t   KeyErrorR0   t   exc_infoR4   R   t	   format_tbR    t   getvalueR   R;   t
   splitlinesR   R   t
   startswith(   R   RZ   t   type_R   t   tbt   traceback_fmtt   file_t
   python_fmtt   tb_linest   bannert   locationt   source_line(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_traceback_format¸   s$    	c      	   C   s‰   d „  } t  d ƒ � } | ƒ  Wd  QX| j j } | j j } |  j | j ƒ  j ƒ  d d | | d f d d | | d f d	 g ƒ d  S(
   Nc           S   s   t  j ƒ  d  S(   N(   R   t   print_stack(    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   prnÓ   s    t   stderriüÿÿÿs)     File "%s", line %d, in test_print_stacki   s	       prn()s     File "%s", line %d, in prni   s       traceback.print_stack()(   R   t   __code__t   co_firstlinenot   co_filenameR;   Rb   Rc   (   R   Rp   Rq   t   linenot   file(    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_print_stackÒ   s    	c         C   sd   d „  } | ƒ  } | j  j } | j  j } |  j | d d | | d f d | | d f g ƒ d  S(   Nc           S   s
   t  j ƒ  S(   N(   R   t   format_stack(    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   fmtá   s    iþÿÿÿs>     File "%s", line %d, in test_format_stack
    result = fmt()
i   sA     File "%s", line %d, in fmt
    return traceback.format_stack()
i   (   Rr   Rs   Rt   R;   (   R   Ry   t   resultRu   Rv   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   test_format_stackà   s    		(   RP   RQ   R   Rn   Rw   R{   (    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyRY   ¶   s   	t   MiscTracebackCasesc           B   s   e  Z d  „  Z RS(   c         C   sh   d „  } | ƒ  } | j  j } | j  j } |  j | d | | d d d f | | d d d f g ƒ d  S(	   Nc           S   s
   t  j ƒ  S(   N(   R   t   extract_stack(    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   extractô   s    iþÿÿÿi   t   test_extract_stacks   result = extract()i   R~   s    return traceback.extract_stack()(   Rr   Rs   Rt   R;   (   R   R~   Rz   Ru   Rv   (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyR   ó   s    		(   RP   RQ   R   (    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyR|   î   s   c           C   s   t  t t t ƒ d  S(   N(   R   R   RY   R|   (    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt	   test_mainÿ   s    t   __main__(   t   __doc__R    R0   t   unittestt   impR   t   test.test_supportR   R   R   R   R   R   t   TestCaseR   RY   R|   R€   RP   (    (    (    s‰   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_traceback.pyt   <module>   s   (©8	