Sindbad~EG File Manager
�
&Μg:\��D� ddlmZddlZddlmZddlmZddlmZm Z ddl
mZddlm
ZGd�d ej�ZGd
�dej�ZGd�d
ej�ZGd�dej�ZGd�dej�ZGd�d�ZGd�d�Z
Gd�dej�ZGd�d�ZGd�dej�ZGd�dej�ZGd�dej�Zed k(rej8d!d!�"�yy)#�)�formatN)�mock)�requires)�Tk�Text)�EditorWindow)�Editorc�4�eZdZ dZdZdZdZdZd�Zd�Z d�Z
y )
�Is_Get_Testz# 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__rr&rrrrr!r'�rrrrs0��)�(�L�,�N�1��1��5��=�
?�>rrc�0�eZdZ ed��Zd�Zd�Zd�Zy)�FindTestc�(�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)
r0�insert�range�int�index�splitrr�find_paragraph�delete) r�
inserttext�stopline�expectedr0�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
�r4�3.0r#r�:zG
# Comment block with whitespace line before and after
# Comment line
��2.0�4.0r5�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�rG)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
"""
rLr4rNr
rrTzC
"""String with whitespace line before and after
String line.
"""
�rMz5.0r5�BzV
"""Indented string with whitespace before and after
Comment string.
"""
r�Uz
"""Single line string."""
rIrJ�z8
"""Single line string with leading whitespace."""
�7rV)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*�classmethodr2rGrXr`r+rrr-r-+s-�������"�4E�l"Nrr-c��eZdZ d�Zy)�ReformatFunctionTestc���|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� r5zHello 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*rnr+rrrcrc�s
��I�1rrcc��eZdZ d�Zy)�ReformatCommentTestc��|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?"""rOrzy """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�resultrBrs r�test_reformat_commentz)ReformatCommentTest.test_reformat_comment�s{��� � ��
I� ��$�$�[�"�f�=��
D� � �f�h��
=� ��$�$�\�2�s�;��
<� � �f�h�rN)r(r)r*rur+rrrprp�s
��G� rrpc��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*r~r+rrrwrw�s��1rrwc�$�eZdZd�Zd�Zd�Zd�Zy)�TextWrapperc�&�t|��|_y)N)�master)rr0)rr�s r�__init__zTextWrapper.__init__�s����'�� rc�.�t|j|�S�N)�getattrr0)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�r0)r�roots rr�zEditor.__init__�s����%�� rN)r(r)r*r�r�get_selection_indicesr+rrr r �s��&�(�?�?�rr c�R�eZdZ dZdZdZed��Zed��Zd�Z d�Z
d�Zd �Zy
)�FormatEventTestzv '''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 r0rrz�format_paragraph_event� formatter)r1rys rr2zFormatEventTest.setUpClasssY������4����������S�X�X�&���;�;�#�#����*�*�6�2�I�I��
rc�x�|`|`|jj�|jj �|`yr�)r0r�r��update_idletasks�destroy�r1s r�
tearDownClasszFormatEventTest.tearDownClasss0���H�c�m����!�!�#��������Hrc���|jjdd�|jd�|j|jj dd�d�|jjdd�y)Nr4zShort line
�Dummyr9r8)r0r9r�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)Nr4r9�ParameterDoesNothingrO��limitzz '''this is a test of a reformat for a triple quoted string will it
reformat to less than 70 characters for me?'''
r8�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?''') r0r9rs�mark_setr�r�rr?�tag_add�rr0rtrBs 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)Nr4r�rMrNr�rOr�r9z� 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.
r8)r0r9�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)Nr4r�rOr�r9a/# 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.
r8r�rMrJz�# 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.
)r0r9�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*rsr�r�rar2r�r�r�r�r�r+rrr�r��sc��� "��
�� :���J��J�����'�"�6
"�"rr�c�B�eZdZd�Zej
ZejZy)�DummyEditwinc�X�||_||_d|_d|_d|_d|_y)NrLFT)r�r0�indentwidth�tabwidth�usetabs�context_use_ps1)rr�r0s 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�rr0r�Mockr�r�r�ryr�FormatRegionr�r�s rr2zFormatRegionTest.setUpClass�s������4�������������>���$(�I�I�K����!�#'�9�9�;���� �!�#�(�(�C�H�H�5��
�����
�
�3��
rc�|�|`|`|`|jj �|jj�|`yr�)r0r�ryr�r�r�r�s rr�zFormatRegionTest.tearDownClass��4���H�c�m�S�Z����!�!�#��������Hrc�P�|jjd|j�y)Nr4)r0r9�code_samplers r�setUpzFormatRegionTest.setUp�s��� � ����� 0� 0�1rc�<�|jjdd�y)Nr4r8�r0r?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
�
r4r8z15.0z16.0r
)r��
get_regionr0rr��join�
tag_remove)rr�r0�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)NrZ� r�z6.0z11.0z sel.firstzsel.lastr4r8zadded line 1
r�r�r�z7.0-1cz12.0-1c)r��
set_regionr0r�bellrr�r��
splitlinesr�r��assert_called_oncer�r�r=)
r�set_r0r�� 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_eventr0rr�r�)r�indentr0r�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_eventr0rr�r�)r�dedentr0r�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_eventr0rr�r�)rrWr0r�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:
r4r8rJrNz3.endz # Class comment.r
z# Class comment.z Class comment.) r�r��uncomment_region_eventr0rr�r�r�r�)rrW� uncommentr0r�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�rIz$
def compare(self):
if a > b:
) r��tabify_region_eventr0rr��return_value�assertIsNone�assertIsNotNoner�)rr��tabifyr0r�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�r7rIz0
def compare(self):
if a > b:
)
r��untabify_region_eventr0rr�r�r�r�r�r�)rr��untabifyr0r�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*rar2r�r�r�r�r�r�r�r�r�r�r�patch�objectrr�r�r�r�r+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�)rrry�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)NrLrIrZT)r�rrr��change_indentwidth_eventrr�r�)rr�ryr s r�test_change_indentwidthz#IndentsTest.test_change_indentwidthQs����d�D�)���*�*�V�$��"&�
���(�(��.�����+�+�Q�/�"#�
���(�(��.�����+�+�Q�/�"#�
������(�(��.�����+�+�Q�/rN) r(r)r*rrrrr
r
r+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�)r0)rrr�r�rr0�
MockEditorryr�Rstrip� do_rstripr�s rr2zRstripTest.setUpClassfs[������4�������������>����S�X�X�.��
�� � �#�*�*�-�7�7��
rc�|�|`|`|`|jj �|jj�|`yr�)r0rryr�r�r�r�s rr�zRstripTest.tearDownClassor�rc�<�|jjdd�y)Nr4�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
r4r9)r0r9rrr�)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
)�coder4rr
)�a
za
za
r)r0�subTestr9rrr�r?)rr0rs 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*rar2r�r�rrr+rrrrds9���8��8�����*�C�&Brr�__main__r7)� verbosity�exit)�idlelibrr�unittestr�test.supportr�tkinterrr�idlelib.editorr�idlelib.idle_test.mock_idler r�TestCaserr-rcrprwr�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