HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/idlelib/idle_test/__pycache__/test_codecontext.cpython-311.pyc
�

��Vc�@���dZddlmZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddlm
Z
ddlZddlmZejjZejd��ejd��ejd��ejd��d	�Zd
ZGd�d��ZGd
�dej��ZGd�dej��Zedkrejd���dSdS)zTest codecontext, coverage 100%�)�codecontextN)�requires)�NSEW�Tk�Frame�Text�TclError)�mock)�config�)�main�	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� �eZdZd�Zd�Zd�ZdS)�DummyEditwinc�L�||_||_||_||_d|_dS)Nr)�root�top�
text_frame�text�label)�selfr�framers    �6D:\Python311\Lib\idlelib\idle_test\test_codecontext.py�__init__zDummyEditwin.__init__'s)����	���������	���
�
�
�c�j�tt|j�|������S�N)�int�floatr�index)rr"s  r�	getlinenozDummyEditwin.getlineno.s&���5������/�/�0�0�1�1�1rc� �|d|_dS)Nr)r)r�kwargss  r�update_menu_labelzDummyEditwin.update_menu_label1s���G�_��
�
�
rN)�__name__�
__module__�__qualname__rr#r&�rrrr&sA���������2�2�2�%�%�%�%�%rrc���eZdZed���Zed���Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zej�ejd
��d���Zd�Zd�ZdS)�CodeContextTestc���td��t��x}|_|���t	|��x}|_t
|��x}|_|�dt��|�
ddd���|�ddt���t|||��|_tt j_dS)N�gui�1.0�left�both�)�side�fill�expand)�row�column�sticky)rrr�withdrawrrrr�insert�code_sample�pack�gridrr�editor�testcfgr�idleConf�userCfg)�clsrrrs    r�
setUpClasszCodeContextTest.setUpClass7s���������$�$���s�x��
�
����!�$�K�K�'���	��u�+�+�%��s�x����E�;�'�'�'�
�
�
��V�A�
�6�6�6��	�	�a��$�	�/�/�/�!�$��t�4�4��
�'.���$�$�$rc���ttj_|jj�dd��|`|`|`|j�	��|j�
��|`dS)Nr/�end)�usercfgrr@rAr>r�deleterr�update_idletasks�destroy)rBs r�
tearDownClasszCodeContextTest.tearDownClassEse��'.���$��
����u�e�,�,�,��J��	�3�8���!�!�#�#�#���������H�H�Hrc�`����j�d��d�jd<tj�j���_ddd��_tjj���fd�}tj
j�tjd|��}|�
����|j��d�_�fd	�}tj
j�tjd
|��}|�
����|j��dS)Nr�TkFixedFont�fontz#abcdefz#123456��
background�
foregroundc�6��|dkr�jS�||��S)N�context)�
highlight_cfg)�theme�element�orig_idleConf_GetHighlightrs  ��r�mock_idleconf_GetHighlightz9CodeContextTest.setUp.<locals>.mock_idleconf_GetHighlightVs,����)�#�
*��)�)�-�-�e�W�=�=�=r�GetHighlightc����jSr)�
font_override)r�
configType�sectionrs   �r�mock_idleconf_GetFontz4CodeContextTest.setUp.<locals>.mock_idleconf_GetFont`s����%�%r�GetFont)r�yviewr�CodeContextr>�ccrSr@rX�unittestr
�patch�object�start�
addCleanup�stoprZ)rrW�GetHighlight_patcherr]�GetFont_patcherrVs`    @r�setUpzCodeContextTest.setUpNs>�����	�������)��	�&���)�$�+�6�6���,5�,5�7�7���%0�%9�%F�"�	>�	>�	>�	>�	>�	>� (�}�2�9�9�� �.�2L� N� N���"�"�$�$�$����,�1�2�2�2�*���	&�	&�	&�	&�	&�"�-�-�4�4�� �)�-B�D�D������������,�-�-�-�-�-rc��|jjr|jj���|j���|j`|`dSr)rarRrI�__del__�rs r�tearDownzCodeContextTest.tearDowngsE���7�?�	&��G�O�#�#�%�%�%���������G�O�T�W�W�Wrc�z�|j}|j}|j}||j|��||j|j��||jd|jd��|�|j��||jdg��||jd��|�|jj	��dS)NrM�r���rFr2)
�assertEqualr>ra�editwinr�assertIsNonerR�info�
topvisible�t1)r�eq�edras    r�	test_initzCodeContextTest.test_initns���
�
��
�[��
�W��
��2�:�r����
��2�7�B�G����
��2�7�6�?�B�G�F�O�,�,�,����"�*�%�%�%�
��2�7�'�(�)�)�)�
��2�=�!�������$�'�*�%�%�%�%�%rc�8�|j���dSr)rarlrms r�test_delzCodeContextTest.test_del{s����������rc�~�|j�dd���x}|j_|j���|�t��5}|jj�	dd|��ddd��n#1swxYwY|�
dt|j����dS)Ni'c��dSrr*r*rr�<lambda>z5CodeContextTest.test_del_with_timer.<locals>.<lambda>s��D�r�afterruz
doesn't exist)
rr�rarwrl�assertRaisesr	r�tk�call�assertIn�str�	exception)r�timer�cms   r�test_del_with_timerz#CodeContextTest.test_del_with_timer~s���!�Y�_�_�U�L�L�A�A�A����
��������
�
�
�x�
(�
(�	6�B��I�L���g�v�u�5�5�5�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6�	6����	6�	6�	6�	6��
�
�o�s�2�<�'8�'8�9�9�9�9�9s�"B
�
B�Bc��tj���|�|jjd��dS)N�)rr`�reloadrrra�
context_depthrms r�test_reloadzCodeContextTest.test_reload�s8����&�&�(�(�(������.��3�3�3�3�3rc�x�|j}|j}|j}|jr
|��|��|�|j��||jd|jd��||jd|jd��||jd|jd��||j�dd��d��||jj	d	��||j
j�d
d|jj
��dd
��|��|�|j��||jj	d��|�|jj
��d�d�|�d��dD����}|j�d��|��||j�dd��|��|��|��||j�dd��|��dS)NrM�fgrP�bgrOr/�end-1crzHide Code Contextr�rur2r�zShow Code Context�
c3�&K�|]}|dV��
dS)�Nr*)�.0�xs  r�	<genexpr>zACodeContextTest.test_toggle_code_context_event.<locals>.<genexpr>�s&����"G�"G�A�1�Q�4�"G�"G�"G�"G�"G�"Gr�r)rrra�toggle_code_context_eventrR�assertIsNotNonerrS�getrsrrr�r�rwrt�join�get_contextr_)rrxra�toggle�line11_contexts     r�test_toggle_code_context_eventz.CodeContextTest.test_toggle_code_context_event�s'��
�
��
�W���-���:�	��F�H�H�H�	��������R�Z�(�(�(�
��2�:�f��t�y��0�1�1�1�
��2�:�d��T�/��=�>�>�>�
��2�:�d��T�/��=�>�>�>�
��2�:�>�>�%��*�*�B�/�/�/�
��2�:��0�1�1�1�
��4�9�<���W�f�d�g�j�9�9�!�<�g�F�F�F�	��������"�*�%�%�%�
��2�:��0�1�1�1����$�'�*�%�%�%����"G�"G�����1C�1C�A�1F�"G�"G�"G�G�G��
��
�
�b���������
��2�:�>�>�%��*�*�N�;�;�;�	����������
��2�:�>�>�%��*�*�N�;�;�;�;�;rc��|j}|jj}|�t��5|dd���ddd��n#1swxYwY||d��dgdf��||d��dgdf��||d��ddgdf��||d	��gd
�df��||d��gd�df��||dd
���gd�df��||dd���gd�df��||dd���ddgdf��||dd���gd�df��||dd���ddgdf��dS)Nr2r)�stopline��r�r�	class C1:�class���r�r��    def __init__(self, a, b):�def�
)r���r�z    def compare(self):r���r��        if a > b:�ifr�)r�r�r��r�r�z        elif a < b:�elifr�)r�r�r�r�r�r�)�
stopindent)rrrar�r��AssertionError)rrx�gcs   r�test_get_contextz CodeContextTest.test_get_context�s���
�
��
�W�
 ���
�
�~�
.�
.�	�	��B�q�1�����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	��2�2�a�5�5�0�1�1�5�6�6�6�	��2�2�a�5�5�0�1�1�5�6�6�6�	��2�2�a�5�5�0�B�D�EF�H�	I�	I�	I�	��2�2�b�6�6�8�8�8�9:�<�	=�	=�	=�
	��2�2�b�6�6�=�=�=�?@�A�	B�	B�	B�	��2�2�b�1����!I�!I�!I�KL� M�	N�	N�	N�	��2�2�b�1����!I�!I�!I�JK� M�	N�	N�	N�	��2�2�b�1����!B�!G�!I�JK� M�	N�	N�	N�	��2�2�b�Q����#K�#K�#K�LM�"O�	P�	P�	P�	��2�2�b�Q����#D�#I�#K�LM�"O�	P�	P�	P�	P�	Ps�A�A�Ac�F�|j}|j}|js|���|�|�����||jdg��||jd��|j�	d��|���||jdg��||jd��||j�
dd��d��|j�	d��|���||jddg��||jd��||j�
dd��d	��|j�	d��|���||jddg��||jd
��||j�
dd��d	��|j�	d
��|���||jgd���||jd��||j�
dd��d
��|j�	d��|���||jgd���||jd��||j�
dd��d��|���d|_||jgd���||jd��||j�
dd��d��|j�	d��|���||jgd���||jd��||j�
dd��d��dS)Nrpr2r�r/r�rr�r�r�r�)rpr�r�r�z'class C1:
    def __init__(self, a, b):r�)rpr�r�r�r��zFclass C1:
    def compare(self):
        if a > b:
        elif a < b:�r�)rrrarRr�rt�update_code_contextrurvrr_r�r�)rrxras   r�test_update_code_contextz(CodeContextTest.test_update_code_context�s-��
�
��
�W���z�	+��(�(�*�*�*�	
���"�0�0�2�2�3�3�3�
��2�7�'�(�)�)�)�
��2�=�!����	��
�
�a����
��� � � �
��2�7�'�(�)�)�)�
��2�=�!����
��2�:�>�>�%��*�*�B�/�/�/�	��
�
�a����
��� � � �
��2�7�'�)E�F�G�G�G�
��2�=�!����
��2�:�>�>�%��*�*�K�8�8�8�	��
�
�a����
��� � � �
��2�7�'�)E�F�G�G�G�
��2�=�!����
��2�:�>�>�%��*�*�K�8�8�8�	��
�
�a����
��� � � �
��2�7�E�E�E�	F�	F�	F�	��2�=�!����
��2�:�>�>�%��*�*�-L�	M�	M�	M�	��
�
�b����
��� � � �
��2�7�=�=�=�	>�	>�	>�
	��2�=�"����
��2�:�>�>�%��*�*�-B�	C�	C�	C�	��� � � ����
��2�7�=�=�=�	>�	>�	>�
	��2�=�"����
��2�:�>�>�%��*�*�-B�	C�	C�	C�	��
�
�a����
��� � � �
��2�7�E�E�E�	F�	F�	F�	��2�=�!����
��2�:�>�>�%��*�*�,K�L�L�L�L�Lrc�2�|j}|j}|j}|js|���|j�d��|���||jd��|j�	dd��|��||jd��|j�d��|���||jd��|j�	dd��|��||jd	��d|_
|j�d��|���||jd��|j�	dd
��|��||jd	��|j�d��|���|j�dd
d��|j�	dd
��|��||jd
��dS)Nz2.0r�r:z1.5r2z12.0r�z3.0r�r/z5.0�selr�)rrra�
jumptolinerRr�rr_r�rv�mark_setr��tag_add)rrxra�jumps    r�test_jumptolinezCodeContextTest.test_jumptoline.s��
�
��
�W���}���z�	+��(�(�*�*�*�	��
�
�e����
��� � � �
��2�=�!����
�
���H�e�,�,�,������
��2�=�!����	��
�
�f����
��� � � �
��2�=�"����
�
���H�e�,�,�,������
��2�=�!�������
��
�
�f����
��� � � �
��2�=�"����
�
���H�e�,�,�,������
��2�=�!����	��
�
�e����
��� � � �
�
���5�%��/�/�/�
�
���H�e�,�,�,������
��2�=�!�����rr�c�6�|jjr|j���|j���|���|j���|j���|���dSr)rarRr��timer_event�assert_not_called�
assert_called)r�mock_updates  r�test_timer_eventz CodeContextTest.test_timer_eventWs����7�?�	0��G�-�-�/�/�/���������%�%�'�'�'�	
��)�)�+�+�+���������!�!�#�#�#�#�#rc��|j}|j}|jd}d}|�||��|j�|���||_|���|���||jd|��||_|���||jd|��dS)NrM�
TkTextFont)rrrar�assertNotEqualrRr�rZ�update_font)rrxra�	orig_font�	test_fonts     rr�zCodeContextTest.test_fontds���
�
��
�W���G�F�O�	� �	����I�y�1�1�1��:�	+��(�(�*�*�*�&���
������	�$�$�&�&�&�
��2�:�f��y�)�)�)�'���
������
��2�:�f��y�)�)�)�)�)rc����|j�|j�t|j��}ddd�}��fd�}�jr����||_��������||������||��||_����||��dS)Nz#222222z#ffff00rNc�|����jd|d����jd|d��dS)NrOrP)rR)�colorsrarxs ��r�assert_colors_are_equalzFCodeContextTest.test_highlight_colors.<locals>.assert_colors_are_equal�sE����B�r�z�,�'���)=�>�>�>��B�r�z�,�'���)=�>�>�>�>�>r)rrra�dictrSrRr��update_highlight_colors)r�orig_colors�test_colorsr�rarxs    @@r�test_highlight_colorsz%CodeContextTest.test_highlight_colors}s����
�
��
�W���4�-�.�.��%.�i�H�H��	?�	?�	?�	?�	?�	?�
�:�	+��(�(�*�*�*�(���
�"�"�$�$�$�	�$�$�&�&�&����,�,�,�	�"�"�$�$�$����,�,�,�)���
�"�"�$�$�$����,�,�,�,�,rN)r'r(r)�classmethodrCrJrjrnrzr|r�r�r�r�r�r�r
rcrdrr`r�r�r�r*rrr,r,5s<�������/�/��[�/�����[��.�.�.�2%�%�%�&�&�&����:�:�:�4�4�4�"<�"<�"<�H.P�.P�.P�`OM�OM�OM�b'�'�'�R
�Z���{�.�0E�F�F�
$�
$�G�F�
$�*�*�*�2-�-�-�-�-rr,c��eZdZd�Zd�ZdS)�HelperFunctionTextc���tj}d}|D]$\}}|�||��|���%|�|dtjd�����d��dS)N))z    first word)�    �first)z	first word)�	r�)u
  ᧔᧒: )z  u᧔᧒)z	no spaces)r�no)r�rr)z# TEST COMMENTr�)�    (continuation))r�rr�z^(\s*)([^\s]*))�c)r�z(continuation))r�get_spaces_firstwordrr�re�compile)rr��
test_lines�line�expected_outputs     r�test_get_spaces_firstwordz,HelperFunctionText.test_get_spaces_firstword�s����.���
�&0�	9�	9�!�D�/����S�S��Y�Y��8�8�8�8�	
�����1�!�z�*;�<�<�>�>�>�3�	5�	5�	5�	5�	5rc���|j}tj}t���}|||d��tjddf��|||d��d��|||d��tjddf��|||d��d	��|||d
��d��||d��d
��dS)NrrFr2)rr�r�r�z    # Class comment.r�)r�r�r�r�)r�r�r��	if a == b:)r2r�r�)rrr�
get_line_infor;�
splitlines�INFINITY)rrx�gli�liness    r�test_get_line_infoz%HelperFunctionText.test_get_line_info�s���
�
���'���&�&�(�(��	��3�3�u�Q�x�=�=�;�/��U�;�<�<�<�
��3�3�u�Q�x�=�=�3�4�4�4�
��3�3�u�Q�x�=�=�;�/�1G��O�P�P�P�
��3�3�u�Q�x�=�=�E�F�F�F�
��3�3�u�Q�x�=�=�8�9�9�9�
��3�3�~��� 9�:�:�:�:�:rN)r'r(r)r�r�r*rrr�r��s2������5�5�5�&;�;�;�;�;rr��__main__r�)�	verbosity)�__doc__�idlelibrrb�
unittest.mock�test.supportr�tkinterrrrrr	r
r�rr@rArF�IdleUserConfParserr?r;r�TestCaser,r�r'r
r*rr�<module>r�s���!�!���������������!�!�!�!�!�!�3�3�3�3�3�3�3�3�3�3�3�3�3�3�������	�	�	�	��������
�
&��%�F�%�b�)�)�*��*�2�.�.�%�F�%�b�)�)�+�&�+�B�/�/�	�����"%�%�%�%�%�%�%�%�f-�f-�f-�f-�f-�h�'�f-�f-�f-�R%;�%;�%;�%;�%;��*�%;�%;�%;�P�z����H�M�A��������r