ó
ŒwÛjc           @   s   d  d l  Z  d  d l Z d  d l m Z m Z m Z m Z m Z d  d l Z d  d l	 Z	 d  d l	 m
 Z
 m Z d  d l m 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 e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ 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(   iÿÿÿÿN(   t   run_unittestt   TESTFNt   rmtreet   unlinkt   captured_stdout(   t   CoverageResultst   Trace(   t   testmodc         C   s    |  j  d ƒ r |  d  }  n  |  S(   s=   Given a .pyc/.pyo filename converts it to the appropriate .pys   .pycs   .pyoiÿÿÿÿ(   s   .pycs   .pyo(   t   endswith(   t   filename(    (    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_trace.pyt
   fix_ext_py   s    c          C   s2   t  j j t  j j t ƒ ƒ d }  t t ƒ |  f S(   s4   The .py file and module name of this file (__file__)i    (   t   ost   patht   splitextt   basenamet   __file__R
   (   t   modname(    (    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_trace.pyt   my_file_and_modname   s    "c         C   s
   |  j  j S(   N(   t   __code__t   co_firstlineno(   t   func(    (    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_trace.pyt   get_firstlineno   s    c         C   s   |  } | } | | } | S(   N(    (   t   xt   yt   at   bt   c(    (    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_trace.pyt   traced_func_linear$   s    
c         C   s+   |  } x t  d ƒ D] } | | 7} q W| S(   Ni   (   t   range(   R   R   R   t   i(    (    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_trace.pyt   traced_func_loop*   s    c         C   s   |  | t  j d ƒ S(   Ni   (   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_trace.pyt   traced_func_importing0   s    c         C   s   t  |  |  ƒ } | |  S(   N(   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_trace.pyt   traced_func_simple_caller3   s    c         C   s#   t  |  ƒ } | t | |  ƒ 7} | S(   N(   R    R   (   R   t   k(    (    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_trace.pyt   traced_func_importing_caller7   s    c         c   s*   d } x t  |  ƒ D] } | | Vq Wd  S(   Ni   (   R   (   t   numR   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_trace.pyt   traced_func_generator<   s    c          C   s+   d }  x t  d ƒ D] } |  | 7}  q Wd  S(   Ni    i
   (   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_trace.pyt   traced_func_calling_generatorA   s    c         C   s   |  d S(   Ni   (    (   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_trace.pyt   traced_doublerF   s    c          C   s/   d }  g  t  |  ƒ D] } t | ƒ ^ q } | S(   Ni
   (   R   R&   (   R!   R   t   mylist(    (    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_trace.pyt    traced_caller_list_comprehensionI   s    %t   TracedClassc           B   sA   e  Z d  „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z RS(   c         C   s   | |  _  d  S(   N(   R   (   t   selfR   (    (    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_trace.pyt   __init__P   s    c         C   s   |  j  | S(   N(   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_trace.pyt   inst_method_linearS   s    c         C   s    |  j  | ƒ } | t | | ƒ S(   N(   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_trace.pyt   inst_method_callingV   s    c         C   s   | d S(   Ni   (    (   t   clsR   (    (    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_trace.pyt   class_method_linearZ   s    c         C   s   |  d S(   Ni   (    (   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_trace.pyt   static_method_linear^   s    (	   t   __name__t
   __module__R+   R,   R-   t   classmethodR/   t   staticmethodR0   (    (    (    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_trace.pyR)   O   s
   			t   TestLineCountsc           B   sM   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s/   White-box testing of line-counting, via runfuncc      	   C   s7   t  d d d d d d d d ƒ |  _ t t ƒ |  _ d  S(   Nt   counti   t   tracei    t
   countfuncst   countcallers(   R   t   tracerR
   R   t   my_py_filename(   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_trace.pyt   setUph   s    $c         C   s‹   |  j  j t d d ƒ } |  j | d ƒ i  } t t ƒ } x. t d d ƒ D] } d | |  j | | f <qJ W|  j |  j  j ƒ  j | ƒ d  S(   Ni   i   i   i   (	   R:   t   runfuncR   t   assertEqualR   R   R;   t   resultst   counts(   R*   t   resultt   expectedt   firstlinenoR   (    (    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_trace.pyt   test_traced_func_linearl   s    c         C   s˜   |  j  j t d d ƒ t t ƒ } i d |  j | d f 6d |  j | d f 6d |  j | d f 6d |  j | d f 6} |  j |  j  j ƒ  j | ƒ d  S(   Ni   i   i   i   i   i   (   R:   R=   R   R   R;   R>   R?   R@   (   R*   RC   RB   (    (    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_trace.pyt   test_traced_func_loopx   s    c         C   sˆ   |  j  j t d d ƒ t t ƒ } i d |  j | d f 6d t t j ƒ d f 6d t t j ƒ d f 6} |  j |  j  j	 ƒ  j
 | ƒ d  S(   Ni   i   i   i   (   R:   R=   R   R   R;   R
   R   R   R>   R?   R@   (   R*   RC   RB   (    (    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_trace.pyt   test_traced_func_importing„   s    c         C   sÆ   |  j  j t ƒ t t ƒ } t t ƒ } i d |  j | d f 6d |  j | d f 6d |  j | d f 6d |  j | d f 6d |  j | d f 6d |  j | d f 6} |  j |  j  j ƒ  j | ƒ d  S(   Ni   i   i   i
   i   (	   R:   R=   R%   R   R$   R;   R>   R?   R@   (   R*   t   firstlineno_callingt   firstlineno_genRB   (    (    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_trace.pyt   test_trace_func_generator�   s    c         C   sž   |  j  j t ƒ t t ƒ } t t ƒ } i d |  j | d f 6d |  j | d f 6d |  j | d f 6d |  j | d f 6} |  j |  j  j ƒ  j | ƒ d  S(   Ni   i   i   i   i
   (	   R:   R=   R(   R   R&   R;   R>   R?   R@   (   R*   RG   t   firstlineno_calledRB   (    (    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_trace.pyt   test_trace_list_comprehensionŸ   s    c      
   C   s£   xœ d g D]‘ } t  d d d d d d d d ƒ } t d ƒ } t | | ƒ } | j | d	 ƒ t | ƒ } i d |  j | d f 6} |  j | j ƒ  j | ƒ q
 Wd  S(
   NR,   R6   i   R7   i    R8   R9   i   i   (	   R   R)   t   getattrR=   R   R;   R>   R?   R@   (   R*   t   methnameR:   t
   traced_objt   methodRC   RB   (    (    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_trace.pyt   test_linear_methods­   s    !(
   R1   R2   t   __doc__R<   RD   RE   RF   RI   RK   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_trace.pyR5   f   s   						t   TestRunExecCountsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s8   A simple sanity test of line-counting, via runctx (exec)c         C   s   t  t ƒ |  _ d  S(   N(   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_trace.pyR<   ¿   s    c      	   C   sù   t  d d d d d d d d ƒ |  _ d } t | t d ƒ } |  j j | t ƒ  t ƒ  ƒ t t ƒ } i d |  j	 | d f 6d	 |  j	 | d
 f 6d |  j	 | d f 6d |  j	 | d f 6} x8 | j
 ƒ  D]* } |  j |  j j ƒ  j | | | ƒ qÇ Wd  S(   NR6   i   R7   i    R8   R9   s   traced_func_loop(2, 5)t   execi   i   i   i   i   (   R   R:   t   compileR   t   runctxt   globalst   varsR   R   R;   t   keysR>   R?   R@   (   R*   t   codeRC   RB   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_trace.pyt   test_exec_countsÂ   s    $(   R1   R2   RQ   R<   RZ   (    (    (    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_trace.pyRR   ½   s   	t	   TestFuncsc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s"   White-box testing of funcs tracingc         C   s.   t  d d d d d d ƒ |  _ t ƒ  |  _ d  S(   NR6   i    R7   R8   i   (   R   R:   R   t   filemod(   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_trace.pyR<   Ú   s    c         C   sU   |  j  j t d ƒ i d |  j d 6d |  j d 6} |  j |  j  j ƒ  j | ƒ d  S(   Ni   R    R   (   R    (   R   (   R:   R=   R    R\   R>   R?   t   calledfuncs(   R*   RB   (    (    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_trace.pyt   test_simple_callerÞ   s
    c         C   sŠ   |  j  j t d ƒ i d |  j d 6d |  j d	 6d |  j d
 6d |  j d 6d t t j ƒ d d f 6} |  j |  j  j ƒ  j	 | ƒ d  S(   Ni   R    R   R"   R   R   R   (   R    (   R   (   R"   (   R   (
   R:   R=   R"   R\   R
   R   R   R>   R?   R]   (   R*   RB   (    (    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_trace.pyt   test_loop_caller_importingç   s    c         C   sr   t  d ƒ } |  j j | j d ƒ i d |  j d 6d |  j d 6d |  j d 6} |  j |  j j ƒ  j | ƒ d  S(	   Ni   i   s   TracedClass.inst_method_callings   TracedClass.inst_method_linearR   (   s   TracedClass.inst_method_calling(   s   TracedClass.inst_method_linear(   R   (   R)   R:   R=   R-   R\   R>   R?   R]   (   R*   t   objRB   (    (    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_trace.pyt   test_inst_method_callingó   s    (   R1   R2   RQ   R<   R^   R_   Ra   (    (    (    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_trace.pyR[   Ø   s
   				t   TestCallersc           B   s    e  Z d  Z d „  Z d „  Z RS(   s$   White-box testing of callers tracingc         C   s.   t  d d d d d d ƒ |  _ t ƒ  |  _ d  S(   NR6   i    R7   R9   i   (   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_trace.pyR<     s    c         C   sä   |  j  j t d ƒ i d t j j t j ƒ d d d d f |  j d f 6d |  j d |  j d f 6d |  j d |  j d f 6d |  j d |  j d f 6d |  j d t	 t
 j ƒ d
 d f f 6} |  j |  j  j ƒ  j | ƒ d  S(   Ni   i    s   .pyR7   s   Trace.runfuncR"   R    R   R   R   R   (   R"   (   R    (   R   (   R"   (   R    (   R"   (   R   (   R   (   R:   R=   R"   R   R   R   R7   R   R\   R
   R   R>   R?   t   callers(   R*   RB   (    (    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_trace.pyR_     s    4)(   R1   R2   RQ   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_trace.pyRb   ÿ   s   	t   TestCoveragec           B   s8   e  Z d  „  Z d d „ Z d „  Z d „  Z d „  Z RS(   c         C   s   t  t ƒ t t ƒ d  S(   N(   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_trace.pyt   tearDown  s    
s5   from test import test_pprint; test_pprint.test_main()c         C   s9   | j  | ƒ | j ƒ  } | j d t d t d t ƒ d  S(   Nt   show_missingt   summaryt   coverdir(   t   runR?   t   write_resultst   TrueR   (   R*   R:   t   cmdt   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_trace.pyt	   _coverage  s    c         C   s–   t  j d d d d ƒ } t ƒ  � } |  j | ƒ Wd  QX| j ƒ  } |  j d | ƒ |  j d | ƒ t j t ƒ } |  j d | ƒ |  j d | ƒ d  S(	   NR7   i    R6   i   s	   pprint.pys   case.pys   pprint.covers   unittest.case.cover(	   R7   R   R   Rn   t   getvaluet   assertInR   t   listdirR   (   R*   R:   t   stdoutt   files(    (    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_trace.pyt   test_coverage#  s    c         C   s¥   t  j j t  j j t  j ƒ ƒ } t j d t j t j	 | g d d d d ƒ } t
 ƒ  � } |  j | ƒ Wd  QXt  j j t ƒ r¡ t  j t ƒ } |  j | g  ƒ n  d  S(   Nt
   ignoredirsR7   i    R6   i   (   R   R   t   normpatht   dirnameR   R7   R   t   syst   prefixt   exec_prefixR   Rn   t   existsR   Rq   R>   (   R*   t   libpathR:   Rr   Rs   (    (    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_trace.pyt   test_coverage_ignore.  s    !c   
      C   s
  t  j d d d d ƒ } d } | t j k r: t j | =n  d } t ƒ  � } |  j | | ƒ Wd  QX| j d ƒ | j ƒ  i  } xG | D]? } | j ƒ  d  \ } } }	 t	 | ƒ t	 | d  ƒ f | |	 <q† Wt  j
 t j | j ƒ } |  j | | ƒ |  j | | d ƒ d  S(   NR7   i    R6   i   s   test.tracedmodules.testmods<   import test.tracedmodules.testmod as t;t.func(0); t.func2();i   iÿÿÿÿi   id   (   i   id   (   R7   R   Rx   t   modulesR   Rn   t   seekt   readlinet   splitt   intt   fullmodnameR   Rp   R>   (
   R*   R:   R   Rl   Rr   t   coveraget   linet   linest   covt   module(    (    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_trace.pyt   test_issue9936:  s     
$(   R1   R2   Re   Rn   Rt   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_trace.pyRd     s
   			c           C   s   t  t ƒ d  S(   N(   R    R1   (    (    (    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_trace.pyt	   test_mainP  s    t   __main__($   R   Rx   t   test.test_supportR    R   R   R   R   t   unittestR7   R   R   t   test.tracedmodulesR   R
   R   R   R   R   R   R    R"   R$   R%   R&   R(   t   objectR)   t   TestCaseR5   RR   R[   Rb   Rd   RŠ   R1   (    (    (    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_trace.pyt   <module>   s6   (			
									W'8	