ó
­«Y]c           @   sÒ  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z d Z d Z d Z d Z	 d Z
 e d Z e e d	 d
 ƒ Z e e d	 d
 ƒ Z e e e d	 d
 ƒ Z e e
 e e d	 d
 ƒ Z e e e d	 d
 ƒ Z e e	 e d	 d
 ƒ Z e e
 e e d	 d
 ƒ Z d Z d d d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d d „  ƒ  YZ d d  d „  ƒ  YZ d d! d „  ƒ  YZ d e j f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e d k rÎe ƒ  n  d S("   iÿÿÿÿN(   t   test_supportsH   def get_name():
    return __name__
def get_file():
    return __file__
s   import sub
s   from . import sub
s   from .... import sub
s'   from __future__ import absolute_import
s   reloaded = True
s   <???>t   execs   !!!_test_!!!t   TestImporterc           B   sÇ   e  Z i e e f d  6e e f d 6e e f d 6e e f d 6e e f d 6e e f d 6e e f d 6e e f d 6e e	 f d 6e e f d	 6e e f d
 6Z
 e d „ Z d „  Z d d „ Z d „  Z RS(   t   hooktestmodulet   hooktestpackages   hooktestpackage.subs   hooktestpackage.sub.subbers   hooktestpackage.oldabss   hooktestpackage.newabss   hooktestpackage.newrels!   hooktestpackage.sub.subber.subests   hooktestpackage.futrelt   subt   reloadmodulec         C   s"   | t  k r t ‚ n  | |  _ d  S(   N(   t	   test_patht   ImportErrort   path(   t   selfR	   (    (    s&   lib/python2.7/test/test_importhooks.pyt   __init__4   s    	c         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R
   (    (    s&   lib/python2.7/test/test_importhooks.pyt   _get__path__;   s    c         C   s   | |  j  k r |  Sd  Sd  S(   N(   t   modulest   None(   R
   t   fullnameR	   (    (    s&   lib/python2.7/test/test_importhooks.pyt   find_module>   s    c         B   st   |  j  | \ } } e j  j | e j | ƒ ƒ } d |  j j | _ |  | _ | re |  j	 ƒ  | _
 n  | | j U| S(   Ns   <%s>(   R   t   syst
   setdefaultt   impt
   new_modulet	   __class__t   __name__t   __file__t
   __loader__R   t   __path__t   __dict__(   R
   R   t   ispkgt   codet   mod(    (    s&   lib/python2.7/test/test_importhooks.pyt   load_moduleD   s    	N(   R   t
   __module__t   Falset   test_cot   Truet   test2_oldabs_cot   test2_newabs_cot   test2_newrel_cot   test2_deeprel_cot   test2_futrel_coR   R   R   R   R   R   R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR   $   s    	t   MetaImporterc           B   s   e  Z d  „  Z RS(   c         C   s   g  S(   N(    (   R
   (    (    s&   lib/python2.7/test/test_importhooks.pyR   P   s    (   R   R    R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR)   O   s   t   PathImporterc           B   s   e  Z d  „  Z RS(   c         C   s
   |  j  g S(   N(   R	   (   R
   (    (    s&   lib/python2.7/test/test_importhooks.pyR   T   s    (   R   R    R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR*   S   s   t   ImportBlockerc           B   s,   e  Z d  Z d „  Z d d „ Z d „  Z RS(   s‘   Place an ImportBlocker instance on sys.meta_path and you
    can be sure the modules you specified can't be imported, even
    if it's a builtin.c         G   s   t  j | ƒ |  _ d  S(   N(   t   dictt   fromkeyst   namestoblock(   R
   R.   (    (    s&   lib/python2.7/test/test_importhooks.pyR   \   s    c         C   s   | |  j  k r |  Sd  S(   N(   R.   R   (   R
   R   R	   (    (    s&   lib/python2.7/test/test_importhooks.pyR   ^   s    c         C   s   t  d ‚ d  S(   Ns
   I dare you(   R   (   R
   R   (    (    s&   lib/python2.7/test/test_importhooks.pyR   b   s    N(   R   R    t   __doc__R   R   R   R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR+   X   s   	t
   ImpWrapperc           B   s    e  Z d d  „ Z d d „ Z RS(   c         C   s5   | d  k	 r( t j j | ƒ r( t ‚ n  | |  _ d  S(   N(   R   t   osR	   t   isdirR   (   R
   R	   (    (    s&   lib/python2.7/test/test_importhooks.pyR   h   s    	c         C   sš   | j  d ƒ d } | | k r2 |  j d  k r2 d  S|  j d  k rJ d  } n |  j g } y t j | | ƒ \ } } } Wn t k
 r‰ d  SXt | | | ƒ S(   Nt   .iÿÿÿÿ(   t   splitR	   R   R   R   R   t	   ImpLoader(   R
   R   R	   t   subnamet   filet   filenamet   stuff(    (    s&   lib/python2.7/test/test_importhooks.pyR   m   s    	N(   R   R    R   R   R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR0   f   s   R5   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  | |  _ | |  _ d  S(   N(   R7   R8   R9   (   R
   R7   R8   R9   (    (    s&   lib/python2.7/test/test_importhooks.pyR   ~   s    		c         C   sG   t  j | |  j |  j |  j ƒ } |  j r: |  j j ƒ  n  |  | _ | S(   N(   R   R   R7   R8   R9   t   closeR   (   R
   R   R   (    (    s&   lib/python2.7/test/test_importhooks.pyR   ƒ   s
    !		(   R   R    R   R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR5   |   s   	t   ImportHooksBaseTestCasec           B   s   e  Z d  „  Z d „  Z RS(   c         C   sJ   t  j |  _ t  j |  _ t  j |  _ t  j j ƒ  t  j j ƒ  |  _ d  S(   N(	   R   R	   t	   meta_patht
   path_hookst   path_importer_cachet   clearR   t   copyt   modules_before(   R
   (    (    s&   lib/python2.7/test/test_importhooks.pyt   setUp   s
    c         C   sX   |  j  t j  (|  j t j (|  j t j (t j j ƒ  t j j ƒ  t j j |  j ƒ d  S(   N(	   R	   R   R<   R=   R>   R?   R   t   updateRA   (   R
   (    (    s&   lib/python2.7/test/test_importhooks.pyt   tearDown”   s    (   R   R    RB   RD   (    (    (    s&   lib/python2.7/test/test_importhooks.pyR;   ‹   s   	t   ImportHooksTestCasec           B   s8   e  Z d d  „ Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s¶  d d  l  } d d  l } d d  l } d d  l } |  j | j ƒ  d ƒ |  j | j ƒ  d ƒ |  j | j j ƒ  d ƒ |  j | j j j ƒ  d ƒ | rï |  j | j | ƒ |  j | j | ƒ |  j | j j | ƒ |  j | j j j | ƒ n  t	 t
 f t j d <d d  l } |  j t | d ƒ ƒ t	 t f t j d <t j | ƒ |  j t | d ƒ ƒ d d  l } |  j | j j ƒ  d ƒ |  j | j j | j ƒ d d  l } |  j | j j ƒ  d	 ƒ |  j | j j | j ƒ d d  l j j j } |  j | j ƒ  d
 ƒ |  j | j | j ƒ d d  l } |  j | j j ƒ  d ƒ |  j | j j | j ƒ d d  l } |  j | j ƒ  d ƒ d d  l } |  j | j j ƒ  d ƒ |  j | j j | ƒ d  S(   NiÿÿÿÿR   R   s   hooktestpackage.subs   hooktestpackage.sub.subberR   t   reloadeds   hooktestpackage.oldabss   hooktestpackage.newrels!   hooktestpackage.sub.subber.subests   hooktestpackage.futrelR   s   hooktestpackage.newabs(   R   R   t   hooktestpackage.subt   hooktestpackage.sub.subbert   assertEqualt   get_nameR   t   subberR   R!   R"   R   R   R   t   assertFalset   hasattrt	   reload_coR   t   reloadt
   assertTruet   hooktestpackage.oldabst   oldabst   hooktestpackage.newrelt   newrelt!   hooktestpackage.sub.subber.subestt   subestt   hooktestpackage.futrelt   futrelt   hooktestpackage.newabst   newabs(   R
   t   importerR   R   R   RV   R   (    (    s&   lib/python2.7/test/test_importhooks.pyt   doTestImportsŸ   sb    



c         C   s*   t  ƒ  } t j j | ƒ |  j | ƒ d  S(   N(   R)   R   R<   t   appendR\   (   R
   t   i(    (    s&   lib/python2.7/test/test_importhooks.pyt   testMetaPathÚ   s    	c         C   s.   t  j j t ƒ t  j j t ƒ |  j ƒ  d  S(   N(   R   R=   R]   R*   R	   R   R\   (   R
   (    (    s&   lib/python2.7/test/test_importhooks.pyt   testPathHookß   s    c         C   s@   d } t  j | ƒ t j j t | ƒ ƒ |  j t t | ƒ d  S(   Nt
   exceptions(	   R    t   unloadR   R<   R]   R+   t   assertRaisesR   t
   __import__(   R
   t   mname(    (    s&   lib/python2.7/test/test_importhooks.pyt   testBlockerä   s    c      
   C   sß   t  ƒ  } t j j | ƒ t j j t  ƒ d	 } xW | D]O } | j d ƒ d } x3 t j j ƒ  D]" } | j | ƒ r_ t j | =q_ q_ Wq6 Wt	 j
 d t f ƒ ; x3 | D]+ } t | t ƒ  t ƒ  d g ƒ } | j q¦ WWd  QXd  S(
   Nt   colorsyst   urlparses   distutils.cores   compiler.miscR3   i    s.   The compiler package is deprecated and removedt	   __dummy__(   Rg   Rh   s   distutils.cores   compiler.misc(   R0   R   R<   R]   R=   R4   R   t   keyst
   startswithR    t   check_warningst   DeprecationWarningRd   t   globalst   localsR   (   R
   R^   t   mnamesRe   t   parentt   nt   m(    (    s&   lib/python2.7/test/test_importhooks.pyt   testImpWrapperê   s    		N(   R   R    R   R\   R_   R`   Rf   Rt   (    (    (    s&   lib/python2.7/test/test_importhooks.pyRE      s
   ;			c           C   s   t  j t ƒ d  S(   N(   R    t   run_unittestRE   (    (    (    s&   lib/python2.7/test/test_importhooks.pyt	   test_mainû   s    t   __main__(    (    (    (    (    R   R   R1   t   unittestt   testR    t   test_srct   absimpt   relimpt
   deeprelimpt   futimpt
   reload_srct   compileR"   RN   R$   R%   R&   R'   R(   R   R   R)   R*   R+   R0   R5   t   TestCaseR;   RE   Rv   R   (    (    (    s&   lib/python2.7/test/test_importhooks.pyt   <module>   s<   +^	