Sindbad~EG File Manager
�
&Μg^<���dZddlmZddlZddlmZddlmZmZddl Z ddlm
Z
ddlmZGd�d ej�ZGd
�dej�ZGd�d
ej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd�dej�ZGd �d!ej�ZGd"�d#ej�ZGd$�d%ej�Zed&k(rej<d'd(�)�yy)*a�Test query, coverage 93%.
Non-gui tests for Query, SectionName, ModuleName, and HelpSource use
dummy versions that extract the non-gui methods and add other needed
attributes. GUI tests create an instance of each class and simulate
entries and button clicks. Subclass tests only target the new code in
the subclass definition.
The appearance of the widgets is checked by the Query and
HelpSource htests. These are run by running query.py.
�)�queryN��requires)�Tk�END)�mock)�Varc�B�eZdZdZGd�d�Zd�Zd�Zd�Zd�Zd�Z y )
� QueryTestzTest Query base class.c��eZdZejj
ZejjZejjZd�Zd�Z d�Z
y)�QueryTest.Dummy_Queryc�T�t|��|_ddi|_d|_d|_y)N��value�text�F)r �entry�entry_error�result� destroyed��self�dummy_entrys �9/usr/local/lib/python3.12/idlelib/idle_test/test_query.py�__init__zQueryTest.Dummy_Query.__init__!s(���;�/�D�J� &��|�D���D�K�"�D�N�c�"�||jd<y�Nr�r�r�messages r� showerrorzQueryTest.Dummy_Query.showerror&���'.�D���V�$rc��d|_y�NT)r�rs r�destroyzQueryTest.Dummy_Query.destroy(s ��!�D�NrN)�__name__�
__module__�__qualname__r�Query�entry_ok�ok�cancelrr"r'�rr�Dummy_Queryr
s<���;�;�'�'��
�[�[�^�^�����#�#�� #�
/� "rr0c���|jd�}|j|j�d�|j|j|jfd�|jd|jd�y)N� �NFz
blank liner)r0�assertEqualr,rr�assertInr�r�dialogs r�test_entry_ok_blankzQueryTest.test_entry_ok_blank+sa���!�!�#�&��������*�D�1����&�-�-��)9�)9�:�M�J��
�
�l�F�$6�$6�v�$>�?rc���|jd�}|j}||j�d�||j|jfd�||j
dd�y)N� good �goodr3rr)r0r4r,rrr)rr7�Equals r�test_entry_ok_goodzQueryTest.test_entry_ok_good1s\���!�!�)�,��� � ��
�f�o�o���(�
�v�}�}�f�.�.�/��?�
�f� � ��(�"�-rc�r�|jd�}tj�|j_|j|j
�d�|j|jjj�|j`|j|j|jfd�y)Nrr3)r0r�Mockr� focus_setr4r-�
assertTrue�calledrrr6s r�
test_ok_blankzQueryTest.test_ok_blank8s���!�!�"�%��!%���������������d�+�������.�.�5�5�6��L�L�"����&�-�-��)9�)9�:�M�Jrc��|jd�}|j|j�d�|j|j|jfd�y)Nr;)r;T)r0r4r-rrr6s r�test_ok_goodzQueryTest.test_ok_good@sG���!�!�&�)���������d�+����&�-�-��)9�)9�:�N�Krc��|jd�}|j|j�d�|j|j|jfd�y)Nzdoes not matterr%)r0r4r.rrr6s r�test_cancelzQueryTest.test_cancelEsH���!�!�"3�4���������$�/����&�-�-��)9�)9�:�L�IrN)
r(r)r*�__doc__r0r8r=rCrErGr/rrrrs,���"�"� @�.�K�L�
Jrrc�<�eZdZdZGd�d�Zd�Zd�Zd�Zd�Zy) �SectionNameTestz#Test SectionName subclass of Query.c�J�eZdZejj
ZdgZd�Zd�Zy)�!SectionNameTest.Dummy_SectionName�usedc�8�t|��|_ddi|_y�Nrrr�r rrrs rrz*SectionNameTest.Dummy_SectionName.__init__Q����;�/�D�J� &��|�D�rc�"�||jd<yrrr s rr"z+SectionNameTest.Dummy_SectionName.showerrorTr#rN) r(r)r*r�SectionNamer,�
used_namesrr"r/rr�Dummy_SectionNamerLNs$���$�$�-�-���X�
� ,� /rrUc��|jd�}|j|j�d�|jd|jd�y�Nr2zno namer�rUr4r,r5rr6s r�test_blank_section_namez'SectionNameTest.test_blank_section_nameWsB���'�'��,��������*�D�1��
�
�i��!3�!3�F�!;�<rc��|jd�}|j|j�d�|jd|jd�y)NrM�userrXr6s r�test_used_section_namez&SectionNameTest.test_used_section_name\sB���'�'��/��������*�D�1��
�
�e�V�/�/��7�8rc��|jd�}|j|j�d�|jd|jd�y)N� goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30rrXr6s r�test_long_section_namez&SectionNameTest.test_long_section_nameasC���'�'��1��������*�D�1��
�
�&��(:�(:�6�(B�Crc��|jd�}|j|j�d�|j|jdd�y)Nr:r;rr)rUr4r,rr6s r�test_good_section_namez&SectionNameTest.test_good_section_namefsD���'�'� �2��������*�F�3�����+�+�F�3�R�8rN) r(r)r*rHrUrYr\r_rar/rrrJrJKs$��)�/�/�=�
9�
D�
9rrJc�<�eZdZdZGd�d�Zd�Zd�Zd�Zd�Zy) �ModuleNameTestz"Test ModuleName subclass of Query.c�H�eZdZejj
ZdZd�Zd�Zy)�ModuleNameTest.Dummy_ModuleNamerc�8�t|��|_ddi|_yrOrPrs rrz(ModuleNameTest.Dummy_ModuleName.__init__rrQrc�"�||jd<yrrr s rr"z)ModuleNameTest.Dummy_ModuleName.showerrorur#rN) r(r)r*r�
ModuleNamer,�text0rr"r/rr�Dummy_ModuleNamereos"���#�#�,�,���� ,� /rrjc��|jd�}|j|j�d�|jd|jd�yrW�rjr4r,r5rr6s r�test_blank_module_namez%ModuleNameTest.test_blank_module_namexsB���&�&�s�+��������*�D�1��
�
�i��!3�!3�F�!;�<rc��|jd�}|j|j�d�|jd|jd�y)N� __name_xyz123_should_not_exist__z not foundrrlr6s r�test_bogus_module_namez%ModuleNameTest.test_bogus_module_name}sC���&�&�'I�J��������*�D�1��
�
�k�6�#5�#5�f�#=�>rc��|jd�}|j|j�d�|jd|jd�y)N� itertoolszsource-basedrrlr6s r�test_c_source_namez!ModuleNameTest.test_c_source_name�sB���&�&�{�3��������*�D�1��
�
�n�f�&8�&8��&@�Arc�|�|jd�}|j|j�jd��|j |j
dd�|jd�}|j|j�jd��|j |j
dd�y)N�idlelib�__init__.pyrrzidlelib.idlezidle.py)rjrAr,�endswithr4rr6s r�test_good_module_namez$ModuleNameTest.test_good_module_name�s����&�&�y�1��������)�2�2�=�A�B�����+�+�F�3�R�8��&�&�~�6��������)�2�2�9�=�>�����+�+�F�3�R�8rN) r(r)r*rHrjrmrprsrxr/rrrcrcls$��(�/�/�=�
?�
B�
9rrcc�6�eZdZdZGd�d�Zd�Zd�Zd�Zy)�GotoTestzTest Goto subclass of Query.c�D�eZdZejj
Zd�Zd�Zy)�GotoTest.Dummy_ModuleNamec�8�t|��|_ddi|_yrOrPrs rrz"GotoTest.Dummy_ModuleName.__init__�rQrc�"�||jd<yrrr s rr"z#GotoTest.Dummy_ModuleName.showerror�r#rN)r(r)r*r�Gotor,rr"r/rrrjr|�s���:�:�&�&�� ,� /rrjc��|jd�}|j|j�d�|jd|jd�y)N�aznot a base 10 integerrrlr6s r�test_bogus_gotozGotoTest.test_bogus_goto�sC���&�&�s�+��������*�D�1��
�
�-�v�/A�/A�&�/I�Jrc��|jd�}|j|j�d�|jd|jd�y)N�0znot a positive integerrrlr6s r�
test_bad_gotozGotoTest.test_bad_goto�sC���&�&�s�+��������*�D�1��
�
�.��0B�0B�6�0J�Krc��|jd�}|j|j�d�|j|jdd�y)N�1�rr)rjr4r,rr6s r�test_good_gotozGotoTest.test_good_goto�sD���&�&�s�+��������*�A�.�����+�+�F�3�R�8rN)r(r)r*rHrjr�r�r�r/rrrzrz�s ��"�/�/�K�
L�
9rrzc�*�eZdZdZGd�d�Zd�Zy)�HelpsourceBrowsefileTestz8Test browse_file method of ModuleName subclass of Query.c�F�eZdZejj
Ze�Zy)�)HelpsourceBrowsefileTest.Dummy_HelpSourceN)r(r)r*r�
HelpSource�browse_filer �pathvarr/rr�Dummy_HelpSourcer��s���&�&�2�2���%�rr�c�t�|j�}dd�dfdd�tfdd�dfdd�tffD]{\}}}|j�5|jj |�||_|j
�|j|jj�|�ddd��}y#1swY��xYw)Nrc��y�Nrr/�r��b�cs r�<lambda>zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>�s��"rc��tS�N��__file__r�s rr�zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>�s��8r�htestc��yr�r/r�s rr�zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>�s��rrc��tSr�r�r�s rr�zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>�s��r) r�r��subTestr��set�askfilenamer�r4�get)rr7�path�funcrs r�test_file_replaces_pathz0HelpsourceBrowsefileTest.test_file_replaces_path�s����&�&�(���_�b�)��+�X�6��/�7�3��0�(�;� #=��D�$��
�������"�"�4�(�%)��"��"�"�$�� � ����!3�!3�!5�v�>� ��#=�
��s
�AB.�.B7 N)r(r)r*rHr�r�r/rrr�r��s��>���?rr�c�d�eZdZdZGd�d�ZejZed��Z d�Z
d�Zd�Zd�Z
y )
�HelpsourcePathokTestz4Test path_ok method of HelpSource subclass of Query.c�F�eZdZejj
Zd�Zdd�Zy)�%HelpsourcePathokTest.Dummy_HelpSourcec�8�t|��|_ddi|_yrO)r r��
path_error)r�
dummy_paths rrz.HelpsourcePathokTest.Dummy_HelpSource.__init__�s���*�-�D�I�%�r�l�D�OrNc�"�||jd<yr)r�)rr!�widgets rr"z/HelpsourcePathokTest.Dummy_HelpSource.showerror�s��&-�D�O�O�F�#rr�)r(r)r*rr��path_okrr"r/rrr�r��s���"�"�*�*�� +� .rr�c�.�|jt_yr�)�
orig_platformr�platform��clss r�
tearDownClassz"HelpsourcePathokTest.tearDownClass�s���*�*��rc��|jd�}|j|j�d�|jd|jd�y)Nr2zno help filer)r�r4r�r5r�r6s r�test_path_ok_blankz'HelpsourcePathokTest.test_path_ok_blank�sB���&�&�s�+��������)�4�0��
�
�n�f�&7�&7��&?�@rc��|jtdz�}|j|j�d�|j d|j
d�y)Nzbad-bad-badz not existr)r�r�r4r�r5r�r6s r�test_path_ok_badz%HelpsourcePathokTest.test_path_ok_bad�sG���&�&�x�-�'?�@��������)�4�0��
�
�k�6�#4�#4�V�#<�=rc�J�|jd�}|j}dD]u}|j�5|jj |�|j|j�|�|j|jdd�ddd��wy#1swY��xYw)Nr)z
www.py.orgz
http://py.orgr)r�r4r�r�r�r�r�)rr7r<�urls r�test_path_ok_webz%HelpsourcePathokTest.test_path_ok_web�s���&�&�r�*��� � ��0�C�����������$�� � ����!1�3�7�� � ��!2�!2�6�!:�B�?� ��1���s�AB�B" c�d�|jd�}dD]�\}}|j�5|t_|jjt�|j|j�|tz�|j|jdd�ddd���y#1swY��xYw)Nr))�darwin�file://)�otherrr)
r�r�rr�r�r�r�r4r�r�)rr7r��prefixs r�test_path_ok_filez&HelpsourcePathokTest.test_path_ok_file�s����&�&�r�*�� D��H�f�����!)���������)�� � ����!1�6�H�3D�E�� � ��!2�!2�6�!:�B�?� ��!E���s�A1B&�&B/ N)r(r)r*rHr�rr�r��classmethodr�r�r�r�r�r/rrr�r��sC��:�.�.��N�N�M��+��+�A�
>�
@�@rr�c�*�eZdZdZGd�d�Zd�Zy)�HelpsourceEntryokTestz5Test entry_ok method of HelpSource subclass of Query.c�L�eZdZejj
ZiZiZd�Zd�Z y)�&HelpsourceEntryokTest.Dummy_HelpSourcec��|jSr�)�namer&s r�item_okz.HelpsourceEntryokTest.Dummy_HelpSource.item_ok�����9�9�rc��|jSr�)r�r&s rr�z.HelpsourceEntryokTest.Dummy_HelpSource.path_ok�r�rN)
r(r)r*rr�r,rr�r�r�r/rrr�r��s'���#�#�,�,�����
� � rr�c���|j�}dD]N\}}}|j�5||c|_|_|j |j�|�ddd��Py#1swY�[xYw)N))NNN)N�doc.txtN)�docNN)r�r�)r�r�)r�r�r�r�r4r,)rr7r�r�rs r�test_entry_ok_helpsourcez.HelpsourceEntryokTest.test_entry_ok_helpsource�sf���&�&�(��#K��D�$������+/��(���V�[�� � ����!2�F�;� �� #K� ��s�0A%�%A. N)r(r)r*rHr�r�r/rrr�r��s��;���<rr�c�6�eZdZdZGd�d�Zd�Zd�Zd�Zy)�CustomRunCLIargsokTestz6Test cli_ok method of the CustomRun subclass of Query.c�D�eZdZejj
Zd�Zd�Zy)�&CustomRunCLIargsokTest.Dummy_CustomRunc�8�t|��|_ddi|_yrOrPrs rrz/CustomRunCLIargsokTest.Dummy_CustomRun.__init__rQrc�"�||jd<yrrr s rr"z0CustomRunCLIargsokTest.Dummy_CustomRun.showerrorr#rN)r(r)r*r� CustomRun�cli_args_okrr"r/rr�Dummy_CustomRunr�s���o�o�1�1�� ,� /rr�c�f�|jd�}|j|j�g�y)Nr2)r�r4r�r6s r�test_blank_argsz&CustomRunCLIargsokTest.test_blank_argss+���%�%�c�*������+�+�-�r�2rc��|jd�}|j|j�d�|jd|jd�y)Nz'no-closing-quotez
No closingr)r�r4r�r5rr6s r�test_invalid_argsz(CustomRunCLIargsokTest.test_invalid_argssE���%�%�&9�:������+�+�-�t�4��
�
�l�F�$6�$6�v�$>�?rc���gd�}|jdj|�dz�}|j|j�|dgz�|j|jdd�y)N)z-n�10z --verbosez-pz/pathz--namer2z
"my name"zmy namerr)r��joinr4r�r)r�argsr7s r�test_good_argsz%CustomRunCLIargsokTest.test_good_args s_��A���%�%�c�h�h�t�n�|�&C�D������+�+�-�t�y�k�/A�B�����+�+�F�3�R�8rN)r(r)r*rHr�r�r�r�r/rrr�r�s��<�/�/�3�@�
9rr�c�*�eZdZdZGd�d�Zd�Zy)�CustomRunEntryokTestz8Test entry_ok method of the CustomRun subclass of Query.c�P�eZdZejj
ZiZe�Zd�Z y)�$CustomRunEntryokTest.Dummy_CustomRunc��|jSr�)�cli_argsr&s rr�z0CustomRunEntryokTest.Dummy_CustomRun.cli_args_ok.s���=�=� rN)
r(r)r*rr�r,rr �
restartvarr�r/rrr�r�*s"���?�?�+�+�����U�
� !rr�c�*�|j�}dD]r}|jj|�ddgdg|fffD]H\}}|j||��5||_|j|j
�|�ddd��J�ty#1swY�WxYw)N>FT)NNzmy arg)�restartr�)r�r�r�r�r�r4r,)rr7r�r�rs r�test_entry_ok_customrunz,CustomRunEntryokTest.test_entry_ok_customrun1s����%�%�'��$�G����!�!�'�*�%1�'/�j�H�:�w�2G�%H�%J� ��&��\�\�'�H�\�E�&.�F�O��$�$�V�_�_�%6��?�F�E�%J�%�F�E�s�(B � BN)r(r)r*rHr�r�r/rrr�r�'s��>�!�!�@rr�c�D�eZdZed��Zed��Zd�Zd�Zd�Zd�Z y)�QueryGuiTestc���td�t�x|_}|jj�t j
|ddd��|_tj�|j_ y)N�gui�TEST�testT��_utest)
rr�root�withdrawrr+r7rr?r')r�r�s r�
setUpClasszQueryGuiTest.setUpClass@sO������$����4��������[�[��v�v�d�C��
�!�Y�Y�[��
�
�rc�X�|j`|`|jj�|`yr�)r7r'r�r�s rr�zQueryGuiTest.tearDownClassHs&���J�J���J��������Hrc��|jjjdd�d|j_|jjj�y)Nr�end)r7r�deleterr'�
reset_mockr&s r�setUpzQueryGuiTest.setUpOs>������� � ��E�*�!����������&�&�(rc�
�|j}|jjdd�|jj �|j|jd�|j|jj�y�Nr�abc)
r7r�insert� button_ok�invoker4rrAr'rBr6s r�
test_click_okzQueryGuiTest.test_click_okTs[�����������A�u�%������!��������.�������-�-�.rc���|j}|jj�|j|jd�|j|jj�yr�)r7rrr4r�assertFalser'rBr6s r�test_click_blankzQueryGuiTest.test_click_blank[sI�����������!��������-�������.�.�/rc�
�|j}|jjdd�|jj �|j|jd�|j|jj�yr)
r7rr�
button_cancelrr4rrAr'rBr6s r�test_click_cancelzQueryGuiTest.test_click_cancelas[�����������A�u�%����#�#�%��������-�������-�-�.rN)
r(r)r*r�r�r�r�rrrr/rrr�r�>s<���)��)�����)�
/�0�/rr�c�"�eZdZed��Zd�Zy)�SectionnameGuiTestc��td�y�Nr�rr�s rr�zSectionnameGuiTest.setUpClassk� ����rc��t�}|j�tj|dddhd��}|j}|j |j
dh�|jjdd�|jj�|j |jd�|j�y)N�T�trTr�r�okay)rr�rrSr4rTrrrrrr')rr�r7r<s r�test_click_section_namez*SectionnameGuiTest.test_click_section_nameos����t���
�
���#�#�D�#�s�U�G�D�I��� � ������*�*�U�G�4������A�v�&������!��������/����rN)r(r)r*r�r�rr/rrr
r
i������� rr
c�"�eZdZed��Zd�Zy)�ModulenameGuiTestc��td�yrrr�s rr�zModulenameGuiTest.setUpClass}rrc��t�}|j�tj|dddd��}|j |j
d�|j |jj�d�|jj�|j|jjd��|j�y)NrrruTr�rv)rr�rrhr4rirr�rrrArrwr'�rr�r7s r�test_click_module_namez(ModulenameGuiTest.test_click_module_name�s����t���
�
���"�"�4��c�9�T�J��������y�1�������)�)�+�Y�7������!�����
�
�.�.�}�=�>����rN�r(r)r*r�r�rr/rrrr{s������rrc�"�eZdZed��Zd�Zy)�GotoGuiTestc��td�yrrr�s rr�zGotoGuiTest.setUpClass�rrc�.�t�}|j�tj|ddd��}|jjdd�|jj�|j|jd�|j�y)NrrTr�r�22�)rr�rrrrrrr4rr'rs rrz"GotoGuiTest.test_click_module_name�si���t���
�
���*�*�T�3��D�9�������A�t�$������!��������+����rNrr/rrrr�s������rrc�"�eZdZed��Zd�Zy)�HelpsourceGuiTestc��td�yrrr�s rr�zHelpsourceGuiTest.setUpClass�rrc���t�}|j�tj|ddtd��}|j
}||jj�d�||jj�t�|jj�tjdk(rdnd}||jd|tzf�|j�y)Nr�__test__T)�menuitem�filepathr�r�r�r)rr�rr�r�r4rr�r�rr�sysr�rr')rr�r7r<r�s r�test_click_help_sourcez(HelpsourceGuiTest.test_click_help_source�s����t���
�
���"�"�4��z�,4�T�C��� � ��
�f�l�l��� �*�-�
�f�k�k�o�o���*������!�!�l�l�h�6��B��
�f�m�m�j�&�8�*;�<�=����rN)r(r)r*r�r�r,r/rrr%r%�s������rr%c�"�eZdZed��Zd�Zy)�CustomRunGuiTestc��td�yrrr�s rr�zCustomRunGuiTest.setUpClass�rrc��t�}|j�tj|dddgd��}|j |j
j
�d�|j
jtd�|jj�|j |jgd�df�|j�y) N�Titler��b=1T)r�r�za b=1z c)r�r2r�)
rr�rr�r4rr�rrrrrr'rs r�test_click_argsz CustomRunGuiTest.test_click_args�s����t���
�
���/�/�$��,/��<��F��������)�)�+�W�5������C��&������!�������):�D�(A�B����rN)r(r)r*r�r�r3r/rrr.r.�rrr.�__main__�F)� verbosity�exit)rHrur�unittest�test.supportr�tkinterrrr+r�idlelib.idle_test.mock_tkr �TestCaserrJrcrzr�r�r�r�r�r�r
rrr%r.r(�mainr/rr�<module>r>sY��
���!��
��)�
0J��!�!�0J�f9�h�'�'�9�B!9�X�&�&�!9�H9�x� � �9�:?�x�0�0�?�2*@�8�,�,�*@�Z<�H�-�-�<�29�X�.�.�9�6@�8�,�,�@�.(/�8�$�$�(/�V��*�*��$��)�)��"
�(�#�#�
� ��)�)��(�x�(�(��$�z���H�M�M�A�E�*�r
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists