o
    5‘ðii  ã                   @   sJ   d Z ddlZddlZddlmZ ddlmZ ddlmZ G dd„ dƒZ	dS )	zinstall_scripts testsé    N)Úinstall_scripts)ÚDistributioné   )Úcontextsc                   @   s®   e Zd Zedddgidd�ZdZdZdZdd
d„Ze	j
jejdkdd�dd„ ƒZe	j
jejdkdd�dd„ ƒZe	j
jejdkdd�dd„ ƒZe	j
jejdkdd�dd„ ƒZd	S )ÚTestInstallScriptsÚfooÚconsole_scriptszfoo=foo:fooz0.0)ÚnameÚentry_pointsÚversionz%/usr/dummy-test-path/local/bin/pythonz/usr/bin/env dummy-test-pythonz6C:\Dummy Test Path\Program Files\Python 3.6\python.exeNc                 C   st   t | jƒ}d|_t|ƒ}||_|d ur| d¡}||_| ¡  t 	¡ � | 
¡  W d   ƒ d S 1 s3w   Y  d S )Nzsetup.pyÚbuild_scripts)r   ÚsettingsÚscript_namer   Úinstall_dirÚget_finalized_commandÚ
executableÚensure_finalizedr   ÚquietÚrun)Úselfr   r   ÚdistÚcmdÚbs© r   úd/root/parts/websockify/install/lib/python3.10/site-packages/setuptools/tests/test_install_scripts.pyÚ_run_install_scripts   s   



"ÿz'TestInstallScripts._run_install_scriptsÚwin32znon-Windows only)Úreasonc              	   C   ó¢   d| j › d�}| d| j ¡ | ¡ �/ |  t|ƒ¡ tt| d¡ƒddd��}| ¡ }W d  ƒ n1 s5w   Y  W d  ƒ n1 sDw   Y  ||ksOJ ‚dS )	zt
        Ensure that shebang is not quoted on Unix when getting the Python exe
        from sys.executable.
        ú#!Ú
úsys.executabler   Úrúutf-8©ÚencodingN)Úunix_exeÚsetattrÚas_cwdr   ÚstrÚopenÚjoinÚreadline©r   ÚtmpdirÚmonkeypatchÚexpectedÚfÚactualr   r   r   Ú!test_sys_executable_escaping_unix#   ó   

ÿ€þz4TestInstallScripts.test_sys_executable_escaping_unixzWindows onlyc              	   C   r   )	z‹
        Ensure that shebang is quoted on Windows when getting the Python exe
        from sys.executable and it contains a space.
        ú#!"ú"
r!   úfoo-script.pyr"   r#   r$   N)Ú	win32_exer'   r(   r   r)   r*   r+   r,   r-   r   r   r   Ú"test_sys_executable_escaping_win321   r4   z5TestInstallScripts.test_sys_executable_escaping_win32c              	   C   s˜   d| j › d�}| ¡ �1 |  t|ƒ| j ¡ tt| d¡ƒddd��}| ¡ }W d  ƒ n1 s0w   Y  W d  ƒ n1 s?w   Y  ||ksJJ ‚dS )z‹
        Ensure that shebang on Unix is not quoted, even when
        a value with spaces
        is specified using --executable.
        r   r    r   r"   r#   r$   N)Úunix_spaces_exer(   r   r)   r*   r+   r,   ©r   r.   r0   r1   r2   r   r   r   Ú)test_executable_with_spaces_escaping_unix?   s   

ÿ€þz<TestInstallScripts.test_executable_with_spaces_escaping_unixc              	   C   s    d| j › d�}| ¡ �5 |  t|ƒd| j  d ¡ tt| d¡ƒddd��}| ¡ }W d  ƒ n1 s4w   Y  W d  ƒ n1 sCw   Y  ||ksNJ ‚dS )	z�
        Ensure that shebang on Windows is quoted when
        getting a path with spaces
        from --executable, that is itself properly quoted.
        r5   r6   ú"r7   r"   r#   r$   N)r8   r(   r   r)   r*   r+   r,   r;   r   r   r   Ú"test_executable_arg_escaping_win32M   s   

ÿ€þz5TestInstallScripts.test_executable_arg_escaping_win32)N)Ú__name__Ú
__module__Ú__qualname__Údictr   r&   r:   r8   r   ÚpytestÚmarkÚskipifÚsysÚplatformr3   r9   r<   r>   r   r   r   r   r      s$    ý



r   )
Ú__doc__rF   rC   Ú"setuptools.command.install_scriptsr   Úsetuptools.distr   Ú r   r   r   r   r   r   Ú<module>   s    