<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 f8                 @   s   d Z 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
 ddlmZ ddlZddlmZ ejjZejdejdejdejdd	Zd
ZG dd dZG dd dejZG dd dejZedkrejdd dS )zTest codecontext, coverage 100%    )codecontextN)requires)TkFrameTextTclError)mock)config )mainZ	highlightkeys
extensionsz
class C1():
    # Class comment.
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def compare(self):
        if a > b:
            return a
        elif a < b:
            return b
        else:
            return None
c               @   s   e Zd Zdd ZdS )DummyEditwinc             C   s   || _ || _|| _|| _d S )N)roottopZ
text_frametext)selfr   framer    r   G/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_codecontext.py__init__&   s    zDummyEditwin.__init__N)__name__
__module____qualname__r   r   r   r   r   r   %   s   r   c               @   s   e Zd Zedd Ze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ejjejddd Zdd ZdS )CodeContextTestc             C   s~   t d t  }| _|j  t| }| _t| }| _|jdt	 |j
dddd |j
dddd t|||| _ttj_d S )NZguiz1.0leftZboth   )ZsideZfillexpandr   )r   r   r   Zwithdrawr   r   r   r   insertcode_sampleZpackr   editortestcfgr   idleConfuserCfg)clsr   r   r   r   r   r   
setUpClass/   s    zCodeContextTest.setUpClassc             C   s@   t tj_| jjjdd | `| `| `| jj	  | jj
  | `d S )Nz1.0end)usercfgr   r"   r#   r    r   deleter   r   Zupdate_idletasksdestroy)r$   r   r   r   tearDownClass=   s    

zCodeContextTest.tearDownClassc             C   s   | j jd tj| j| _d S )Nr   )r   yviewr   CodeContextr    cc)r   r   r   r   setUpF   s    zCodeContextTest.setUpc             C   s,   | j jr| j jj  | j j  | j `| ` d S )N)r-   contextr)   __del__)r   r   r   r   tearDownJ   s    
zCodeContextTest.tearDownc             C   s   | j }| j}| j}||j| ||j|j ||j|jd  | j|j ||jd
g ||j	d || j
jjdd| jjd d || j
jjdd| jjd d d S )Nfontr   r   r
   FafterinfoZtimer)r   r5   r
   F)assertEqualr    r-   Zeditwinr   textfontassertIsNoner/   r4   
topvisibler   tkcallt1t2)r   eqZedr-   r   r   r   	test_initQ   s     zCodeContextTest.test_initc             C   s   | j j  | jt(}| jjjdd| j j | jd| W d Q R X | jt(}| jjjdd| j j	 | jd| W d Q R X | j `| j `	| j j  d S )Nr3   r4   zdoesn't exist)
r-   r0   assertRaisesr   r   r:   r;   r<   ZassertInr=   )r   msgr   r   r   test_del_   s    
zCodeContextTest.test_delc             C   s4   t jj  | j| jjddd | j| jjd d S )NZ	lightgrayz#000000)
background
foreground   )r   r,   reloadr6   r-   colorscontext_depth)r   r   r   r   test_reloadl   s    

zCodeContextTest.test_reloadc             C   s   | j }| j}|j}|jr|  || d | j|j ||jd |j ||jd |jd  ||jd |jd  ||jjddd	 || d | j|j d S )
Nbreakr2   ZfgrD   ZbgrC   z1.0zend-1cr
   )	r6   r-   toggle_code_context_eventr/   ZassertIsNotNoner7   rG   getr8   )r   r>   r-   Ztoggler   r   r   test_toggle_code_context_eventr   s    z.CodeContextTest.test_toggle_code_context_eventc             C   s.  | j }| jj}| jt |ddd W d Q R X ||ddgdf ||ddgdf ||d	ddgdf ||ddddgdf ||ddddd gdf ||dddd!d"d#d$gdf ||dddd%d&d'gdf ||dddd(d)gdf ||dddd*d+d,gdf ||dddd-d.gdf d S )/Nr   r   )Zstopline      class C1():class          def __init__(self, a, b):def
          def compare(self):           if a > b:if           elif a < b:elif)Z
stopindent)rO   r   rP   rQ   )rO   r   rP   rQ   )rO   r   rP   rQ   )rR   rR   rT   rU   )rO   r   rP   rQ   )rW   rR   rX   rU   )rY   rY   rZ   r[   )rO   r   rP   rQ   )rW   rR   rX   rU   )rY   rY   rZ   r[   )rV   rY   r]   r^   )rO   r   rP   rQ   )rW   rR   rX   rU   )rY   rY   rZ   r[   )rV   rY   r]   r^   )rW   rR   rX   rU   )rY   rY   rZ   r[   )rV   rY   r]   r^   )rY   rY   rZ   r[   )rV   rY   r]   r^   )rW   rR   rX   rU   )rY   rY   rZ   r[   )rV   rY   r]   r^   )rY   rY   rZ   r[   )rV   rY   r]   r^   )r6   r-   Zget_contextr@   AssertionError)r   r>   gcr   r   r   test_get_context   s:    


z CodeContextTest.test_get_contextc          
   C   s*  | j }| j}|js|j  | j|j  ||jdg ||jd |jj	d |j  ||jdg ||jd ||jj
ddd |jj	d |j  ||jd!d"g ||jd
 ||jj
ddd |jj	d
 |j  ||jd$d%g ||jd ||jj
ddd |jj	d |j  ||jd'd(d)g ||jd ||jj
ddd |jj	d |j  ||jd+d,d-d.d/g ||jd ||jj
ddd |j  d|_||jd1d2d3d4d5g ||jd ||jj
ddd |jj	d |j  ||jd7d8d9g ||jd ||jj
ddd d S ):Nr   r   r
   FrO   z1.0zend-1cclass C1():rQ   rN   rR       def __init__(self, a, b):rU   rS   z)class C1():
    def __init__(self, a, b):r\   rW       def compare(self):rY           if a > b:r[   rV           elif a < b:r^      zHclass C1():
    def compare(self):
        if a > b:
        elif a < b:   r5   )r   r5   r
   Fr5   )r   r5   r
   Fr5   )r   r5   r
   F)rO   r   rb   rQ   r5   )r   r5   r
   F)rO   r   rb   rQ   r5   )r   r5   r
   F)rO   r   rb   rQ   )rR   rR   rc   rU   r5   )r   r5   r
   F)rO   r   rb   rQ   )rW   rR   rd   rU   )rY   rY   re   r[   )rV   rY   rf   r^   r5   )r   r5   r
   F)rO   r   rb   rQ   )rW   rR   rd   rU   )rY   rY   re   r[   )rV   rY   rf   r^   r5   )r   r5   r
   F)rO   r   rb   rQ   )rR   rR   rc   rU   )r6   r-   r/   rK   r8   update_code_contextr4   r9   r   r+   rL   rH   )r   r>   r-   r   r   r   test_update_code_context   sl    z(CodeContextTest.test_update_code_contextc             C   s   | j }| j}|j}|js |j  |jjd d |j  ||jd |jj	dd |  ||jd |jjd d |j  ||jd |jj	dd |  ||jd d|_
|jjd d |j  ||jd |jj	dd	 |  ||jd d S )
NrO   z.0r   z1.5r   rg   z3.0rY   z1.0)r6   r-   Z
jumptoliner/   rK   r   r+   ri   r9   Zmark_setrH   )r   r>   r-   Zjumpr   r   r   test_jumptoline  s0    zCodeContextTest.test_jumptolineri   c             C   sD   | j jr| j j  | j j  |j  | j j  | j j  |j  d S )N)r-   r/   rK   Ztimer_eventZassert_not_calledZassert_called)r   Zmock_updater   r   r   test_timer_event)  s    



z CodeContextTest.test_timer_eventc             C   s  | j }| j}|jd }tjj}d}ddd}|jr:|j  ||jd< |tj_|j  ||j	| ||j
| |j  ||jd< |tj_|j  ||j	| ||j
| ||jd | ||jd |d  ||jd |d  ||jd< |j  ||j	| ||j
| ||jd | ||jd |d  ||jd |d  ||jd< |tj_|j  ||j	| ||j
| ||jd | ||jd |d  ||jd |d  |tj_|j  d S )Nr2   ZFakeFontz#222222z#ffff00)rC   rD   rC   rD   )r6   r-   r   r   r,   rG   r/   rK   Zconfig_timer_eventr7   Zcontextcolors)r   r>   r-   Z	save_fontZsave_colorsZ	test_fontZtest_colorsr   r   r   test_config_timer_event6  sN    





z'CodeContextTest.test_config_timer_eventN)r   r   r   classmethodr%   r*   r.   r1   r?   rB   rI   rM   ra   rj   rk   r   Zpatchobjectr   r,   rl   rm   r   r   r   r   r   -   s   	0Q!r   c               @   s   e Zd Zdd Zdd ZdS )HelperFunctionTextc          	   C   sJ   t j}d}x |D ]\}}| j||| qW | j|dtjddd  d S )!N    first word    first	first word	
     ᧔᧒:      ᧔᧒	no spacesr
   no# TEST COMMENT    (continuation)z^(\s*)([^\s]*))c(continuation)rr   rs   rq   r   ru   rs   rt   r   rw   rx   rv   r   r
   rz   ry   r   r
   r
   r
   r   r
   r
   r{   r   rr   r
   r|   r   )r   r   r   r   r   r   r   )rr   r~   )r   Zget_spaces_firstwordr6   recompile)r   rL   Z
test_lineslineZexpected_outputr   r   r   test_get_spaces_firstwordl  s          z,HelperFunctionText.test_get_spaces_firstwordc             C   s   | j }tj}tj }|||d tjddf |||d d |||d tjddf |||d	 d |||d d ||dd d S )Nr   r
   Fr   class C1():rQ   rO   z    # Class comment.rN   rR       def __init__(self, a, b):rU   rW   rY           if a > b:r[   	if a == b:)r   r   rQ   )rR   r   rU   )rY   r   r[   )r   r   r[   )r6   r   Zget_line_infor   
splitlinesZINFINITY)r   r>   Zglilinesr   r   r   test_get_line_info  s    z%HelperFunctionText.test_get_line_infoN)r   r   r   r   r   r   r   r   r   rp   j  s   rp   __main__rO   )	verbosity)__doc__Zidlelibr   ZunittestZtest.supportr   Ztkinterr   r   r   r   r   r   r	   r"   r#   r'   ZIdleUserConfParserr!   r   r   ZTestCaser   rp   r   r   r   r   r   r   <module>   s(     ?(