o
    DDi	                     @   s|   d dl mZ d dlZd dlmZ d dlmZm	Z	m
Z
mZ G dd deZG dd de
ZG dd	 d	eZG d
d de
ZdS )    )expectedFailureN)CodemodCodemodContextCodemodTestSkipFilec                       s@   e Zd Zdededdf fddZdejdejfdd	Z  Z	S )
SimpleCodemodcontextskipreturnNc                      t  | || _d S N)super__init__r	   )selfr   r	   	__class__ Z/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/codemod/tests/test_codemod.pyr         
zSimpleCodemod.__init__treec                 C   s   | j rt |S r   )r	   r   r   r   r   r   r   transform_module_impl   s   z#SimpleCodemod.transform_module_impl)
__name__
__module____qualname__r   boolr   cstModuler   __classcell__r   r   r   r   r      s    r   c                   @   s6   e Zd ZeZd	ddZed	ddZed	ddZdS )
TestSkipDetectionr
   Nc                 C   s,   d}| j ||ddd | j ||ddd d S )Nu
            def foo() -> None:
                pass

            def bar() -> int:
                return 5
        Fr	   expected_skipTassertCodemodr   coder   r   r   test_detect_skip   s   z"TestSkipDetection.test_detect_skipc                 C      d}| j ||ddd d S )Nr    FTr!   r#   r%   r   r   r   test_did_not_skip_but_should(      z.TestSkipDetection.test_did_not_skip_but_shouldc                 C   r(   )Nr    TFr!   r#   r%   r   r   r   test_skipped_but_should_not4   r*   z-TestSkipDetection.test_skipped_but_should_notr
   N)	r   r   r   r   	TRANSFORMr'   r   r)   r+   r   r   r   r   r      s    
r   c                       sN   e Zd Zdededdf fddZdefddZd	ej	dej	fd
dZ
  ZS )IncrementCodemodr   
iterationsr
   Nc                   r   r   )r   r   r/   )r   r   r/   r   r   r   r   B   r   zIncrementCodemod.__init__c                 C   s   dS )NTr   )r   r   r   r   should_allow_multiple_passesF   s   z-IncrementCodemod.should_allow_multiple_passesr   c                 C   s<   | j dkr|S |  j d8  _ tt|t dd tjS )Nr      c                 S   s   | j tt| jd dS )Nr1   )value)with_changesstrintr2   )node_r   r   r   <lambda>R   s    z8IncrementCodemod.transform_module_impl.<locals>.<lambda>)r/   r   ensure_typemreplaceIntegerr   r   r   r   r   r   I   s   
z&IncrementCodemod.transform_module_impl)r   r   r   r   r5   r   r   r0   r   r   r   r   r   r   r   r   r.   A   s    r.   c                   @   s   e Zd ZeZdddZdS )TestMultipassr
   Nc                 C   s   d}d}| j ||dd d S )Nz
            x = 5
        z
            x = 10
           )r/   r#   )r   beforeafterr   r   r   test_multi_iterations[   s   z#TestMultipass.test_multi_iterationsr,   )r   r   r   r.   r-   rA   r   r   r   r   r=   X   s    r=   )unittestr   libcstr   libcst.matchersmatchersr:   libcst.codemodr   r   r   r   r   r   r.   r=   r   r   r   r   <module>   s   (