ó
‹wÛjc           @   s²   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z e  j d „  ƒ Z e  j d „  ƒ Z d e f d „  ƒ  YZ	 d e j
 f d „  ƒ  YZ d „  Z e d	 k r® e ƒ  n  d S(
   iÿÿÿÿNc       	   g   s›   xT |  D]L } | d k r1 t  d j | ƒ ƒ ‚ n  y t j | =Wq t k
 rR q Xq Wz	 d VWd x0 |  D]( } y t j | =Wqj t k
 r‘ qj Xqj WXd S(   sš   Uncache a module from sys.modules.

    A basic sanity check is performed to prevent uncaching modules that either
    cannot/shouldn't be uncached.

    t   syst   marshalt   imps.   cannot uncache {0} as it will break _importlibN(   R    R   R   (   t
   ValueErrort   formatR    t   modulest   KeyError(   t   namest   name(    (    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_importlib.pyt   uncache   s    	c          k   sò   i  } z· x� d g  f d g  f d g  f d i  f f D]U \ } } t  t | ƒ | | <| |  k rs |  | } |  | =n | } t t | | ƒ q4 Wt |  ƒ r· t d j |  j ƒ  ƒ ƒ ‚ n  d VWd x* | j ƒ  D] \ } } t t | | ƒ qÍ WXd S(   s,  Context manager to manage the various importers and stored state in the
    sys module.

    The 'modules' attribute is not supported as the interpreter state stores a
    pointer to the dict that the interpreter uses internally;
    reassigning to sys.modules does not have the desired effect.

    t	   meta_patht   patht
   path_hookst   path_importer_caches   unrecognized arguments: {0}N(   t   getattrR    t   setattrt   lenR   R   t   keyst   items(   t   kwargst	   originalst   attrt   defaultt	   new_valuet   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_importlib.pyt   import_state"   s"    
	

	t   mock_modulesc           B   sG   e  Z d  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 RS(   s   A mock importer/loader.c         G   sâ   i  |  _  xÒ | D]Ê } | j d ƒ s. | } n | t d ƒ  } d | k rT d  } n+ | | k ry | j d d ƒ d } n | } t j | ƒ } |  | _ d | _ | | _	 | | _
 | | k rÍ d g | _ n  | |  j  | <q Wd  S(   Ns	   .__init__t   .i   i    s   <mock __file__>s   <mock __path__>(   R   t   endswithR   t   Nonet   rsplitR   t
   new_modulet
   __loader__t   __file__t   __package__R   t   __path__(   t   selfR   R   t   import_namet   packaget   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_importlib.pyt   __init__E   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_importlib.pyt   __getitem__[   s    c         C   s   | |  j  k r d  S|  Sd  S(   N(   R   R   (   R$   t   fullnameR   (    (    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_importlib.pyt   find_module^   s    c         C   s;   | |  j  k r t ‚ n |  j  | t j  | <|  j  | Sd  S(   N(   R   t   ImportErrorR    (   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_importlib.pyt   load_moduled   s    	c         C   s)   t  |  j j ƒ  Œ  |  _ |  j j ƒ  |  S(   N(   R	   R   R   t   _uncachet	   __enter__(   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_importlib.pyR/   k   s    c         G   s   |  j  j d  d  d  ƒ d  S(   N(   R.   t   __exit__R   (   R$   t   exc_info(    (    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_importlib.pyR0   p   s    N(
   t   __name__t
   __module__t   __doc__R(   R)   R   R+   R-   R/   R0   (    (    (    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_importlib.pyR   A   s   				t   ImportModuleTestsc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Test importlib.import_module.c         C   sT   t  d ƒ �B } t d | g ƒ �' t j d ƒ } |  j | j d ƒ Wd  QXWd  QXd  S(   Nt	   top_levelR
   (   R   R   t	   importlibt   import_modulet   assertEqualR2   (   R$   t   mockR'   (    (    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_importlib.pyt   test_module_importy   s    c         C   s{   d } d j  | ƒ } d j  | ƒ } t | | ƒ �B } t d | g ƒ �' t j | ƒ } |  j | j | ƒ Wd  QXWd  QXd  S(   Nt   pkgs   {0}.__init__s   {0}.modR
   (   R   R   R   R7   R8   R9   R2   (   R$   t   pkg_namet   pkg_long_nameR   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_importlib.pyt   test_absolute_package_import€   s    c         C   si   d d d d g } t  | Œ  �E } t d | g ƒ �* t j d d ƒ } |  j | j d ƒ Wd  QXWd  QXd  S(   Ns
   a.__init__s   a.b.__init__s   a.b.c.__init__s   a.b.c.dR
   s   .ds   a.b.c(   R   R   R7   R8   R9   R2   (   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_importlib.pyt$   test_shallow_relative_package_importŠ   s
    c         C   sf   d d d g } t  | Œ  �E } t d | g ƒ �* t j d d ƒ } |  j | j d ƒ Wd  QXWd  QXd  S(   Ns
   a.__init__s   a.b.__init__s   a.cR
   s   ..cs   a.b(   R   R   R7   R8   R9   R2   (   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_importlib.pyt!   test_deep_relative_package_import‘   s
    c         C   s~   d } d j  | ƒ } d j  | ƒ } t | | ƒ �E } t d | g ƒ �* t j | | ƒ } |  j | j | ƒ Wd  QXWd  QXd  S(   NR<   s   {0}.__init__s   {0}.modR
   (   R   R   R   R7   R8   R9   R2   (   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_importlib.pyt!   test_absolute_import_with_package™   s    c         C   s   |  j  t t j d ƒ d  S(   Ns   .support(   t   assertRaisest	   TypeErrorR7   R8   (   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_importlib.pyt   test_relative_import_wo_package¤   s    (	   R2   R3   R4   R;   R?   R@   RA   RB   RE   (    (    (    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_importlib.pyR5   u   s   		
			c          C   s   d d l  m }  |  t ƒ d  S(   Niÿÿÿÿ(   t   run_unittest(   t   test.test_supportRF   R5   (   RF   (    (    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_importlib.pyt	   test_mainª   s    t   __main__(   t
   contextlibR   R7   R    t   unittestt   contextmanagerR	   R   t   objectR   t   TestCaseR5   RH   R2   (    (    (    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_importlib.pyt   <module>   s   45	