U
    aÊ¹j  ã                   @   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ZddlmZ ddl	m
Z
 ddlmZ ddlmZmZ dZd	Zejd
d„ ƒZejdd„ ƒZG dd„ dƒZG dd„ dƒZG dd„ dƒZdS )zdevelop testsé    N)Úpaths_on_pythonpath)Údevelop)ÚDistributioné   )ÚcontextsÚ
namespaceszHfrom setuptools import setup

setup(name='foo',
    packages=['foo'],
)
zprint "foo"
c              
   c   sJ   t  ¡ �8}t  ¡ �$}|  d|¡ |  d|¡ d V  W 5 Q R X W 5 Q R X d S )Nzsite.USER_BASEzsite.USER_SITE)r   ÚtempdirÚsetattr)ZmonkeypatchÚ	user_baseÚ	user_site© r   ú\/var/www/html/bwave/python/venv/lib/python3.8/site-packages/setuptools/tests/test_develop.pyÚ	temp_user   s
    

r   c              	   c   s�   | }|  d¡}|d }| ¡ r*tt|ƒƒ‚| d¡�}| t¡ W 5 Q R X |d }| d¡�}| t¡ W 5 Q R X | ¡ � |V  W 5 Q R X d S )NÚfooúsetup.pyÚwz__init__.py)	ÚmkdirÚisfileÚ
ValueErrorÚdirÚopenÚwriteÚSETUP_PYÚINIT_PYÚas_cwd)Útmpdirr   Útargetr   ÚsetupÚfÚinitr   r   r   Útest_env&   s    

r    c                   @   sJ   e Zd ZeedƒZeedƒo&ejejkZdd„ Z	e
jjdd�dd„ ƒZd	S )
ÚTestDevelopÚreal_prefixÚbase_prefixc                 C   sR   t  d¡ tddgdddgid�}t|ƒ}d|_t|ƒ}| ¡  ||_| ¡  dS )	z�
        Test that console scripts are installed and that they reference
        only the project by name and not the current version.
        zTTODO: needs a fixture to cause 'develop' to be invoked without mutating environment.r   z0.0Úconsole_scriptszfoocmd = foo:foo)ÚnameÚpackagesÚversionÚentry_pointsr   N)	ÚpytestÚskipÚdictr   Úscript_namer   Úensure_finalizedZinstall_dirÚrun)Úselfr   ÚsettingsÚdistÚcmdr   r   r   Útest_console_scripts:   s$    ÿÿÿü
z TestDevelop.test_console_scriptsz0legacy behavior retained for compatibility #4167©Úreasonc                 C   sN   t dd�}t|ƒ}t|ƒ}| ¡  t |j¡}|jdks<t‚|j	dksJt‚d S )NzFoo $$$ Bar_baz-bing)r%   z	.egg-linkZFoo_Bar_baz_bing)
r+   r   r   r-   ÚpathlibÚPathÚegg_linkÚsuffixÚAssertionErrorÚstem)r/   r0   r1   r2   Úlinkr   r   r   Útest_egg_link_filenameU   s    ÿz"TestDevelop.test_egg_link_filenameN)Ú__name__Ú
__module__Ú__qualname__ÚhasattrÚsysZin_virtualenvr#   ÚprefixÚin_venvr3   r)   ÚmarkZxfailr=   r   r   r   r   r!   6   s
   
r!   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚTestResolverzÅ
    TODO: These tests were written with a minimal understanding
    of what _resolve_setup_path is intending to do. Come up with
    more meaningful cases that look like real-world scenarios.
    c                 C   s   t  ddd¡dkst‚d S )NÚ.©r   Z_resolve_setup_pathr:   ©r/   r   r   r   Útest_resolve_setup_path_cwdi   s    z(TestResolver.test_resolve_setup_path_cwdc                 C   s   t  ddd¡dkst‚d S )NÚpkgsrG   ú../rH   rI   r   r   r   Útest_resolve_setup_path_one_dirl   s    z,TestResolver.test_resolve_setup_path_one_dirc                 C   s   t  ddd¡dkst‚d S )Nzpkgs/rG   rK   rL   rH   rI   r   r   r   Ú.test_resolve_setup_path_one_dir_trailing_slasho   s    z;TestResolver.test_resolve_setup_path_one_dir_trailing_slashN)r>   r?   r@   Ú__doc__rJ   rM   rN   r   r   r   r   rF   b   s   rF   c                   @   sT   e Zd Zedd„ ƒZejjee	j
 d¡ƒdd�ejje ¡ dkdd�dd	„ ƒƒZd
S )ÚTestNamespacesc              
   C   sP   t jdddt|ƒg}|  ¡ �* tt|ƒgƒ� t |¡ W 5 Q R X W 5 Q R X d S )Nr   r   z--install-dir)rB   Ú
executableÚstrr   r   Ú
subprocessÚ
check_call)Úsrc_dirr   Zdevelop_cmdr   r   r   Úinstall_developt   s    û
zTestNamespaces.install_developZAPPVEYORz-https://github.com/pypa/setuptools/issues/851r4   ÚPyPyz.https://github.com/pypa/setuptools/issues/1202c              	   C   sÀ   t  |d¡}t  |d¡}|d }tjdddt|ƒdt|ƒg}t |¡ |  ||¡ t  |¡ tjdd	g}t	t|ƒgƒ� t |¡ W 5 Q R X tjdd
g}t	t|ƒgƒ� t |¡ W 5 Q R X dS )a  
        Installing two packages sharing the same namespace, one installed
        naturally using pip or `--single-version-externally-managed`
        and the other installed using `develop` should leave the namespace
        in tact and both packages reachable by import.
        z	myns.pkgAz	myns.pkgBr&   z-mÚpipÚinstallz-tz-cz"import myns.pkgA; import myns.pkgBzimport pkg_resourcesN)
r   Zbuild_namespace_packagerB   rQ   rR   rS   rT   rV   Zmake_site_dirr   )r/   r   Zpkg_AZpkg_Br   Zinstall_cmdZ
try_importZpkg_resources_impr   r   r   Ú!test_namespace_package_importable�   s4    ù	

ýýz0TestNamespaces.test_namespace_package_importableN)r>   r?   r@   ÚstaticmethodrV   r)   rE   ZskipifÚboolÚosÚenvironÚgetÚplatformÚpython_implementationrZ   r   r   r   r   rP   s   s   
þ
þrP   )rO   r]   r6   r`   rS   rB   r)   Zsetuptools._pathr   Zsetuptools.command.developr   Zsetuptools.distr   Ú r   r   r   r   Zfixturer   r    r!   rF   rP   r   r   r   r   Ú<module>   s&   

,