mò
­fIc           @   sJ  d  k  Z  d  k Z d  k Z d  k Z d k l Z d Z e d Z e e d d ƒ Z	 e e d d ƒ Z
 d Z d f  d „  ƒ  YZ d	 f  d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d f  d „  ƒ  YZ d f  d „  ƒ  YZ d f  d „  ƒ  YZ d e i f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e d j o e ƒ  n d  S(   N(   s   test_supportsH   def get_name():
    return __name__
def get_file():
    return __file__
s   reloaded = True
s   <???>t   execs   !!!_test_!!!t   ImportTrackerc           B   s#   t  Z d  Z d „  Z e d „ Z RS(   s,   Importer that only tracks attempted imports.c         C   s   g  |  _ d  S(   N(   t   selft   imports(   R   (    (    t2   /mit/python/lib/python2.4/test/test_importhooks.pyt   __init__   s    c         C   s   |  i i | ƒ d  S(   N(   R   R   t   appendt   fullnamet   None(   R   R   t   path(    (    R   t   find_module   s    (   t   __name__t
   __module__t   __doc__R   R   R
   (    (    (    R   R      s    	t   TestImporterc           B   sƒ   t  Z h  d e e f <d e e f <d e e f <d e e f <d e e f <Z e d „ Z d „  Z d  d „ Z
 d	 „  Z RS(
   Nt   hooktestmodulet   hooktestpackages   hooktestpackage.subs   hooktestpackage.sub.subbert   reloadmodulec         C   s$   | t j o
 t ‚ n | |  _  d  S(   N(   R	   t	   test_patht   ImportErrorR   (   R   R	   (    (    R   R   ,   s    
c         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R   (    (    R   t   _get__path__3   s    c         C   s    | |  i j o |  Sn d  Sd  S(   N(   R   R   t   modulesR   (   R   R   R	   (    (    R   R
   6   s    c         B   sv   |  i | \ } } e i i | e i | ƒ ƒ } d |  i
 i | _ |  | _ | o |  i ƒ  | _ n | | i U| S(   Ns   <%s>(   R   R   R   t   ispkgt   codet   syst
   setdefaultt   impt
   new_modulet   modt	   __class__R   t   __file__t
   __loader__R   t   __path__t   __dict__(   R   R   R   R   R   (    (    R   t   load_module<   s    	(   R   R   t   Falset   test_cot   TrueR   R   R   R   R   R
   R#   (    (    (    R   R   "   s
   Q	t   MetaImporterc           B   s   t  Z d „  Z RS(   Nc         C   s   g  S(   N(    (   R   (    (    R   R   H   s    (   R   R   R   (    (    (    R   R'   G   s   t   PathImporterc           B   s   t  Z d „  Z RS(   Nc         C   s
   |  i g S(   N(   R   R	   (   R   (    (    R   R   L   s    (   R   R   R   (    (    (    R   R(   K   s   t   ImportBlockerc           B   s,   t  Z d  Z d „  Z e 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  i | ƒ |  _ d  S(   N(   t   dictt   fromkeyst   namestoblockR   (   R   R,   (    (    R   R   T   s    c         C   s   | |  i j o |  Sn d  S(   N(   R   R   R,   R   (   R   R   R	   (    (    R   R
   V   s    c         C   s   t  d ‚ d  S(   Ns
   I dare you(   R   (   R   R   (    (    R   R#   Z   s    (   R   R   R   R   R   R
   R#   (    (    (    R   R)   P   s    	t
   ImpWrapperc           B   s    t  Z d  d „ Z d  d „ Z RS(   Nc         C   s8   | d  j	 o t i  i | ƒ o
 t ‚ n | |  _  d  S(   N(   R	   R   t   ost   isdirR   R   (   R   R	   (    (    R   R   `   s    !
c         C   s§   | i d ƒ d } | | j o |  i d  j o d  Sn |  i d  j o
 d  } n |  i g } y t i | | ƒ \ } } } Wn t j
 o d  Sn Xt | | | ƒ S(   Nt   .iÿÿÿÿ(   R   t   splitt   subnameR   R	   R   R   R
   t   filet   filenamet   stuffR   t	   ImpLoader(   R   R   R	   R4   R5   R2   R3   (    (    R   R
   e   s    
	(   R   R   R   R   R
   (    (    (    R   R-   ^   s   R6   c           B   s   t  Z d „  Z d „  Z RS(   Nc         C   s   | |  _  | |  _ | |  _ d  S(   N(   R3   R   R4   R5   (   R   R3   R4   R5   (    (    R   R   v   s    		c         C   sI   t  i | |  i |  i |  i ƒ } |  i o |  i i ƒ  n |  | _	 | S(   N(
   R   R#   R   R   R3   R4   R5   R   t   closeR    (   R   R   R   (    (    R   R#   {   s
    !
	(   R   R   R   R#   (    (    (    R   R6   t   s   	t   ImportHooksBaseTestCasec           B   s   t  Z d „  Z d „  Z RS(   Nc         C   sZ   t  i |  _ t  i |  _ t  i |  _ t  i i ƒ  t ƒ  |  _ t  i i	 d |  i ƒ d  S(   Ni    (
   R   R	   R   t	   meta_patht
   path_hookst   path_importer_cachet   clearR   t   trackert   insert(   R   (    (    R   t   setUp…   s    c         C   sm   |  i t i (|  i t i (|  i t i (t i i ƒ  x2 |  i i D]$ } | t i
 j o t i
 | =qA qA Wd  S(   N(   R   R	   R   R9   R:   R;   R<   R=   R   R   R   (   R   R   (    (    R   t   tearDown   s     (   R   R   R?   R@   (    (    (    R   R8   ƒ   s   	t   ImportHooksTestCasec           B   s8   t  Z d  d „ Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   sN  d  k  } d  k } d  k } d  k } |  i | i ƒ  d ƒ |  i | i ƒ  d ƒ |  i | i i ƒ  d ƒ |  i | i i i ƒ  d ƒ | oY |  i | i
 | ƒ |  i | i
 | ƒ |  i | i i
 | ƒ |  i | i i i
 | ƒ n t t f t i d <d  k } |  i t | d ƒ ƒ t t f t i d <t | ƒ |  i t | d ƒ ƒ d  S(   NR   R   s   hooktestpackage.subs   hooktestpackage.sub.subberR   t   reloaded(   R   R   t   hooktestpackage.subt   hooktestpackage.sub.subberR   t   assertEqualt   get_namet   subt   subbert   importerR    R$   R%   R   R   R   t   failIft   hasattrt	   reload_cot   reloadt
   failUnless(   R   RI   R   R   R   (    (    R   t   doTestImports™   s.    					
c         C   s*   t  ƒ  } t i i | ƒ |  i | ƒ d  S(   N(   R'   t   iR   R9   R   R   RO   (   R   RP   (    (    R   t   testMetaPath´   s    	c         C   s.   t  i i t ƒ t  i i t ƒ |  i ƒ  d  S(   N(   R   R:   R   R(   R	   R   R   RO   (   R   (    (    R   t   testPathHook¹   s    c         C   ss   d } | t i j o t i | =n t i i t | ƒ ƒ y t | ƒ Wn t j
 o n X|  i	 d | ƒ d  S(   Nt
   exceptionss&   '%s' was not supposed to be importable(
   t   mnameR   R   R9   R   R)   t
   __import__R   R   t   fail(   R   RT   (    (    R   t   testBlocker¾   s    c         C   sé   t  ƒ  } t i i | ƒ t i i t  ƒ d	 } xY | D]Q } | i d ƒ d } x5 t i
 i ƒ  D]$ } | i | ƒ o t i
 | =q_ q_ Wq6 Wx3 | D]+ } t | t ƒ  t ƒ  d g ƒ } | i q’ Wy t i
 d =Wn t j
 o n Xd  S(
   Nt   colorsyst   urlparses   distutils.cores   compiler.miscR0   i    t	   __dummy__t   urllib(   RX   RY   s   distutils.cores   compiler.misc(   R-   RP   R   R9   R   R:   t   mnamesRT   R1   t   parentR   t   keyst   nt
   startswithRU   t   globalst   localst   mR    t   KeyError(   R   R]   R\   RP   RT   Rc   R_   (    (    R   t   testImpWrapperÊ   s&    	   (   R   R   R   RO   RQ   RR   RW   Re   (    (    (    R   RA   —   s
   			c           C   s   t  i t ƒ d  S(   N(   t   test_supportt   run_unittestRA   (    (    (    R   t	   test_mainß   s    t   __main__(   R   R   R.   t   unittestt   testRf   t   test_srct
   reload_srct   compileR%   RL   R   R   R   R'   R(   R)   R-   R6   t   TestCaseR8   RA   Rh   R   (   Rf   RL   Rm   Rl   Rj   R6   R   R   R   R-   Rh   R(   RA   R8   R   R'   R%   R   R)   R.   (    (    R   t   ?   s*   				
	%H	