<!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
2a8                 @   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	 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 )    )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   5/opt/alt/python36/lib64/python3.6/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sidefillexpandr   )r   r   r   Zwithdrawr   r   r   r   insertcode_sample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   r7   r
   F)assertEqualr"   r/   Zeditwinr   textfontassertIsNoner1   r6   
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 )Nr5   r6   zdoesn't exist)
r/   r2   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.   reloadr8   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breakr4   ZfgrF   bgrE   z1.0zend-1cr
   )	r8   r/   toggle_code_context_eventr1   ZassertIsNotNoner9   rI   getr:   )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)rR   r   rS   rT   )rR   r   rS   rT   )rR   r   rS   rT   )rU   rU   rW   rX   )rR   r   rS   rT   )rZ   rU   r[   rX   )r\   r\   r]   r^   )rR   r   rS   rT   )rZ   rU   r[   rX   )r\   r\   r]   r^   )rY   r\   r`   ra   )rR   r   rS   rT   )rZ   rU   r[   rX   )r\   r\   r]   r^   )rY   r\   r`   ra   )rZ   rU   r[   rX   )r\   r\   r]   r^   )rY   r\   r`   ra   )r\   r\   r]   r^   )rY   r\   r`   ra   )rZ   rU   r[   rX   )r\   r\   r]   r^   )rY   r\   r`   ra   )r\   r\   r]   r^   )rY   r\   r`   ra   )r8   r/   Zget_contextrB   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
   FrR   z1.0zend-1cclass C1():rT   rQ   rU       def __init__(self, a, b):rX   rV   z)class C1():
    def __init__(self, a, b):r_   rZ       def compare(self):r\           if a > b:r^   rY           elif a < b:ra      zHclass C1():
    def compare(self):
        if a > b:
        elif a < b:   r7   )r   r7   r
   Fr7   )r   r7   r
   Fr7   )r   r7   r
   F)rR   r   re   rT   r7   )r   r7   r
   F)rR   r   re   rT   r7   )r   r7   r
   F)rR   r   re   rT   )rU   rU   rf   rX   r7   )r   r7   r
   F)rR   r   re   rT   )rZ   rU   rg   rX   )r\   r\   rh   r^   )rY   r\   ri   ra   r7   )r   r7   r
   F)rR   r   re   rT   )rZ   rU   rg   rX   )r\   r\   rh   r^   )rY   r\   ri   ra   r7   )r   r7   r
   F)rR   r   re   rT   )rU   rU   rf   rX   )r8   r/   r1   rN   r:   update_code_contextr6   r;   r   r-   rO   rJ   )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 )
NrR   z.0r   z1.5r   rj   z3.0r\   z1.0)r8   r/   Z
jumptoliner1   rN   r   r-   rl   r;   Zmark_setrJ   )r   r@   r/   Zjumpr   r   r   test_jumptoline  s0    zCodeContextTest.test_jumptolinerl   c             C   sD   | j jr| j j  | j j  |j  | j j  | j j  |j  d S )N)r/   r1   rN   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 )Nr4   ZFakeFontz#222222z#ffff00)rE   rF   rE   rF   )r8   r/   r   r   r.   rI   r1   rN   Zconfig_timer_eventr9   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,   r0   r3   rA   rD   rK   rP   rd   rm   rn   r   Zpatchobjectr   r.   ro   rp   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)ru   rv   rt   r   rx   rv   rw   r   rz   r{   ry   r   r
   r}   r|   r   r
   r
   r
   r   r
   r
   r~   r   ru   r
   r   r   )r   r   r   r   r   r   r   )ru   r   )r   Zget_spaces_firstwordr8   recompile)r   rO   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():rT   rR   z    # Class comment.rQ   rU       def __init__(self, a, b):rX   rZ   r\           if a > b:r^   	if a == b:)r   r   rT   )rU   r   rX   )r\   r   r^   )r   r   r^   )r8   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   rs   j  s   rs   __main__rR   )	verbosity)Zidlelibr   ZunittestZtest.supportr   Ztkinterr   r   r   r   r   r   r	   r$   r%   r)   ZIdleUserConfParserr#   r    r   ZTestCaser   rs   r   r   r   r   r   r   <module>   s&     ?(