Sindbad~EG File Manager
�
&Μg:\��F�dZddlmZddlZddlmZddlmZddlm Z m
Z
ddlmZddl
mZGd �d
ej �ZGd�dej �ZGd
�dej �ZGd�dej �ZGd�dej �ZGd�d�ZGd�d�ZGd�dej �ZGd�d�ZGd�dej �ZGd�dej �ZGd�d ej �Zed!k(rej:d"d"�#�yy)$zTest format, coverage 99%.�)�formatN)�mock)�requires)�Tk�Text)�EditorWindow)�Editorc�6�eZdZdZdZdZdZdZdZd�Z d�Z
d �Zy
)�Is_Get_TestzTest the is_ and get_ functionsz# This is a commentzThis is not a commentz# This is a comment z # This is a commentz This is not a commentc���|jtjd��|jtjd��|jtj|j��y)N�z
)�
assertTrue�ft�is_all_white�assertFalse�test_comment��selfs �:/usr/local/lib/python3.12/idlelib/idle_test/test_format.py�test_is_all_whitezIs_Get_Test.test_is_all_whitesI���������+�,��������5�6��������):�):�;�<�c�L�|j}|tj|j�d�|tj|j�d�|tj|j
�d�|tj|j�d�y)Nr
� )�assertEqualr�
get_indentr�trailingws_comment�leadingws_comment�leadingws_nocomment�r�Equals r�test_get_indentzIs_Get_Test.test_get_indentsq��� � ��
�b�m�m�D�-�-�.��3�
�b�m�m�D�3�3�4�b�9�
�b�m�m�D�2�2�3�V�<�
�b�m�m�D�4�4�5�v�>rc��|j}|tj|j�d�|tj|j�d�|tj|j
�d�|tj|j�d�|tj|j�d�y)N�#� #rr
)rr�get_comment_headerrrrr�test_nocommentrs r�test_get_comment_headerz#Is_Get_Test.test_get_comment_header s���� � ��
�b�#�#�D�$5�$5�6��<�
�b�#�#�D�$;�$;�<�c�B�
�b�#�#�D�$:�$:�;�W�E�
�b�#�#�D�$<�$<�=�v�F�
�b�#�#�D�$7�$7�8�"�=rN)�__name__�
__module__�__qualname__�__doc__rr&rrrrr!r'�rrrrs0��)�(�L�,�N�1��1��5��=�
?�>rrc�2�eZdZdZed��Zd�Zd�Zd�Zy)�FindTestaaTest the find_paragraph function in paragraph module.
Using the runcase() function, find_paragraph() is called with 'mark' set at
multiple indexes before and inside the test paragraph.
It appears that code with the same indentation as a quoted string is grouped
as part of the same paragraph, which is probably incorrect behavior.
c�(�ddlm}|�|_y)Nr)r)�idlelib.idle_test.mock_tkr�text)�clsrs r�
setUpClasszFindTest.setUpClass5s��2��6��rc�X�|j}|jd|�td|�D]k}t|j d|z�jd�d�}d|dz|fD]/}d||fz}|j
tj||�|��1�m|jdd�y) N�1.0�z%d.end�.r�z%d.%d�end)
r1�insert�range�int�index�splitrr�find_paragraph�delete) r�
inserttext�stopline�expectedr1�line�
linelength�col� tempindexs r�runcasezFindTest.runcase:s����y�y�����E�:�&��!�X�&�D��T�Z�Z��4��8�>�>�s�C�A�F�G�J��:�q�=�*�5��#�t�S�k�1� �� � ��!2�!2�4��!C�X�N�6�'�
���E�5�!rc
���d}|j|dddd|ddf�d}|j|d d
dd|dd
f�d}|j|d d
dd|ddf�d}|j|dd
dd|ddf�d}|j|dd
dd|ddf�d}|j|dd
dd|ddf�d}|j|dd
dd|ddf�d}|j|dd
dd|ddf�y)Nz;# Comment block with no blank lines before
# Comment line
�r5�3.0r#r�:zG
# Comment block with whitespace line before and after
# Comment line
��2.0�4.0r6�FzS
# Indented comment block with whitespace before and after
# Comment line
r$�Rz
# Single line comment
�z4
# Single line comment with leading whitespace
�3z0
# Comment immediately followed by code
x = 42
�(z=
# Indented comment immediately followed by code
x = 42
�5z=
# Comment immediately followed by indented code
x = 42
�1�rH)r�comments r�test_find_commentzFindTest.test_find_commentGsZ��
� �
���W�a�%���W�Q�r�]�!C�D�
� �
���W�a�%���W�Q�r�]�!C�D�
� �
���W�a�%�����2��!G�H�
� �
���W�a�%���W�Q�r�]�!C�D�
� �
���W�a�%�����2��!G�H�
� �
���W�a�%���W�Q�r�]�!C�D�
� �
���W�a�%�����2��!G�H�
� �
���W�a�%���W�Q�r�]�!C�Drc
��d}|j|dddd|ddf�d}|j|d d
dd|dd
f�d}|j|d d
dd|ddf�d}|j|dd
dd|ddf�d}|j|dd
dd|ddf�y)Nz6"""String with no blank lines before
String line
"""
rMr5rOr
rrUzC
"""String with whitespace line before and after
String line.
"""
�rNz5.0r6�BzV
"""Indented string with whitespace before and after
Comment string.
"""
r�Uz
"""Single line string."""
rJrK�z8
"""Single line string with leading whitespace."""
�7rW)r�
teststrings r�test_find_paragraphzFindTest.test_find_paragraph}s���
� �
���Z��U�E�2�z�!�B�7G�$H�I�
� �
���Z��U�E�2�z�!�B�7G�$H�I�
� �
���Z��U�E�6�:�a��;K�$L�M�
� �
���Z��U�E�2�z�!�B�7G�$H�I�
� �
���Z��U�E�6�:�a��;K�$L�MrN) r(r)r*r+�classmethodr3rHrYrar,rrr.r.+s-�������"�4E�l"Nrr.c��eZdZdZd�Zy)�ReformatFunctionTestz?Test the reformat_paragraph function without the editor window.c���|j}tj}d}||dd�d�||dd�d�|||d�d�|||d�d�|||d �d
�|||d�d
�|||d�d�d
}|||d�d�|||d�d�|||d �d�|||d�d�|||d�d
�y)Nz
O hello world� r6zHello world�zHello worldz
O
hello
world��z
O hello
world��
z
O hello worldz
O
hello
worldz
O hello
world)rr�reformat_paragraph)rr �reform�hws r�test_reformat_paragraphz,ReformatFunctionTest.test_reformat_paragraph�s���� � ���&�&��
��
�f�S�!�n�c�"�
�f�%�r�*�N�;� �f�R��m�.�/�
�f�R��m�.�/�
�f�R��m�-�.�
�f�R��n�.�/�
�f�R��n�o�.���
�f�R��m�0�1�
�f�R��m�0�1�
�f�R��m�/�0�
�f�R��n�0�1�
�f�R��n�/�0rN)r(r)r*r+ror,rrrdrd�s
��I�1rrdc��eZdZdZd�Zy)�ReformatCommentTestz=Test the reformat_comment function without the editor window.c��|j}d}tj|dd�}d}|||�d}tj|dd�}d}|||�y)Nzu """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""rPrzy """this is a test of a reformat for a triple quoted string will it
reformat to less than 70 characters for me?"""zm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?r#zo# this is a test of a reformat for a triple quoted string will it
# reformat to less than 70 characters for me?)rr�reformat_comment)rr �test_string�resultrCrs r�test_reformat_commentz)ReformatCommentTest.test_reformat_comment�s{��� � ��
I� ��$�$�[�"�f�=��
D� � �f�h��
=� ��$�$�\�2�s�;��
<� � �f�h�rN)r(r)r*r+rvr,rrrqrq�s
��G� rrqc��eZdZd�Zy)�FormatClassTestc��tjd�}|j|jd�|j �|j|jd�y)N�editor)r�FormatParagraphr�editwin�close)r�instances r�test_init_closezFormatClassTest.test_init_close�sH���%�%�h�/������)�)�8�4���������)�)�4�0rN)r(r)r*rr,rrrxrx�s��1rrxc�$�eZdZd�Zd�Zd�Zd�Zy)�TextWrapperc�&�t|��|_y)N)�master)rr1)rr�s r�__init__zTextWrapper.__init__�s����'�� rc�.�t|j|�S�N)�getattrr1)r�names r�__getattr__zTextWrapper.__getattr__�s���t�y�y�$�'�'rc��yr�r,rs r�undo_block_startzTextWrapper.undo_block_start�s��rc��yr�r,rs r�undo_block_stopzTextWrapper.undo_block_stop�s��trN)r(r)r*r�r�r�r�r,rrr�r��s��(�(�$�#rr�c�*�eZdZd�Zej
Zy)r c�$�t|�|_yr�)r�r1)r�roots rr�zEditor.__init__�s����%�� rN)r(r)r*r�r�get_selection_indicesr,rrr r �s��&�(�?�?�rr c�T�eZdZdZdZdZdZed��Zed��Z d�Z
d�Zd �Zd
�Z
y)�FormatEventTestz�Test the formatting of text inside a Text widget.
This is done with FormatParagraph.format.paragraph_event,
which calls functions in the module as appropriate.
zv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''
a '''The first line is under the max width.
The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
'''
a,# The first line is under the max width.
# The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
# Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
# The fourth line is short like the first line.c��td�t�|_|jj�t |j��}|j
j
|_t
j|�j|_ y)N�gui)r�)
rrr��withdrawr r1rr{�format_paragraph_event� formatter)r2rzs rr3zFormatEventTest.setUpClasssY������4����������S�X�X�&���;�;�#�#����*�*�6�2�I�I��
rc�x�|`|`|jj�|jj �|`yr�)r1r�r��update_idletasks�destroy�r2s r�
tearDownClasszFormatEventTest.tearDownClasss0���H�c�m����!�!�#��������Hrc���|jjdd�|jd�|j|jj dd�d�|jjdd�y)Nr5zShort line
�Dummyr:r9)r1r:r�r�getr@rs r�test_short_linezFormatEventTest.test_short_line sU��� � �����/����w����������u�h�7��I�� � �����&rc��|j}|jd|j�|jdd�|j dd��|jdd�}d}|j
||�|jdd�|jd|j�|jdd d
�|j dd��|jdd�}d}|j
||�|jdd�y)Nr5r:�ParameterDoesNothingrP��limitzz '''this is a test of a reformat for a triple quoted string will it
reformat to less than 70 characters for me?'''
r9�selz1.11z1.endzv '''this is a test of a reformat for a triple quoted string will it reformat
to less than 70 characters for me?''') r1r:rt�mark_setr�r�rr@�tag_add�rr1rurCs r�test_long_linezFormatEventTest.test_long_line&s����y�y��
���E�4�+�+�,��
�
�h��&����-�R��8����%��*��7� �
�����*����E�5�!�
���E�4�+�+�,����U�F�G�,����-�R��8����%��*��)� �
�����*����E�5�!rc��|j}|jd|j�|jddd�|j dd��|jdd�}d }|j
||�|jdd
�y)Nr5r�rNrOr�rPr�r:z� The second line's length is way over the max width. It goes on and
on until it is over 100 characters long. Same thing with the third
line. It is also way over the max width, but FormatParagraph will
fix it.
r9)r1r:�multiline_test_stringr�r�r�rr@r�s r�test_multiple_linesz#FormatEventTest.test_multiple_linesAsz���y�y�����E�4�5�5�6����U�E�5�)����-�R��8����%��*��� �
�����*����E�5�!rc���|j}|jd|j�|jdd��|j dd�}d}|j||�|j
dd�|jd|j�|jdd d
�|jdd��|j dd�}d}|j||�|j
dd�y)Nr5r�rPr�r:a/# The first line is under the max width. The second line's length is
# way over the max width. It goes on and on until it is over 100
# characters long. Same thing with the third line. It is also way over
# the max width, but FormatParagraph will fix it. The fourth line is
# short like the first line.
r9r�rNrKz�# The first line is under the max width.
# The second line's length is way over the max width. It goes on and
# on until it is over 100 characters long.
)r1r:�multiline_test_commentr�r�rr@r�r�s r�test_comment_blockz"FormatEventTest.test_comment_blockPs����y�y��
���E�4�6�6�7����-�R��8����%��*��!� �
�����*����E�5�!�
���E�4�6�6�7����U�E�5�)����-�R��8����%��*��/� �
�����*����E�5�!rN)r(r)r*r+rtr�r�rbr3r�r�r�r�r�r,rrr�r��sc��� "��
�� :���J��J�����'�"�6
"�"rr�c�B�eZdZd�Zej
ZejZy)�DummyEditwinc�X�||_||_d|_d|_d|_d|_y)NrMFT)r�r1�indentwidth�tabwidth�usetabs�context_use_ps1)rr�r1s rr�zDummyEditwin.__init__}s.���� ��� ������
����#��rN)r(r)r*r�r�_make_blanksr�r,rrr�r�|s ��$� �,�,�L�(�>�>�rr�c�T�eZdZed��Zed��Zd�Zd�ZdZd�Z d�Z
d�Zd �Zd
�Z
d�Zej j#ej&d�d
��Zej j#ej&d�d��Zej j#ed�d��Zy)�FormatRegionTestc��td�t�|_|jj�t |j�|_t
j�|j
_t
j�|j
_ t|j|j
�|_tj|j�|_y)Nr�)rrr�r�rr1r�Mockr�r�r�rzr�FormatRegionr�r�s rr3zFormatRegionTest.setUpClass�s������4�������������>���$(�I�I�K����!�#'�9�9�;���� �!�#�(�(�C�H�H�5��
�����
�
�3��
rc�|�|`|`|`|jj �|jj�|`yr�)r1r�rzr�r�r�r�s rr�zFormatRegionTest.tearDownClass��4���H�c�m�S�Z����!�!�#��������Hrc�P�|jjd|j�y)Nr5)r1r:�code_samplers r�setUpzFormatRegionTest.setUp�s��� � ����� 0� 0�1rc�<�|jjdd�y)Nr5r9�r1r@rs r�tearDownzFormatRegionTest.tearDown�s��� � �����&ra# WS line needed for test.
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��|jj}|j}|j}|j ddd�gd�}||�dddj|�|f�|j
ddd�||�dd dd
d
gf�y)Nr��7.0�10.0)r
z def compare(self):z if a > b:r
�
r5r9z15.0z16.0r
)r��
get_regionr1rr��join�
tag_remove)rr�r1�eq�expected_liness r�test_get_regionz FormatRegionTest.test_get_region�s����n�n�'�'���y�y��
�
�
��
���U�E�6�*��� �3�5�5�&�$�)�)�N�";�^�L�M�
����u�e�,�
�3�5�6�6�4�"�b��2�3rc��|jj}|j}|j}|j}tj�|_|jj�d}|jj�d}|jddd�|jj�\}}} }
|||| |
�|jj�||jdd�| �||jdd�| �|jddd �d
}|jd�}|dd
| |�||jdd�|�||jdd�|�||jdd�|�||jdd�|�|jddd �||_y)Nr[� r�z6.0z11.0z sel.firstzsel.lastr5r9zadded line 1
r�r�r�z7.0-1cz12.0-1c)r��
set_regionr1r�bellrr�r��
splitlinesr�r��assert_called_oncer�r�r>)
r�set_r1r�� save_bell�line6�line10�head�tail�chars�lines� newstring�newliness
r�test_set_regionz FormatRegionTest.test_set_region�s����~�~�(�(���y�y��
�
�
���I�I� ��I�I�K�� �� � �+�+�-�a�0���!�!�,�,�.�q�1�����U�E�6�*�#'�>�>�#<�#<�#>� ��d�E�5�
�T�4���&�� � �$�$�&�
�4�8�8�E�6�"�E�*�
�4�8�8�K��,�e�4�����u�e�,�+� ��?�?�4�(���U�F�E�8�,�
�4�8�8�K��,�i�8�
�4�8�8�E�6�"�I�.�
�4�8�8�E�8�$�e�,�
�4�8�8�F�I�&��/�����u�e�,��� rc���|jj}|j}|j}|j ddd�|�||jdd�d�y)Nr�r�r�z2
def compare(self):
if a > b:
)r��indent_region_eventr1rr�r�)r�indentr1r�s r�test_indent_region_eventz)FormatRegionTest.test_indent_region_event�sP�����3�3���y�y��
�
�
�����U�E�6�*���
�4�8�8�E�6�"�%\�^rc���|jj}|j}|j}|j ddd�|�||jdd�d�y)Nr�r�r�z"
def compare(self):
if a > b:
)r��dedent_region_eventr1rr�r�)r�dedentr1r�s r�test_dedent_region_eventz)FormatRegionTest.test_dedent_region_event�sP�����3�3���y�y��
�
�
�����U�E�6�*���
�4�8�8�E�6�"�%L�Nrc���|jj}|j}|j}|j ddd�|�||jdd�d�y)Nr�r�r�z0##
## def compare(self):
## if a > b:
)r��comment_region_eventr1rr�r�)rrXr1r�s r�test_comment_region_eventz*FormatRegionTest.test_comment_region_event�sP���.�.�5�5���y�y��
�
�
�����U�E�6�*�� �
�4�8�8�E�6�"�%Z�\rc��|jj}|jj}|j}|j}|jddd�|�|�||j
dd�d�|jddd�|jddd�|�||j
dd �d
�|jjdddddg�|�||j
dd �d
�y)Nr�r�r�z*
def compare(self):
if a > b:
r5r9rKrOz3.endz # Class comment.r
z# Class comment.z Class comment.) r�r��uncomment_region_eventr1rr�r�r�r�)rrX� uncommentr1r�s r�test_uncomment_region_eventz,FormatRegionTest.test_uncomment_region_events����.�.�5�5���N�N�9�9� ��y�y��
�
�
�����U�E�6�*�� ���
�4�8�8�E�6�"�%T�V�
����u�e�,����U�E�5�)���
�4�8�8�E�7�#�&<�>����!�!�%���5G��4L�M���
�4�8�8�E�7�#�&7�9r�_asktabwidthc�,�|jj}|j}|j}|j ddd�d|_|j
|��d|_|j|��||jdd�d�y)Nr�r�r�rJz$
def compare(self):
if a > b:
) r��tabify_region_eventr1rr��return_value�assertIsNone�assertIsNotNoner�)rr��tabifyr1r�s r�test_tabify_region_eventz)FormatRegionTest.test_tabify_region_events{�����3�3���y�y��
�
�
�����U�E�6�*�$(��!����&�(�#�$%��!����V�X�&�
�4�8�8�E�6�"�%Q�Src�n�|jj}|j}|j}|j ddd�d|_|j
|��d|_|jj�d|_|j|��||jdd�d�y)Nr�r�r�r8rJz0
def compare(self):
if a > b:
)
r��untabify_region_eventr1rr�r�r�r�r�r�)rr��untabifyr1r�s r�test_untabify_region_eventz+FormatRegionTest.test_untabify_region_event)s����>�>�7�7���y�y��
�
�
�����U�E�6�*�$(��!����(�*�%�$%��!����*�*�,�$%��!����X�Z�(�
�4�8�8�E�6�"�%Z�\r�
askintegerc�l�|jj}d|_|j|�d�y)N�
)r�r�r�r)rr��asks r�test_ask_tabwidthz"FormatRegionTest.test_ask_tabwidth:s+���n�n�)�)��"$�
��������#rN)r(r)r*rbr3r�r�r�r�r�r�r�r�r�r�r�patch�objectrr�r�r�rr,rrr�r��s����4��4�����2�'��K�"4�"!�F_�O�]�:�*
�Z�Z���r����7�T�8�T�
�Z�Z���r����7�]�8�]�
�Z�Z���r�<�(�$�)�$rr�c��eZdZejjed�d��Zejjed�d��Zy)�IndentsTest�askyesnoc�x�tdd�}tj|�}d|_|j d�|j|jd�|j|jd�|j d�|j|jd�|j|jd�y)NT�F)r�r�Indentsr��toggle_tabs_eventrr�r�)rrrz�indentss r�test_toggle_tabszIndentsTest.test_toggle_tabsCs����d�D�)���*�*�V�$�� $����!�!�$�'��������.�����+�+�Q�/��!�!�$�'��������/�����+�+�Q�/rr�c��tdd�}tj|�}d|_|j d�|j|jd�d|_|j d�|j|jd�d|_d|_|j d�|j|jd�y)NrMrJr[T)r�rrr��change_indentwidth_eventrr�r�)rr�rzr
s r�test_change_indentwidthz#IndentsTest.test_change_indentwidthQs����d�D�)���*�*�V�$��"&�
���(�(��.�����+�+�Q�/�"#�
���(�(��.�����+�+�Q�/�"#�
������(�(��.�����+�+�Q�/rN) r(r)r*rrrrrrr,rrrrAsJ�� �Z�Z���r�:�&�0�'�0�
�Z�Z���r�<�(�0�)�0rrc�>�eZdZed��Zed��Zd�Zd�Zd�Zy)�
RstripTestc�2�td�t�|_|jj�t |j�|_t
|j
��|_tj|j�j|_
y)Nr�)r1)rrr�r�rr1�
MockEditorrzr�Rstrip� do_rstripr�s rr3zRstripTest.setUpClassfs[������4�������������>����S�X�X�.��
�� � �#�*�*�-�7�7��
rc�|�|`|`|`|jj �|jj�|`yr�)r1rrzr�r�r�r�s rr�zRstripTest.tearDownClassor�rc�<�|jjdd�y)Nr5�end-1cr�rs rr�zRstripTest.tearDownvs��� � �����)rc��d}d}|jjd|�|j�|j|jj dd�|�y)Nz�Line with an ending tab
Line ending in 5 spaces
Linewithnospaces
indented line
indented line with trailing space
zyLine with an ending tab
Line ending in 5 spaces
Linewithnospaces
indented line
indented line with trailing space
r5r:)r1r:rrr�)r�original�strippeds r�test_rstrip_lineszRstripTest.test_rstrip_linesysU��
� �
6� �
� � �����)�������������u�h�7��Brc��|j}dD]a}|j|��5|jd|�|j�|j |jdd�d�ddd��cdD]s}|j|��5|j
dd�|jd|�|j�|j |jdd�d�ddd��uy#1swY��xYw#1swY��xYw)N)r
r�z
)�coder5rr
)�a
za
za
r)r1�subTestr:rrr�r@)rr1rs r�test_rstrip_endzRstripTest.test_rstrip_end�s����y�y��(�D����4��(����E�4�(���� �� � ����%��!9�2�>�)�(�)�
0�D����4��(����E�8�,����E�4�(���� �� � ����%��!9�5�A� )�(�0� )�(��
)�(�s�AC,�
AC8�,C5 �8D N) r(r)r*rbr3r�r�rr r,rrrrds9���8��8�����*�C�&Brr�__main__r8)� verbosity�exit)r+�idlelibrr�unittestr�test.supportr�tkinterrr�idlelib.editorr�idlelib.idle_test.mock_idler r�TestCaserr.rdrqrxr�r�r�r�rrr(�mainr,rr�<module>r,s
��� ���!��'�<�>�(�#�#�>�>tN�x� � �tN�n1�8�,�,�1�4 �(�+�+� �41�h�'�'�1�&$�$�@�@�
t"�h�'�'�t"�L
?�
?�u$�x�(�(�u$�p 0�(�#�#� 0�F4B��"�"�4B�n�z���H�M�M�A�A�&�r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists