U
    uiq                     @   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   s^   t | j}d|_t|}||_|d k	r6|d}||_|  t	  |
  W 5 Q R X 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   I/tmp/pip-unpacked-wheel-9osl9suo/setuptools/tests/test_install_scripts.py_run_install_scripts   s    


z'TestInstallScripts._run_install_scriptswin32znon-Windows only)reasonc              
   C   sv   d| j  }|d| j  | @ | t| tt|dddd}| }W 5 Q R X W 5 Q R X ||ksrtdS )zt
        Ensure that shebang is not quoted on Unix when getting the Python exe
        from sys.executable.
        #!%s
sys.executabler   rutf-8encodingN)	unix_exesetattras_cwdr   stropenjoinreadlineAssertionErrorr   tmpdirZmonkeypatchexpectedfactualr   r   r   !test_sys_executable_escaping_unix#   s    

z4TestInstallScripts.test_sys_executable_escaping_unixzWindows onlyc              
   C   sv   d| j  }|d| j  | @ | t| tt|dddd}| }W 5 Q R X W 5 Q R X ||ksrtdS )z
        Ensure that shebang is quoted on Windows when getting the Python exe
        from sys.executable and it contains a space.
        #!"%s"
r   foo-script.pyr    r!   r"   N)		win32_exer%   r&   r   r'   r(   r)   r*   r+   r,   r   r   r   "test_sys_executable_escaping_win321   s    

z5TestInstallScripts.test_sys_executable_escaping_win32c              
   C   sl   d| j  }| D | t|| j  tt|dddd}| }W 5 Q R X W 5 Q R X ||ksht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"   N)unix_spaces_exer&   r   r'   r(   r)   r*   r+   r   r-   r.   r/   r0   r   r   r   )test_executable_with_spaces_escaping_unix?   s    

z<TestInstallScripts.test_executable_with_spaces_escaping_unixc              
   C   st   d| j  }| L | t|d| j  d  tt|dddd}| }W 5 Q R X W 5 Q R X ||ksptdS )z
        Ensure that shebang on Windows is quoted when
        getting a path with spaces
        from --executable, that is itself properly quoted.
        r2   "r3   r    r!   r"   N)r4   r&   r   r'   r(   r)   r*   r+   r7   r   r   r   "test_executable_arg_escaping_win32M   s    

z5TestInstallScripts.test_executable_arg_escaping_win32)N)__name__
__module____qualname__dictr   r$   r6   r4   r   pytestmarkZskipifsysplatformr1   r5   r8   r:   r   r   r   r   r      s"   



r   )
__doc__rA   r?   Z"setuptools.command.install_scriptsr   Zsetuptools.distr    r   r   r   r   r   r   <module>   s   