o
    DDio                     @   sp   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 d dlmZ G dd deZdS )	    N)Path)skipIf)	is_native)CodemodTest)UnitTestc                   @   sF   e Zd Zee dkddddZdddZddd	Zdd
dZ	dS )TestCodemodCLIWindowsreturnNc                 C   sj   t jtjddddddtttjd gt jt jd}t	 s)| 
d	|jd
 d S | 
d|jd
 d S )N-mlibcst.toolcodemodz0remove_unused_imports.RemoveUnusedImportsCommandz--python-versionz3.6z$codemod_formatter_error_input.py.txt)stdoutstderrz(ParserSyntaxError: Syntax Error @ 14:11.utf-8zterror: cannot format -: Cannot parse for target version Python 3.6: 13:10:     async with AsyncExitStack() as stack:)
subprocessrunsys
executablestrr   __file__parentPIPEr   assertInr   decode)selfrlt r   ^/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/codemod/tests/test_codemod_cli.py"test_codemod_formatter_error_input   s,   

z1TestCodemodCLI.test_codemod_formatter_error_inputc              
   C   s:   t jtjdddddtttgdt jd}d|v sJ d S )	Nr
   r   r   z-xz(libcst.codemod.commands.noop.NOOPCommandr   encodingr   zFinished codemodding 1 files!)r   check_outputr   r   r   r   r   STDOUT)r   outputr   r   r   test_codemod_external3   s   
	z$TestCodemodCLI.test_codemod_externalc              	   C   s   d}t  D}t|}|d t| |d t| |d t| tjtj	ddddt
|gd	tjd
}| d|j W d    d S 1 sMw   Y  d S )NzL
        def baz() -> str:
            return "{}: {}".format(*baz)
        zmod1.pyzmod2.pyzmod3.pyr
   r   r   z4convert_format_to_fstring.ConvertFormatStringCommandr   r   z- 3 warnings were generated.)tempfileTemporaryDirectoryr   
write_textr   make_fixture_datar   r   r   r   r   r   r   r   )r   codetmpdirpr#   r   r   r   #test_warning_messages_several_filesE   s,   
"z2TestCodemodCLI.test_warning_messages_several_filesc                 C   s   d}d}t  C}t|}t|D ]}|d| d t| qtjt	j
ddddt|d	t|gd
tjd}| d| d|j W d    d S 1 sNw   Y  d S )N   z=
        def baz(): # type: int
            return 5
        modz.pyr
   r   r   z)convert_type_comments.ConvertTypeCommentsz--jobsr   r   zTransformed z files successfully.)r%   r&   r   ranger'   r   r(   r   r   r   r   r   r   r   r   )r   
file_countr)   r*   r+   ir#   r   r   r   'test_matcher_decorators_multiprocessinga   s0   

"z6TestCodemodCLI.test_matcher_decorators_multiprocessing)r	   N)
__name__
__module____qualname__r   platformsystemr   r$   r,   r2   r   r   r   r   r      s    

r   )r6   r   r   r%   pathlibr   unittestr   libcst._parser.entrypointsr   libcst.codemodr   libcst.testing.utilsr   r   r   r   r   r   <module>   s   