Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_ensurepip.cpython-35.opt-1.pyc



��Yf�-�
@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Zej
jdddg�Zyddl
Z
Wnek
r�dd�ZYn
Xdd�ZGdd	�d	ej�ZGd
d�d�ZGdd
�d
eej�Zejejdd��ZGdd�deej�ZGdd�deej�ZdejZGdd�deej�ZGdd�deej�Zedkr�ej�dS)�N�	ensurepipZblocked�sslcCstjtj�}||�S)N)�unittest�skiprZ_MISSING_SSL_MESSAGE)�fZdeco�r�8/opt/alt/python35/lib64/python3.5/test/test_ensurepip.py�requires_usable_pipsr	cCs|S)Nr)rrrrr	sc@seZdZdd�ZdS)�TestEnsurePipVersioncCs|jtjtj��dS)N)�assertEqualr�_PIP_VERSION�version)�selfrrr�test_returns_versionsz)TestEnsurePipVersion.test_returns_versionN)�__name__�
__module__�__qualname__rrrrrr
sr
c@seZdZdd�ZdS)�EnsurepipMixincCs�tjjd�}|j�|_|j|j�tj}tjjd�}|j�}|j|j�||_tj	|_	tj
j�|_|_
dS)Nzensurepip._run_pipzensurepip.os)
r�mockZpatch�start�run_pip�
addCleanup�stop�os�devnull�path�environ�copy�
os_environ)rZ
run_pip_patchZreal_devnullZos_patchZ
patched_osrrr�setUp!s		zEnsurepipMixin.setUpN)rrrrrrrrrsrc@s�eZdZedd��Zedd��Zedd��Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��Zedd��Zedd��Z
dd�Zedd��Zedd��ZdS)�
TestBootstrapcCsitj�|jjdddtjjddgtjj�|jjdd}|jt	|�d�dS)	N�installz
--no-indexz--find-links�
setuptools�pipr��)
r�	bootstrapr�assert_called_once_withrr�ANY�	call_argsr�len)r�additional_pathsrrr�test_basic_bootstrapping2s
		
z&TestBootstrap.test_basic_bootstrappingc	CsKtjdd�|jjdddtjjddddgtjj�dS)	N�rootz	/foo/bar/r!z
--no-indexz--find-linksz--rootr"r#)rr&rr'rrr()rrrr�test_bootstrapping_with_rootAs			z*TestBootstrap.test_bootstrapping_with_rootcCsHtjdd�|jjdddtjjdddgtjj�dS)	N�userTr!z
--no-indexz--find-linksz--userr"r#)rr&rr'rrr()rrrr�test_bootstrapping_with_userNs
		z*TestBootstrap.test_bootstrapping_with_usercCsHtjdd�|jjdddtjjdddgtjj�dS)	NZupgradeTr!z
--no-indexz--find-linksz	--upgrader"r#)rr&rr'rrr()rrrr�test_bootstrapping_with_upgradeZs
		z-TestBootstrap.test_bootstrapping_with_upgradecCsHtjdd�|jjdddtjjdddgtjj�dS)	N�	verbosityr$r!z
--no-indexz--find-linksz-vr"r#)rr&rr'rrr()rrrr�#test_bootstrapping_with_verbosity_1fs
		z1TestBootstrap.test_bootstrapping_with_verbosity_1cCsHtjdd�|jjdddtjjdddgtjj�dS)	Nr2r%r!z
--no-indexz--find-linksz-vvr"r#)rr&rr'rrr()rrrr�#test_bootstrapping_with_verbosity_2rs
		z1TestBootstrap.test_bootstrapping_with_verbosity_2cCsHtjdd�|jjdddtjjdddgtjj�dS)	Nr2�r!z
--no-indexz--find-linksz-vvvr"r#)rr&rr'rrr()rrrr�#test_bootstrapping_with_verbosity_3~s
		z1TestBootstrap.test_bootstrapping_with_verbosity_3cCs%tj�|j|jdd�dS)N�ENSUREPIP_OPTIONSr!)rr&rr)rrrr�'test_bootstrapping_with_regular_install�s
z5TestBootstrap.test_bootstrapping_with_regular_installcCs+tjdd�|j|jdd�dS)N�
altinstallTr7)rr&rr)rrrr�#test_bootstrapping_with_alt_install�sz1TestBootstrap.test_bootstrapping_with_alt_installcCs'tjdd�|jd|j�dS)N�default_pipTr7)rr&�assertNotInr)rrrr�#test_bootstrapping_with_default_pip�sz1TestBootstrap.test_bootstrapping_with_default_pipcCsD|jt��tjdddd�WdQRX|j|jj�dS)Nr9Tr;)�assertRaises�
ValueErrorrr&�assertFalser�called)rrrr�$test_altinstall_default_pip_conflict�sz2TestBootstrap.test_altinstall_default_pip_conflictcCs.d|jd<tj�|jd|j�dS)Nztest fodder�PIP_THIS_SHOULD_GO_AWAY)rrr&r<)rrrr�&test_pip_environment_variables_removed�s

z4TestBootstrap.test_pip_environment_variables_removedcCs(tj�|j|jdtj�dS)N�PIP_CONFIG_FILE)rr&rrrr)rrrr�test_pip_config_file_disabled�s
z+TestBootstrap.test_pip_config_file_disabledN)rrrr	r,r.r0r1r3r4r6r8r:r=rBrDrFrrrrr 0s
r c#s��dkrd}n"G�fdd�d�}|�}t�}tjjd|�}|tjd<z	|VWd||kr�tjd=n
|tjd<XdS)NcseZdZ�ZdS)zfake_pip.<locals>.FakePipN)rrr�__version__r)r
rr�FakePip�srHr#)�object�sys�modules�get)r
r#rH�sentinelZorig_pipr)r
r�fake_pip�s			
	
rNc@s�eZdZdd�Zdd�Zedd��Zedd��Zed	d
��Zedd��Z	ed
d��Z
edd��ZdS)�
TestUninstallc	Cs5td��tj�WdQRX|j|jj�dS)N)rNr�_uninstall_helperr@rrA)rrrr�)test_uninstall_skipped_when_not_installed�s
z7TestUninstall.test_uninstall_skipped_when_not_installedcCsptd��(tjj��}tj�WdQRXWdQRX|j�j�}|jd|�|j	|j
j�dS)Nznot a valid versionz!only uninstall a matching version)rN�test�support�captured_stderrrrP�getvalue�strip�assertInr@rrA)r�stderr�warningrrr�5test_uninstall_skipped_with_warning_for_wrong_version�s
zCTestUninstall.test_uninstall_skipped_with_warning_for_wrong_versionc
Cs>t��tj�WdQRX|jjdddddg�dS)N�	uninstallz-yz--disable-pip-version-checkr#r")rNrrPrr')rrrr�test_uninstall�s

	zTestUninstall.test_uninstallcCsGt��tjdd�WdQRX|jjddddddg�dS)	Nr2r$r[z-yz--disable-pip-version-checkz-vr#r")rNrrPrr')rrrr�test_uninstall_with_verbosity_1�s

	z-TestUninstall.test_uninstall_with_verbosity_1cCsGt��tjdd�WdQRX|jjddddddg�dS)	Nr2r%r[z-yz--disable-pip-version-checkz-vvr#r")rNrrPrr')rrrr�test_uninstall_with_verbosity_2�s

	z-TestUninstall.test_uninstall_with_verbosity_2cCsGt��tjdd�WdQRX|jjddddddg�dS)	Nr2r5r[z-yz--disable-pip-version-checkz-vvvr#r")rNrrPrr')rrrr�test_uninstall_with_verbosity_3�s

	z-TestUninstall.test_uninstall_with_verbosity_3c
Cs?d|jd<t��tj�WdQRX|jd|j�dS)Nztest fodderrC)rrNrrPr<)rrrrrDs

z4TestUninstall.test_pip_environment_variables_removedc
Cs9t��tj�WdQRX|j|jdtj�dS)NrE)rNrrPrrrr)rrrrrF	s
z+TestUninstall.test_pip_config_file_disabledN)rrrrQrZr	r\r]r^r_rDrFrrrrrO�s		rOcsFeZdZ�fdd�Zdd�Zdd�Zdd�Z�S)	�TestMissingSSLcs3ttjd<|jdd��}t�j�dS)NrcSsttjd<dS)Nr)rrJrKrrrr�restore_modulesz,TestMissingSSL.setUp.<locals>.restore_module)�ensurepip_no_sslrJrKr�superr)rra)�	__class__rrrs
zTestMissingSSL.setUpc
Cs[d|jd<|jtd��tj�WdQRX|j|jj�|jd|j�dS)Nztest fodder�PIP_THIS_SHOULD_STAYzrequires SSL/TLS)	r�assertRaisesRegex�RuntimeErrorrbr&r@rrArW)rrrr�test_bootstrap_requires_ssls

z*TestMissingSSL.test_bootstrap_requires_sslcCsld|jd<|jtd�� t��tj�WdQRXWdQRX|j|jj�|j	d|j�dS)Nztest fodderrezrequires SSL/TLS)
rrfrgrNrbrPr@rrArW)rrrr�test_uninstall_requires_ssl"s

z*TestMissingSSL.test_uninstall_requires_sslc
Csktjj��}tjdg�WdQRX|j�j�}|j|jd�|�|j	|j
j�dS)Nz	--versionzrequires SSL/TLS)rRrSrTrb�_mainrUrVZ
assertTrue�endswithr@rrA)rrXrYrrr�"test_main_exits_early_with_warning*s
z1TestMissingSSL.test_main_exits_early_with_warning)rrrrrhrirlrr)rdrr`sr`zpip c@s4eZdZedd��Zedd��ZdS)�TestBootstrappingMainFunctioncCsytjj��.}|jt��tjdg�WdQRXWdQRX|j�j�}|j	|t
�|j|jj
�dS)Nz	--version)rRrS�captured_stdoutr>�
SystemExitrrjrUrVr�EXPECTED_VERSION_OUTPUTr@rrA)r�stdout�resultrrr�test_bootstrap_version7sz4TestBootstrappingMainFunction.test_bootstrap_versioncCsltjg�|jjdddtjjddgtjj�|jjdd}|jt	|�d�dS)	Nr!z
--no-indexz--find-linksr"r#rr$r%)
rrjrr'rrr(r)rr*)rr+rrrr,@s
		
z6TestBootstrappingMainFunction.test_basic_bootstrappingN)rrrr	rsr,rrrrrm5s	rmc@s.eZdZdd�Zedd��ZdS)�TestUninstallationMainFunctioncCs|tjj��1}|jt��tjjdg�WdQRXWdQRX|j�j	�}|j
|t�|j|j
j�dS)Nz	--version)rRrSrnr>ror�
_uninstallrjrUrVrrpr@rrA)rrqrrrrr�test_uninstall_versionQs!z5TestUninstallationMainFunction.test_uninstall_versionc
CsDt��tjjg�WdQRX|jjdddddg�dS)Nr[z-yz--disable-pip-version-checkr#r")rNrrurjrr')rrrr�test_basic_uninstallYs

	z3TestUninstallationMainFunction.test_basic_uninstallN)rrrrvr	rwrrrrrtOsrt�__main__)rZ
unittest.mockZtest.supportrRrZos.path�
contextlibrJrZensurepip._uninstallrSZimport_fresh_modulerbr�ImportErrorr	ZTestCaser
rr �contextmanagerrrNrOr`rprmrtr�mainrrrr�<module>s6
}R!