Current File : //opt/imh-python/lib/python2.7/test/test_site.pyo
�
��Wc@s�dZddlZddlmZmZmZddlmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZde	jkr�ddlZnejd��ejrGejjej�rGy$ejej�ejej�WqGek
rCZejdejef��qGXnd	ejfd
��YZdefd��YZd
ejfd��YZd�Ze dkr�e�ndS(sTests for 'site'.

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

i����N(trun_unittesttTESTFNtEnvironmentVarGuard(tcaptured_output(tcopytsites!importation of site.py suppresseds-unable to create user site directory (%r): %stHelperFunctionsTestscBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zde	d�Z
d	�Zd
�Ze
jejdkd�d
��Zd�Ze
jejd�d��Zd�Zd�Zd�ZRS(s�Tests for helper functions.

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

    cCsGtj|_tj|_tj|_tj|_	t
tj�|_
dS(sSave a copy of sys.pathN(tsystpathtsys_pathRt	USER_BASEtold_baset	USER_SITEtold_sitetPREFIXEStold_prefixesRt	sysconfigt_CONFIG_VARStold_vars(tself((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pytsetUp-s

cCsA|jtj(|jt_|jt_|jt_	|j
t_dS(sRestore sys.pathN(
R	RRRRR
R
RRRRRR(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttearDown5s

cCs�d}tjj|�}tj|�\}}|jtjj|�|�|tjj|�krt|j||�n|jtjj|�|�dS(Nt	BeginningtEnd(RR(tosRtjoinRtmakepathtassertEqualtabspathtnormcase(Rt
path_partstoriginal_dirtabs_dirtnorm_dir((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt
test_makepath=scCsytj�}xfgtjD]1}|rtjj|�rtj|�d^qD]#}|j||d||f�qNWdS(NisB%s from sys.path not found in set returned by _init_pathinfo(): %s(Rt_init_pathinfoRRRtisdirRtassertIn(Rtdir_setRtentry((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_init_pathinfoJs5cCsc|j|jtjd|j�|jtj|j�dtj�|jt	jj
|j��dS(s>Contain common code for testing results of reading a .pth files%s not in sys.modulesiN(R%timportedRtmodulesRRt
good_dir_pathRtassertFalseRtexiststbad_dir_path(Rtpth_file((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pytpth_file_testsRs#cCsbt�}|jdt�z7|j�tj|j|jt��|j	|�Wd|j�XdS(Ntprep(
tPthFiletcleanuptTruetcreateRt
addpackagetbase_dirtfilenametsetR0(RR/((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_addpackageYs	
t.cswtjj|�}|d}tjj||��t�d�}|j�fd��|j|�|j�||fS(Ns.pthtwcs
tj��S(N(Rtremove((tpth_fn(sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt<lambda>ns(RRRRtopent
addCleanuptwritetclose(Rtcontentstpth_dirtpth_nametpth_basenameR/((R>sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pytmake_pthhs


cCs�|jd�\}}td��}tj||t��WdQX|j|j�d�|j|j�tjt	j
j||���|j|j�d�|j|j�d�|j|j�d�dS(Nsimport bad)syntax
tstderrsline 1t	Tracebacksimport bad\)syntaxtSyntaxError(RHRRR6R9tassertRegexpMatchestgetvaluetretescapeRRR(RRER>terr_out((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt!test_addpackage_import_bad_syntaxsscCs�|jd�\}}td��}tj||t��WdQX|j|j�d�|j|j�tjt	j
j||���|j|j�d�|j|j�d�dS(Nsrandompath
import nosuchmodule
RIsline 2RJtImportError(RHRRR6R9RLRMRNRORRR(RRER>RP((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_addpackage_import_bad_exec�stwin32sIWindows does not raise an error for file paths containing null characterscCs�|jd�\}}td��}tj||t��WdQX|j|j�d�|j|j�tjt	j
j||���|j|j�d�|j|j�d�dS(Ntabcdef
RIsline 1RJt	TypeError(RHRRR6R9RLRMRNRORRR(RRER>RP((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt#test_addpackage_import_bad_pth_file�scCs\t�}|jdt�z1|j�tj|jt��|j|�Wd|j�XdS(NR1(	R2R3R4R5Rt
addsitedirR7R9R0(RR/((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_addsitedir�s	
s<requires access to PEP 370 user-site (site.ENABLE_USER_SITE)cCsPtj}|j|tj�tjj�}tj	tj
dd|gd|�}|j|dd||f�tjj�}tj	tj
ddd|gd|�}|j|d�tjj�}d|d	<tj	tj
dd|gd|�}|j|d�tjj�}d
|d<tj	tj
ddgd|�}|j|d�dS(
Ns-cs$import sys; sys.exit(%r in sys.path)tenvis,%r is not in sys.path (sys.exit returned %r)s-sit1tPYTHONNOUSERSITEs/tmptPYTHONUSERBASEs=import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))(RRR%RRRtenvironRt
subprocesstcallt
executableR(RtusersiteRZtrc((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt
test_s_option�s2	
	
	

	
		cCs�dt_tj�}|jtj|�dt_ddl}d|_t��6}d|d<|jtj�j	d�tj��WdQXdS(Ni����txoxoR](
tNoneRR
tgetuserbaseRRRRt
assertTruet
startswith(Rt	user_baseRR^((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_getuserbase�s			
cCsQdt_dt_tj�}|jtj|�|j|jtj�|�dS(N(RfRRR
tgetusersitepackagesRRhRi(Rt	user_site((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_getusersitepackages�s
		cCs�dgt_tj�}tjdkrl|jt|�d�tjj	ddd�}|j|d|�nrtjdkr�t
jd	�r�d
gt_tj�}|jt|�d�tjj	dt
jd	�tjd d�}|j|d
|�n�tj
dkr�|jt|�d
�tjj	dddtjd d�}|j|d|�tjj	ddd�}|j|d|�nV|jt|�d
�|j|dd�tjj	ddd�}|j|d|�dS(NRetos2emxtriscositLibs
site-packagesitdarwintPYTHONFRAMEWORKsPython.frameworkis/Libraryit/tlibtpythonssite-python(sos2emxsriscos(RRtgetsitepackagesRtplatformRtlenRRRRtget_config_vartversiontsep(Rtdirstwanted((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_getsitepackages�s6
		(t__name__t
__module__t__doc__RRR"R(R0R:RRHRQRStunittesttskipIfRRxRWRYt
skipUnlessRtENABLE_USER_SITERdRkRnR(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyR%s 			
					$	
!			R2cBs8eZdZedddd�Zd�Zed�ZRS(s/Helper class for handling testing of .pth filesttimet__testdir__t__badcCs�|d|_tjjd�|_tjj|j|j�|_||_||_||_	tjj|j|j�|_
tjj|j|j	�|_dS(sInitialize instance variabless.pthtN(R8RRRR7Rt	file_pathR)tgood_dirnametbad_dirnameR+R.(Rt
filename_baseR)R�R�((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt__init__	s
			cCswt|jd�}zC|dIJ|dIJ|d|jIJ||jIJ||jIJWd|j�Xtj|j�dS(soCreate 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.

        R<s#import @bad module names
s	import %sN(	R@R�R)R�R�RCRtmkdirR+(RtFILE((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyR5s


cCs�tjj|j�r(tj|j�n|rbtjj|j�|_	|j	r�tj|j=q�n|j	r�|j	tj|j<ntjj|j
�r�tj|j
�ntjj|j�r�tj|j�ndS(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(
RRR-R�R=RR*tgetR)timported_moduleR+trmdirR.(RR1((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyR3+s		(R�R�R�RR�R5tFalseR3(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyR2s
	tImportSideEffectTestscBs�eZdZd�Zd�Zd�Zd�Zejd�d��Z	d�Z
d�Zd	�Zd
�Z
d�Zd�ZRS(
s(Test side-effects from importing 'site'.cCstj|_dS(sMake a copy of sys.pathN(RRR	(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyR@scCs|jtj(dS(sRestore sys.pathN(R	RR(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyRDscCshtj�xWtttfD]F}y)|jtjj|j�t	|��Wqt
k
r_qqXqWdS(N(Rtabs__file__RRt__builtin__RhRtisabst__file__treprtAttributeError(Rtmodule((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_abs__file__Hs
)
cCsHtj�t�}x.tjD]#}|j||�|j|�qWdS(N(RtremoveduppathsR9RRtassertNotIntadd(Rt
seen_pathsR((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_no_duplicate_pathsVs

	stest not implementedcCsdS(N((R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_add_build_dir_scCs0|jttd��|jttd��dS(Ntquittexit(RhthasattrR�(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_setting_quitfscCs0|jttd��|jttd��dS(Nt	copyrighttcredits(RhR�R�(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_setting_copyrightkscCs|jttd��dS(Nthelp(RhR�R�(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_setting_helppscCsxtjdkrtddl}|j�djd�rtx:tjjj�D]}|dkrGPqGqGW|jd�qtndS(NRTi����itcptmbcssdid not alias mbcs(	RRxtlocaletgetdefaultlocaleRit	encodingstaliasest
itervaluestfail(RR�tvalue((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_aliasing_mbcstscCs|jttd��dS(Ntsetdefaultencoding(RhR�R(R((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_setdefaultencoding_removed~scCsGdtjkrCyddl}Wntk
r2qCX|jd�ndS(Nt
sitecustomizei����s(sitecustomize not imported automatically(RR*R�RRR�(RR�((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyttest_sitecustomize_executed�s
(R�R�R�RRR�R�R�tskipR�R�R�R�R�R�R�(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyR�=s									
	cCsttt�dS(N(RRR�(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt	test_main�st__main__(!R�R�ttest.test_supportRRRRR�RRRNR�R_RRR*RtSkipTestR�RR$RtmakedirsRXtOSErrortexctTestCaseRtobjectR2R�R�R�(((sg/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_site.pyt<module>s6	�7O