U
    ui                     @   st   d 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	 ddl
Z
G dd deZe
jd	d
 ZG dd dZdS )zTests for distutils.cmd.    N)debug)Command)Distribution)DistutilsOptionErrorc                   @   s   e Zd Zdd ZdS )MyCmdc                 C   s   d S N )selfr   r   H/tmp/pip-unpacked-wheel-9osl9suo/setuptools/_distutils/tests/test_cmd.pyinitialize_options   s    zMyCmd.initialize_optionsN)__name__
__module____qualname__r   r   r   r   r
   r      s   r   c                 C   s
   t t S r   )r   r   )requestr   r   r
   cmd   s    r   c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )TestCommandc              	   C   s   dddg|_ dddg|_t |_d|_|d |d tt |d W 5 Q R X tt |d	 W 5 Q R X d
|_	|d |j	ddgkst
ddg|_|d ddg|_tt |d W 5 Q R X d S )NZone   ZthreeZtwookyes_string_listyes_string_list2not_string_listnot_string_list2zok,dokoption1ZdokxxxZwwwoption2option3)r   r   objectr   r   ensure_string_listpytestraisesr   r   AssertionErrorr   r   r	   r   r   r   r
   test_ensure_string_list   s$    





z#TestCommand.test_ensure_string_listc              	   C   sR   t t |jddddd W 5 Q R X dd }d|_||_|jdd	ddd d S )
NT funcr   )infilesoutfiler$   argsc                 S   s   |dkst d S )Nzgenerating out from in)r    )r$   r'   exec_msglevelr   r   r
   _execute6   s    z,TestCommand.test_make_file.<locals>._executeinout)r   r   	TypeError	make_fileforceexecute)r	   r   r*   r   r   r
   test_make_file0   s    zTestCommand.test_make_filec                    sN   g   fdd}||_ d|_d|_ddg|_|  dddg} |ksJtd S )	Nc                    s     |  d S r   )append)msgr)   Zmsgsr   r
   	_announce@   s    z0TestCommand.test_dump_options.<locals>._announce   )r   r#   r#   )r   r#   r#   zcommand options for 'MyCmd':z  option1 = 1z  option2 = 1)announcer   r   user_optionsdump_optionsr    )r	   r   r5   wantedr   r4   r
   test_dump_options=   s    

zTestCommand.test_dump_optionsc              	   C   sZ   d|_ |d d |_|dd t|ds0td|_tt |d W 5 Q R X d S )Nr   r   r   r   r6   r   )	r   ensure_stringr   hasattrr    r   r   r   r   r!   r   r   r
   test_ensure_stringL   s    
zTestCommand.test_ensure_stringc              	   C   s:   t |_|d d|_tt |d W 5 Q R X d S Nr   r   r   )__file__r   ensure_filenamer   r   r   r   r!   r   r   r
   test_ensure_filenameX   s
    
z TestCommand.test_ensure_filenamec              	   C   sH   t jtpt j|_|d d|_t	t
 |d W 5 Q R X d S r?   )ospathdirnamer@   curdirr   ensure_dirnamer   r   r   r   r!   r   r   r
   test_ensure_dirname_   s
    
zTestCommand.test_ensure_dirnamec                 C   sJ   | d | jdkst|tdd | d | jdksFtd S )Nr   r#   DEBUGTzxxx
)debug_printZ
readouterrr,   r    setattrr   )r	   r   ZcapsysZmonkeypatchr   r   r
   test_debug_printf   s
    

zTestCommand.test_debug_printN)
r   r   r   r"   r1   r;   r>   rB   rH   rL   r   r   r   r
   r      s   r   )__doc__rC   	distutilsr   distutils.cmdr   distutils.distr   distutils.errorsr   r   r   Zfixturer   r   r   r   r   r
   <module>   s   
