
    ;e                         d Z ddlmZ ddlZddlmZ  ed           ddlmZ ddlm	Z	m
Z
 ddlmZ  G d	 d
ej                  Zedk    r ej        dd           dS dS )zTest undo, coverage 77%.    )UndoDelegatorN)requiresgui)Mock)TextTk)
Percolatorc                   j    e Zd Zed             Zed             Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 ZdS )UndoDelegatorTestc                     t                      | _        t          | j                  | _        t	          | j                  | _        d S N)r   rootr   textr	   
percolatorclss    2/usr/lib/python3.11/idlelib/idle_test/test_undo.py
setUpClasszUndoDelegatorTest.setUpClass   s1    44>>#CH--    c                     | j         j                                         | ` | `| j                                         | `d S r   )r   redircloser   r   destroyr   s    r   tearDownClasszUndoDelegatorTest.tearDownClass   s?    ""$$$NCHHHHr   c                     t                      | _        t                      | j        _        | j                            | j                   d S r   )r   	delegatorr   bellr   insertfilterselfs    r   setUpzUndoDelegatorTest.setUp   s9    &"ff$$T^44444r   c                     | j                             | j                   | j                            dd           | j                                         d S )N1.0end)r   removefilterr   r   delete
resetcacher   s    r   tearDownzUndoDelegatorTest.tearDown"   sL    $$T^444	&&&!!#####r   c                    | j         }|                    dd           |                    dd           |                    d           |                     |                    dd          d           |                    dd           |                    dd	           |                    d
d           |                    dd           |                    d           |                     |                    dd          d           |                    d           |                     |                    dd          d           |                    d           |                     |                    dd          d           |                    d           | j                            d           |                     | j        j	        j
                   d S )Ninsertfoobarh<<undo>>r#   r$   
foobar1.21.4hellofoarz1.61.3event)r   r*   event_generateassertEqualgetr&   r   
undo_event
assertTruer   calledr    r   s     r   test_undo_eventz!UndoDelegatorTest.test_undo_event'   s   yHh'''Hc"""J'''%//666He$$$He$$$E5!!!Hg&&&J'''%//888J'''%//:::J'''%//777J'''!!'***+233333r   c                    | j         }|                    dd           |                    dd           |                    dd           |                    d           |                    d           |                     |                    dd          d           |                    d           |                     | j        j        j	                   d S )Nr*   r/   r0   r#   r5   r-   z<<redo>>)
r   r*   r&   r7   r8   r9   r;   r   r   r<   r=   s     r   test_redo_eventz!UndoDelegatorTest.test_redo_event=   s    yHe$$$He$$$E5!!!J'''J'''%//777J'''+233333r   c                 X   | j         }| j        }|                    dd           |                    dd           |                    dd           |                     |j        |j        fd           |                    d           |                     |j        |j        fd           d	S )
z
        Dump_event cannot be tested directly without changing
        environment variables. So, test statements in dump_event
        indirectly
        r*   r/   r0   r1   r2   )   Tr-   )   FN)r   r   r*   r&   assertTupleEqualpointer	can_merger7   )r    r   ds      r   test_dump_eventz!UndoDelegatorTest.test_dump_eventI   s     yNHe$$$He$$$E5!!!qy!+6	BBBJ'''qy!+6
CCCCCr   c                 R   | j         }|                     |                                           | j                            dd           |                     |                                           t                      |_        |                    d           | 	                    |j
        |j                   |                     |j        j                   |                    d           | 	                    |j        d           |                     |j        j                   d S )Nr*   aTF)r   r;   	get_savedr   r*   assertFalser   saved_change_hook	set_savedr8   rE   savedr<   )r    rG   s     r   test_get_set_savedz$UndoDelegatorTest.test_get_set_savedY   s     N&&&	3''''''"ff	DAG,,,+2333	E"%%%+233333r   c                 4   | j         }|                    dd           | j                                         |                    dd           |                    dd           | j                                         |                     |                    dd          d           | j                                         |                    dd           | j                                         |                     |                    dd          d           d S )Nr*   r/   r0   r#   r5   )r   r*   r   undo_block_startundo_block_stopr8   r9   r=   s     r   test_undo_start_stopz&UndoDelegatorTest.test_undo_start_stopl   s    yHe$$$'')))He$$$He$$$&&(((%//777 	'')))He$$$&&(((%//77777r   c                     | j         }dx| j        _        }t          |dz             D ]E}|                    dd           |                     t          | j        j                  |           Fd S )N
   r*   r/   )r   r   max_undoranger*   assertLessEquallenundolist)r    r   rX   is       r   test_addcmdzUndoDelegatorTest.test_addcmd}   s{    y-//(x"}%% 	I 	IAKK%(((  T^%<!=!=xHHHH	I 	Ir   N)__name__
__module____qualname__classmethodr   r   r!   r(   r>   r@   rH   rQ   rU   r^    r   r   r   r      s        . . [.
   [5 5 5
$ $ $
4 4 4,
4 
4 
4D D D 4 4 4&8 8 8"I I I I Ir   r   __main__rC   F)	verbosityexit)__doc__idlelib.undor   unittesttest.supportr   unittest.mockr   tkinterr   r   idlelib.percolatorr	   TestCaser   r_   mainrc   r   r   <module>rp      s      ' & & & & &  ! ! ! ! ! !                ) ) ) ) ) )uI uI uI uI uI) uI uI uIp zHMAE****** r   