U
    ±§f+  ã                   @   sÆ   d Z ddlZddlZddlZddlZddlZddlmZ ddl	mZ
 ddlmZ ejjdddZdd	„ Zejd
d„ ƒZdd„ Zdd„ Zejjdd„ ƒZdd„ Zejjej d¡dd„ ƒƒZdd„ ZdS )z<Run some integration tests.

Try to install a few packages.
é    N)Úeasy_install)ÚDistributionzMplatform.python_implementation() == "PyPy" and platform.system() == "Windows"zpypa/setuptools#2496)Úreasonc              
   C   sŽ   d}|D ]>}z$t |ƒ d}t |jf tƒ Ž¡ W q tk
rD   Y qX qztj d¡ W n0 t	k
rˆ } zt t
|ƒ¡ W 5 d }~X Y nX d S )N)Ú	stevedoreÚvirtualenvwrapperÚpbrÚ
novaclientz4Integration tests cannot run when {pkg} is installedzhttps://pypi.python.org/pypi)Ú
__import__ÚpytestÚskipÚformatÚlocalsÚImportErrorÚurllibÚrequestZurlopenÚ	ExceptionÚstr)ÚmoduleZpackagesÚpkgZtmplÚexc© r   ú@lib/python3.8/site-packages/setuptools/tests/test_integration.pyÚsetup_module   s    r   c                    sÈ   |  d¡‰|  d¡‰|  d¡‰|  d¡‰ ‡ ‡‡‡‡fdd„}|  |¡ ˆ ˆ¡ ˆ tdˆj¡ ˆ dˆj¡ ˆ d	ˆj¡ ˆ d
tjˆ jg ¡ ˆ dt	t
jj tj¡ƒ¡ tƒ }t|ƒ}ˆ j|_|S )z3Fixture to set up temporary installation directory.ÚcwdÚ	user_baseÚ	user_siteÚinstall_dirc                      s,   ˆ  ¡  ˆ ¡  ˆ ¡  ˆ ¡  ˆ  ¡  d S )N)ZundoÚremover   ©r   ÚmonkeypatchZnew_cwdr   r   r   r   Úfin1   s
    zinstall_context.<locals>.finÚ__file__zsite.USER_BASEzsite.USER_SITEzsys.pathZ
PYTHONPATH)ÚmkdirZaddfinalizerÚchdirÚsetattrÚeasy_install_pkgZstrpathÚsysÚpathZsetenvr   ÚosÚpathsepÚjoinr   r   r   )r   Ztmpdirr   r    ZdistÚcmdr   r   r   Úinstall_context(   s     



	

r,   c                 C   sb   | g|_ | ¡  | ¡  |j}t tj ||d ¡¡}|s>t‚tj 	tj |d ||¡¡s^t‚d S )Nz*.eggr   )
ÚargsZensure_finalizedÚrunr   Úglobr(   r'   r*   ÚAssertionErrorÚexists)Zrequirementr+   ZpkgnameZ
modulenameÚtargetZ	dest_pathr   r   r   Ú_install_oneL   s    r3   c                 C   s   t d| ddƒ d S )Nr   zextension.py©r3   ©r,   r   r   r   Útest_stevedoreV   s    r6   c                 C   s   t d| ddƒ d S )Nr   zhook_loader.pyr4   r5   r   r   r   Útest_virtualenvwrapperZ   s       ÿr7   c                 C   s   t d| ddƒ d S )Nr   zcore.pyr4   r5   r   r   r   Útest_pbra   s    r8   z(ignore:'encoding' argument not specifiedc                 C   s   t d| ddƒ d S )Nzpython-novaclientr   zbase.pyr4   r5   r   r   r   Útest_python_novacliente   s    r9   c                 C   s:   t d| ddƒ | jd }tj tj |jdd¡¡s6t‚dS )z€
    Install the pyuri package (version 0.3.1 at the time of writing).

    This is also a regression test for issue #1016.
    Úpyurizuri.pyz	uri.regexN)r3   Zinstalled_projectsr(   r'   r1   r*   Úlocationr0   )r,   r:   r   r   r   Ú
test_pyurio   s    
r<   )Ú__doc__r/   r(   r&   Zurllib.requestr   r
   Zsetuptools.command.easy_installr   Zsetuptools.commandr%   Zsetuptools.distr   ZmarkZskipifZ
pytestmarkr   Zfixturer,   r3   r6   Zxfailr7   r8   Úfilterwarningsr9   r<   r   r   r   r   Ú<module>   s0   þ
#


