U
    aÊ¹j£  ã                   @   s:   d dl Z d dlZd dlmZ ddlmZ G dd„ dƒZdS )é    N)Úpaths_on_pythonpathé   )Ú
namespacesc                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚTestNamespacesc           	   	   C   sº   t  |d¡}t  |d¡}|d }|d }||f}tjdddt|ƒdt|ƒg}t |¡ t  |¡ tjdddt|ƒdt|ƒg}t |¡ tjd	d
g}tt	t|ƒƒ� t |¡ W 5 Q R X dS )zø
        Installing two packages sharing the same namespace, one installed
        to a site dir and the other installed just to a path on PYTHONPATH
        should leave the namespace in tact and both packages reachable by
        import.
        ú	myns.pkgAú	myns.pkgBzsite-packageszpath-packagesú-múpip.__main__Úinstallú-tú-cz"import myns.pkgA; import myns.pkgBN)
r   Úbuild_namespace_packageÚsysÚ
executableÚstrÚ
subprocessÚ
check_callÚmake_site_dirr   Úmap)	ÚselfÚtmpdirÚpkg_AÚpkg_BÚsite_packagesZpath_packagesÚtargetsÚinstall_cmdÚ
try_import© r   ú_/var/www/html/bwave/python/venv/lib/python3.8/site-packages/setuptools/tests/test_namespaces.pyÚtest_mixed_site_and_non_site
   s<    ù	

ù	
ýz+TestNamespaces.test_mixed_site_and_non_sitec              	   C   sš   t  |d¡}|d }| ¡  tjddddt|ƒt|ƒg}tt|ƒgƒ� t |¡ W 5 Q R X t  	|¡ tjddg}tt|ƒgƒ� t |¡ W 5 Q R X d	S )
zc
        Ensure that a namespace package doesn't break on import
        of pkg_resources.
        r   Úpackagesr   Úpipr
   r   r   zimport pkg_resourcesN)
r   r   Úmkdirr   r   r   r   r   r   r   )r   r   ÚpkgÚtargetr   r   r   r   r   Útest_pkg_resources_import4   s(    ù	
ýz(TestNamespaces.test_pkg_resources_importc              	   C   s€   t  |d¡}|d }tjdddt|ƒdt|ƒg}t |¡ t  |¡ tjddg}tt|ƒgƒ� tj|t|ƒd	� W 5 Q R X d
S )z—
        Installing a namespace packages but also having it in the current
        working directory, only one version should take precedence.
        r   r    r   r	   r
   r   r   z&import pkg_resources; import myns.pkgA©ÚcwdN©	r   r   r   r   r   r   r   r   r   )r   r   r   r$   r   Úpkg_resources_impr   r   r   Ú(test_namespace_package_installed_and_cwdP   s$    ù	

ýz7TestNamespaces.test_namespace_package_installed_and_cwdc              	   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j|t|ƒd
� W 5 Q R X dS )z±
        Installing one namespace package and also have another in the same
        namespace in the current working directory, both of them must be
        importable.
        r   r   r    r   r	   r
   r   r   z8import pkg_resources; import myns.pkgA; import myns.pkgBr&   Nr(   )r   r   r   r   r$   r   r)   r   r   r   Ú5test_packages_in_the_same_namespace_installed_and_cwdm   s&    ù	

ýzDTestNamespaces.test_packages_in_the_same_namespace_installed_and_cwdN)Ú__name__Ú
__module__Ú__qualname__r   r%   r*   r+   r   r   r   r   r   	   s   *r   )r   r   Zsetuptools._pathr   Ú r   r   r   r   r   r   Ú<module>   s   