o
    JAf—  ã                   @   s>   d Z ddlmZ G dd„ dƒZG dd„ dƒZG dd„ dƒZd	S )
zqMock classes that imitate idlelib modules or classes.

Attributes and methods will be added as needed for tests.
é    )ÚTextc                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	ÚFuncaZ  Record call, capture args, return/raise result set by test.

    When mock function is called, set or use attributes:
    self.called - increment call number even if no args, kwds passed.
    self.args - capture positional arguments.
    self.kwds - capture keyword arguments.
    self.result - return or raise value set in __init__.
    self.return_self - return self instead, to mock query class return.

    Most common use will probably be to mock instance methods.
    Given class instance, can set and delete as instance attribute.
    Mock_tk.Var and Mbox_func are special variants of this.
    NFc                 C   s"   d| _ || _|| _d | _d | _d S )Nr   )ÚcalledÚresultÚreturn_selfÚargsÚkwds)Úselfr   r   © r
   ú2/usr/lib/python3.10/idlelib/idle_test/mock_idle.pyÚ__init__   s
   
zFunc.__init__c                 O   s<   |  j d7  _ || _|| _t| jtƒr| j‚| jr| S | jS )Né   )r   r   r   Ú
isinstancer   ÚBaseExceptionr   )r	   r   r   r
   r
   r   Ú__call__   s   zFunc.__call__)NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r
   r
   r   r      s    
r   c                   @   s&   e Zd ZdZ		ddd„Zdd„ ZdS )ÚEditorz1Minimally imitate editor.EditorWindow class.
    Nc                 C   s   |pt ƒ | _tƒ | _d S ©N)r   ÚtextÚUndoDelegatorZundo)r	   ÚflistÚfilenameÚkeyÚrootr   r
   r
   r   r   +   s   zEditor.__init__c                 C   s    | j  d¡}| j  d¡}||fS )Nz1.0Úend)r   Úindex)r	   ÚfirstZlastr
   r
   r   Úget_selection_indices0   s   zEditor.get_selection_indices)NNNNN)r   r   r   r   r   r    r
   r
   r
   r   r   (   s    
ÿr   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )r   z0Minimally imitate undo.UndoDelegator class.
    c                  G   ó   d S r   r
   ©r   r
   r
   r   Úundo_block_start:   ó   zUndoDelegator.undo_block_startc                  G   r!   r   r
   r"   r
   r
   r   Úundo_block_stop<   r$   zUndoDelegator.undo_block_stopN)r   r   r   r   r#   r%   r
   r
   r
   r   r   6   s    r   N)r   Zidlelib.idle_test.mock_tkr   r   r   r   r
   r
   r
   r   Ú<module>   s
     