Ñò
‘à"Ic           @   s=  d  Z  d d k Z d d k l Z l Z l Z d d k Z d d k Z d d k Z d d k	 Z	 d d k
 Z
 d e i j o d d k Z n e d ƒ ‚ e i i e i ƒ p$ e i e i ƒ e i e i ƒ n d e i f d „  ƒ  YZ d e f d	 „  ƒ  YZ d
 e i f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   s   Tests for 'site'.

Tests assume the initial paths in sys.path once the interpreter has begun
executing have not been removed.

iÿÿÿÿN(   t   TestSkippedt   run_unittestt   TESTFNt   sites!   importation of site.py suppressedt   HelperFunctionsTestsc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s›   Tests for helper functions.

    The setting of the encoding (set using sys.setdefaultencoding) used by
    the Unicode implementation is not tested.

    c         C   s   t  i |  _ d S(   s   Save a copy of sys.pathN(   t   syst   patht   sys_path(   t   self(    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   setUp#   s    c         C   s   |  i  t _ d S(   s   Restore sys.pathN(   R   R   R   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   tearDown'   s    c         C   s–   d } t  i i | Œ  } t i | Œ  \ } } |  i t  i i | ƒ | ƒ | t  i i | ƒ j o |  i | | ƒ n |  i t  i i | ƒ | ƒ d  S(   Nt	   Beginningt   End(   R   R   (   t   osR   t   joinR   t   makepatht   failUnlessEqualt   abspatht   normcase(   R   t
   path_partst   original_dirt   abs_dirt   norm_dir(    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_makepath+   s    c         C   sŠ   t  i ƒ  } xw g  } t i D]8 } | o+ t i i | ƒ o | t  i | ƒ d q q ~ D]& } |  i | | j d | | f ƒ q\ Wd  S(   Ni   sB   %s from sys.path not found in set returned by _init_pathinfo(): %s(   R   t   _init_pathinfoR   R   R   t   isdirR   t
   failUnless(   R   t   dir_sett   _[1]R   t   entry(    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_init_pathinfo8   s    9 c         C   sj   |  i  | i t i j d | i ƒ |  i  t i | i ƒ d t i j ƒ |  i  t i i	 | i
 ƒ ƒ d S(   s>   Contain common code for testing results of reading a .pth files   %s not in sys.pathi    N(   R   t   importedR   t   modulesR   R   t   good_dir_pathR   R   t   existst   bad_dir_path(   R   t   pth_file(    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   pth_file_tests@   s    &c         C   sb   t  ƒ  } | i d t ƒ z7 | i ƒ  t i | i | i t ƒ  ƒ |  i	 | ƒ Wd  | i ƒ  Xd  S(   Nt   prep(
   t   PthFilet   cleanupt   Truet   createR   t
   addpackaget   base_dirt   filenamet   setR%   (   R   R$   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_addpackageG   s    	
c         C   s\   t  ƒ  } | i d t ƒ z1 | i ƒ  t i | i t ƒ  ƒ |  i | ƒ Wd  | i ƒ  Xd  S(   NR&   (	   R'   R(   R)   R*   R   t
   addsitedirR,   R.   R%   (   R   R$   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_addsitedirV   s    	
c         C   s  t  i } |  i | t i j ƒ t i t i d d | g ƒ } |  i | d ƒ t i t i d d d | g ƒ } |  i | d ƒ t	 i
 i ƒ  } d | d <t i t i d d | g d | ƒ} |  i | d ƒ t	 i
 i ƒ  } d	 | d
 <t i t i d d g d | ƒ} |  i | d ƒ d  S(   Ns   -cs$   import sys; sys.exit(%r in sys.path)i   s   -si    t   1t   PYTHONNOUSERSITEt   envs   /tmpt   PYTHONUSERBASEs=   import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))(   R   t	   USER_SITEt   assert_R   R   t
   subprocesst   callt
   executablet   assertEqualR   t   environt   copy(   R   t   usersitet   rcR4   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_s_optionc   s(    	
	
		(   t   __name__t
   __module__t   __doc__R	   R
   R   R   R%   R/   R1   R@   (    (    (    s+   /mit/python/lib/python2.6/test/test_site.pyR      s   							R'   c           B   s8   e  Z d  Z e d d d d „ Z d „  Z e d „ Z RS(   s/   Helper class for handling testing of .pth filest   timet   __testdir__t   __badc         C   s›   | d |  _  t i i d ƒ |  _ t i i |  i |  i  ƒ |  _ | |  _ | |  _ | |  _	 t i i |  i |  i ƒ |  _
 t i i |  i |  i	 ƒ |  _ d S(   s   Initialize instance variabless   .ptht    N(   R-   R   R   R   R,   R   t	   file_pathR   t   good_dirnamet   bad_dirnameR!   R#   (   R   t   filename_baseR   RI   RJ   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   __init__   s    			c         C   sw   t  |  i d ƒ } zC | d IJ| d IJ| d |  i IJ| |  i IJ| |  i IJWd | i ƒ  Xt i |  i ƒ d S(   so  Create a .pth file with a comment, blank lines, an ``import
        <self.imported>``, a line with self.good_dirname, and a line with
        self.bad_dirname.

        Creation of the directory for self.good_dir_path (based off of
        self.good_dirname) is also performed.

        Make sure to call self.cleanup() to undo anything done by this method.

        t   ws   #import @bad module names   
s	   import %sN(	   t   openRH   R   RI   RJ   t   closeR   t   mkdirR!   (   R   t   FILE(    (    s+   /mit/python/lib/python2.6/test/test_site.pyR*      s    

c         C   sá   t  i i |  i ƒ o t  i |  i ƒ n | o7 t i i |  i ƒ |  _	 |  i	 o t i |  i =q‰ n" |  i	 o |  i	 t i |  i <n t  i i |  i
 ƒ o t  i |  i
 ƒ n t  i i |  i ƒ o t  i |  i ƒ n d S(   s°   Make sure that the .pth file is deleted, self.imported is not in
        sys.modules, and that both self.good_dirname and self.bad_dirname are
        not existing directories.N(   R   R   R"   RH   t   removeR   R    t   getR   t   imported_moduleR!   t   rmdirR#   (   R   R&   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyR(   £   s    

(   RA   RB   RC   R   RL   R*   t   FalseR(   (    (    (    s+   /mit/python/lib/python2.6/test/test_site.pyR'   ~   s
   	t   ImportSideEffectTestsc           B   sq   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 RS(   s(   Test side-effects from importing 'site'.c         C   s   t  i |  _ d S(   s   Make a copy of sys.pathN(   R   R   R   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyR	   ¸   s    c         C   s   |  i  t _ d S(   s   Restore sys.pathN(   R   R   R   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyR
   ¼   s    c         C   se   t  i ƒ  xT t t t f D]C } y$ |  i t i i | i ƒ | ƒ Wq t	 j
 o
 q q Xq Wd  S(   N(
   R   t   abs__file__R   R   t   __builtin__R   R   t   isabst   __file__t   AttributeError(   R   t   module(    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_abs__file__À   s    
 $c         C   sK   t  i ƒ  t ƒ  } x1 t i D]& } |  i | | j ƒ | i | ƒ q Wd  S(   N(   R   t   removeduppathsR.   R   R   R   t   add(   R   t
   seen_pathsR   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_no_duplicate_pathsÎ   s    
	
 c         C   s   d  S(   N(    (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_add_build_dir×   s    c         C   s0   |  i  t t d ƒ ƒ |  i  t t d ƒ ƒ d  S(   Nt   quitt   exit(   R   t   hasattrRY   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_setting_quitÝ   s    c         C   s0   |  i  t t d ƒ ƒ |  i  t t d ƒ ƒ d  S(   Nt	   copyrightt   credits(   R   Rf   RY   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_setting_copyrightâ   s    c         C   s   |  i  t t d ƒ ƒ d  S(   Nt   help(   R   Rf   RY   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_setting_helpç   s    c         C   s~   t  i d j oj d d  k } | i ƒ  d i d ƒ o@ x= t i i i ƒ  D] } | d j o PqI qI W|  i d ƒ qz n d  S(   Nt   win32iÿÿÿÿi   t   cpt   mbcss   did not alias mbcs(	   R   t   platformt   localet   getdefaultlocalet
   startswitht	   encodingst   aliasest
   itervaluest   fail(   R   Rq   t   value(    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_aliasing_mbcsë   s     	c         C   s   |  i  t t d ƒ ƒ d  S(   Nt   setdefaultencoding(   R   Rf   R   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_setdefaultencoding_removedõ   s    c         C   sN   t  i i d ƒ p7 y d d  k } Wn t j
 o qJ X|  i d ƒ n d  S(   Nt   sitecustomizeiÿÿÿÿs(   sitecustomize not imported automatically(   R   R    t   has_keyR|   t   ImportErrorRw   (   R   R|   (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   test_sitecustomize_executedù   s    (   RA   RB   RC   R	   R
   R^   Rb   Rc   Rg   Rj   Rl   Ry   R{   R   (    (    (    s+   /mit/python/lib/python2.6/test/test_site.pyRW   µ   s   										
	c           C   s   t  t t ƒ d  S(   N(   R   R   RW   (    (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt	   test_main  s    t   __main__(   RC   t   unittestt   test.test_supportR    R   R   RY   R   R   Rt   R8   R    R   R   R   R6   t   makedirsR0   t   TestCaseR   t   objectR'   RW   R€   RA   (    (    (    s+   /mit/python/lib/python2.6/test/test_site.pyt   <module>   s&   c7N	