o
    !g                     @   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)monkeypatch	user_base	user_site r   \/root/parts/websockify/install/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_finalized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-linkFoo_Bar_baz_bing)	r,   r   r   r.   pathlibPathegg_linksuffixstem)r1   r2   r3   r4   linkr   r   r   test_egg_link_filenameU   s   z"TestDevelop.test_egg_link_filenameN)__name__
__module____qualname__hasattrsysin_virtualenvr$   prefixin_venvr5   r*   mark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   _resolve_setup_pathr1   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pkgsrK   ../rL   rN   r   r   r   test_resolve_setup_path_one_dirl   rP   z,TestResolver.test_resolve_setup_path_one_dirc                 C   s   t ddddksJ d S )Nzpkgs/rK   rQ   rR   rL   rN   r   r   r   .test_resolve_setup_path_one_dir_trailing_slasho   rP   z;TestResolver.test_resolve_setup_path_one_dir_trailing_slashN)r@   rA   rB   __doc__rO   rS   rT   r   r   r   r   rJ   b   s
    rJ   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)rD   
executablestrr   r   
subprocess
check_call)src_dirr   develop_cmdr   r   r   install_developt   s   
"zTestNamespaces.install_developAPPVEYORz-https://github.com/pypa/setuptools/issues/851r6   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   build_namespace_packagerD   rW   rX   rY   rZ   r]   make_site_dirr   )r1   r   pkg_Apkg_Br   install_cmd
try_importpkg_resources_impr   r   r   !test_namespace_package_importable   s8   
	
"z0TestNamespaces.test_namespace_package_importableN)r@   rA   rB   staticmethodr]   r*   rH   skipifboolosenvirongetplatformpython_implementationri   r   r   r   r   rV   s   s    

rV   )rU   rm   r9   rp   rY   rD   r*   setuptools._pathr   setuptools.command.developr   setuptools.distr    r   r   r   r   fixturer   r!   r"   rJ   rV   r   r   r   r   <module>   s(    

,