o
    Zh                     @   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   s    t  4}t  }| d| | d| d V  W d    n1 s$w   Y  W d    d S W d    d S 1 s<w   Y  d S )Nzsite.USER_BASEzsite.USER_SITE)r   tempdirsetattr)Zmonkeypatch	user_base	user_site r   T/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/tests/test_develop.py	temp_user   s   

"r   c                 c   s    | }| d}|d }| rtt||d}|t W d    n1 s+w   Y  |d }|d}|t W d    n1 sIw   Y  |  |V  W d    d S 1 saw   Y  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J |jdks%J d S )NzFoo $$$ Bar_baz-bing)r%   z	.egg-linkZFoo_Bar_baz_bing)	r+   r   r   r-   pathlibPathegg_linksuffix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J d S )N.r   Z_resolve_setup_pathr/   r   r   r   test_resolve_setup_path_cwdi      z(TestResolver.test_resolve_setup_path_cwdc                 C   s   t ddddksJ d S )NpkgsrF   ../rG   rH   r   r   r   test_resolve_setup_path_one_dirl   rJ   z,TestResolver.test_resolve_setup_path_one_dirc                 C   s   t ddddksJ d S )Nzpkgs/rF   rK   rL   rG   rH   r   r   r   .test_resolve_setup_path_one_dir_trailing_slasho   rJ   z;TestResolver.test_resolve_setup_path_one_dir_trailing_slashN)r=   r>   r?   __doc__rI   rM   rN   r   r   r   r   rE   b   s
    rE   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   s   t jdddt|g}|  - tt|g t| W d    n1 s&w   Y  W d    d S W d    d S 1 s>w   Y  d S )Nr   r   z--install-dir)rA   
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 d
   n1 sKw   Y  tjddg}t	t|g t| W d
   d
S 1 snw   Y  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.pkgBNzimport pkg_resources)
r   Zbuild_namespace_packagerA   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   s8   
	
"z0TestNamespaces.test_namespace_package_importableN)r=   r>   r?   staticmethodrV   r)   rD   Zskipifboolosenvirongetplatformpython_implementationrZ   r   r   r   r   rP   s   s    

rP   )rO   r]   r6   r`   rS   rA   r)   Zsetuptools._pathr   Zsetuptools.command.developr   Zsetuptools.distr    r   r   r   r   Zfixturer   r    r!   rE   rP   r   r   r   r   <module>   s(    

,