U
    +ºc%  ã                   @   sr   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 G dd	„ d	e	j
ƒZed
krne	 ¡  dS )z Tests for the completion module.é    )Úabsolute_import)Údivision)Úprint_function)Ú
completion)Útest_components)Ú	testutilsc                   @   sœ   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d„ Z
dd„ Zdd„ Zd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 )&ÚTabCompletionTestc                 C   s^   dgdgddgg}t jd|d}|  d|¡ |  d|¡ d}dD ]}|  |j|d|¡ q@d S )	NÚrunÚhaltú--nowÚcommand©ÚnameÚcommandsz
{command}))r   r
   )r   )r   Z_BashScriptÚassertInÚformat)Úselfr   ÚscriptZassert_templateZlast_command© r   ú8/tmp/pip-unpacked-wheel-1xt1w7un/fire/completion_test.pyÚtestCompletionBashScript   s    ýz*TabCompletionTest.testCompletionBashScriptc                 C   sH   dgdgddgg}t jd|d}|  d|¡ |  d|¡ |  d|¡ d S )Nr	   r
   r   r   r   z-l now)r   Z_FishScriptr   )r   r   r   r   r   r   ÚtestCompletionFishScript,   s    ýz*TabCompletionTest.testCompletionFishScriptc                 C   s:   dd„ }t  |¡}|  d|¡ |  d|¡ |  d|¡ d S )Nc                 S   s
   | ||fS ©Nr   )ZoneZtwoZthreer   r   r   Úexample:   s    z4TabCompletionTest.testFnCompletions.<locals>.examplez--onez--twoz--three)r   ÚCompletionsr   )r   r   Úcompletionsr   r   r   ÚtestFnCompletions9   s
    
z#TabCompletionTest.testFnCompletionsc                 C   sD   t  dddg¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )NÚredÚgreenÚblueÚ0Ú1Ú2Ú3©r   r   r   ÚassertNotIn©r   r   r   r   r   ÚtestListCompletionsB   s
    z%TabCompletionTest.testListCompletionsc                 C   sn   ddddœ}t  |¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )	Nr   ÚyellowT©r   r   Ú_rainbowr   r   r*   ÚTruer$   ©r   Úcolorsr   r   r   r   ÚtestDictCompletionsI   s    ý
z%TabCompletionTest.testDictCompletionsc                 C   sr   ddddœ}t j|dd}|  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d	|¡ |  d|¡ d S )
Nr   r(   Tr)   )Úverboser   r   r*   r+   r$   r,   r   r   r   ÚtestDictCompletionsVerboseX   s    ýz,TabCompletionTest.testDictCompletionsVerbosec                 C   s:   ddddi iiii}t  |¡}|  d|¡ |  d|¡ d S )NÚlevel1Úlevel2Úlevel3Úlevel4r$   )r   Údeepdictr   r   r   r   ÚtestDeepDictCompletionsg   s    
z)TabCompletionTest.testDeepDictCompletionsc                 C   sT   ddddi iiii}t  d|¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )Nr1   r2   r3   r4   r5   ©r   ÚScriptr   r%   ©r   r5   r   r   r   r   ÚtestDeepDictScriptm   s    z$TabCompletionTest.testDeepDictScriptc                 C   sB   t  dtj¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )NÚidentityz--arg1z--arg2z--arg3z--arg4©r   r8   Útcr;   r   ©r   r   r   r   r   ÚtestFnScriptu   s
    zTabCompletionTest.testFnScriptc                 C   sN   t  dtj¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )NÚ ÚtenÚsumr;   z--alphaz--beta©r   r8   r=   ZMixedDefaultsr   r>   r   r   r   ÚtestClassScript|   s    z!TabCompletionTest.testClassScriptc                 C   sX   ddddi iiii}t jd|dd}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )Nr1   r2   r3   r4   r5   Úfish©Úshellr7   r9   r   r   r   ÚtestDeepDictFishScript„   s    z(TabCompletionTest.testDeepDictFishScriptc                 C   sF   t jdtjdd}|  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )Nr;   rE   rF   Zarg1Zarg2Zarg3Zarg4r<   r>   r   r   r   ÚtestFnFishScriptŒ   s
    z"TabCompletionTest.testFnFishScriptc                 C   sR   t jdtjdd}|  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )	Nr@   rE   rF   rA   rB   r;   ÚalphaÚbetarC   r>   r   r   r   ÚtestClassFishScript“   s    z%TabCompletionTest.testClassFishScriptc                 C   s^   t  ddddœ¡}|  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ d S )Nr   r(   Zpink)é
   g…ëQ¸	@)Út1Út2Ú10z3.14z('t1', 't2')r$   r&   r   r   r   ÚtestNonStringDictCompletions›   s    ýz.TabCompletionTest.testNonStringDictCompletionsc                 C   s$   dd„ }t  |ƒ ¡}|  |g ¡ d S )Nc                  s   s   d} | V  | d7 } qd S )Nr   é   r   )Úxr   r   r   Ú	generator©   s    z=TabCompletionTest.testGeneratorCompletions.<locals>.generator)r   r   ÚassertEqual)r   rT   r   r   r   r   ÚtestGeneratorCompletions¨   s    z*TabCompletionTest.testGeneratorCompletionsc                 C   s   t  tj¡}|  |g ¡ d S r   )r   r   r=   Ú
NoDefaultsrU   r&   r   r   r   ÚtestClassCompletions±   s    z&TabCompletionTest.testClassCompletionsc                 C   s*   t  t ¡ ¡}|  d|¡ |  d|¡ d S )NÚdoubleZtriple)r   r   r=   rW   r   r&   r   r   r   ÚtestObjectCompletionsµ   s    z'TabCompletionTest.testObjectCompletionsc                 C   s,   t  t ¡ j¡}|  d|¡ |  d|¡ d S )Nz--selfz--count)r   r   r=   rW   rY   r%   r   r&   r   r   r   ÚtestMethodCompletionsº   s    z'TabCompletionTest.testMethodCompletionsN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r'   r.   r0   r6   r:   r?   rD   rH   rI   rL   rQ   rV   rX   rZ   r[   r   r   r   r   r      s$   		r   Ú__main__N)Ú__doc__Ú
__future__r   r   r   Zfirer   r   r=   r   ZBaseTestCaser   r\   Úmainr   r   r   r   Ú<module>   s    '