Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/idlelib/idle_test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/idlelib/idle_test/__pycache__/test_pyparse.cpython-312.pyc

�

&Μg�K���dZddlmZddlZddlmZGd�dej�ZGd�dej�Ze	d	k(rejd
��yy)zTest pyparse, coverage 96%.�)�pyparseN)�
namedtuplec��eZdZd�Zd�Zy)�ParseMapTestc�T�dD�cic]}t|�t|���}}tj|�}|j|td�td��|j|td�td��|j|dtd��ycc}w)Nz 	

�	�a�xi�)�ordr�ParseMap�assertEqual)�self�c�	keepwhite�mappings    �;/usr/local/lib/python3.12/idlelib/idle_test/test_pyparse.py�
test_parsemapzParseMapTest.test_parsemap
s���-6�7�Y��S��V�S��V�^�Y�	�7��"�"�9�-�������T��+�S��Y�7������S��*�C��H�5��������C��1��	8s�B%c��tjdd�}|jdjtj�d�y)N�z	 a([{b}])b"c'd
zxxx(((x)))x"x'x
)r�Parserr
�	translate�trans)r�parsers  r�
test_transzParseMapTest.test_transs5������1�%�����.�8�8����G�-�	/�N)�__name__�
__module__�__qualname__rr�rrrrs��2�/rrc��eZdZed��Zed��Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zy)�PyParseTestc�<�tjdd��|_y)Nr)�indentwidth�tabwidth)rrr��clss r�
setUpClasszPyParseTest.setUpClasss���^�^��A�>��
rc��|`y�N)rr%s r�
tearDownClasszPyParseTest.tearDownClasss���Jrc��|j|jjd�|j|jjd�y)Nr)r
rr#r$)rs r�	test_initzPyParseTest.test_init"s6��������0�0�!�4�������-�-�q�1rc�l�|j}|j}|j}|jt�5|d�ddd�d}|D]K}|j|��5||�||j|�||jd�ddd��My#1swY�\xYw#1swY�dxYw)Nr	)��a
��stringr)r
r�set_code�assertRaises�AssertionError�subTest�code�study_level)r�eq�p�setcode�testsr1s      r�
test_set_codezPyParseTest.test_set_code&s���
�
�
���K�K���*�*���
�
�~�
.��C�L�/����F����V��,�����1�6�6�6�"��1�=�=�!�$�-�,��
/�
.��-�,�s�	B�$/B*�B'�*B3	c�
��|j}|j}|j}|j}d�}|d�|||�d�|d�|||�d�|d�d\}�|j	t
�5|�ddd�|j	t
�5|d�ddd�|j
|d��	��|||���||�fd
��	���||�fd��	�|�||�fd��	�d�|d
�|||���||�fd��	���||�fd��	�|�||�fd��	���y#1swY��xYw#1swY��xYw)Nc��y)NFr��indexs r�char_in_string_falsezDPyParseTest.test_find_good_parse_start.<locals>.char_in_string_false=s��rzdef spam():
rzclass spam(  
�k"""This is a module docstring"""
class C:
    def __init__(self, a,
                 b=True):
        pass
)�!�*Fc��y)NTrr?s r�<lambda>z8PyParseTest.test_find_good_parse_start.<locals>.<lambda>[s��r)�is_char_in_stringc���|�kDSr)r�r@�poss �rrFz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>c�	�����rc���|�k\Sr)rrIs �rrFz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>f�	����#�rc���|�kSr)rrIs �rrFz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>irKrzZ"""This is a module docstring"""
class C:
    def __init__(self, a, b=True):
        pass
c���|�kDSr)rrIs �rrFz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>srKrc���|�k\Sr)rrIs �rrFz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>trMrc���|�kSr)rrIs �rrFz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>wrKr)r
rr2�find_good_parse_startr3�	TypeError�assertIsNone)rr8r9r:�startrA�pos0rJs       @r�test_find_good_parse_startz&PyParseTest.test_find_good_parse_start8ss���
�
�
���K�K���*�*���'�'��5�	�� �
�5�%�&��*�	�&�'�
�5�%�&��*�	�!�	��	��c��
�
�y�
)��G�*�
�
�
�y�
)��%�L�*�
	
���%�2D�E�F�	�5�%�&��,�	�5�#<�=�s�C�	�5�#=�>��E�	�5�#<�=�t�D�	�!�	�
	�5�%�&��,�
�5�#<�=�s�C�
�5�#=�>��E�	�5�#<�=�s�C�G*�
)��
)�
)�s�E-�*	E9�-E6�9Fc�v�d}d}|j}|j|�|jt�5|j	d�ddd�|j	d�|j|j|�|j	|�|j|j||d�y#1swY�gxYw)NrBrD�r)rr2r3r4�set_lor
r6)rr6rJr9s    r�test_set_lozPyParseTest.test_set_loys���!�	
����K�K��	�
�
�4���
�
�~�
.�
�H�H�Q�K�/�	
������������&�	
����
��������c�d��,�/�
.�s�B/�/B8c���|j}|j}|j}|j}t	d�\}}}}}	tdgd��}
|
ddg|�|
dddg|�|
dddg|�|
d	ddg|�|
d
ddg|�|
dddg|�|
dddg|�|
d
ddg|�|
dddg|�|
dddg|�|
dgd�|�|
dddg|�|
dddg|	�|
dddg|�|
dddg|�|
dgd�|�|
dgd�|	�|
dgd�|	�|
dddg|�|
dddg|	�|
dddg|�f}|D]�}|j
|j��5||j�|�||jd�||j|j�||j|j�ddd���|j|��y#1swY��xYw)NrY�TestInfo)r1�	goodlines�continuationr.rz$"""This is a complete docstring."""
�z$'''This is a complete docstring.'''
z""""This is a continued docstring.
z"'''This is a continued docstring.
z""""Closing quote does not match."
z"""Bracket in docstring [
z#'''Incomplete two line docstring.

�z"This is a complete string."
z"This is an incomplete string.
z'This is more incomplete.

)rr`raz# Comment\
z"("""Complete string in bracket"""
z("""Open string in bracket
�a = (1 + 2) - 5 *\
�0
   def function1(self, a,
                 b):
)rr`��
   def function1(self, a,\
�
   def function1(self, a,
�())
�)(
�{)(]
r0)r
rr2�_study1�rangerr5r1r7r^r_rT)
rr8r9r:�study�NONE�	BACKSLASH�FIRST�NEXT�BRACKETr]r;�tests
             r�test_study1zPyParseTest.test_study1�s-��
�
�
���K�K���*�*���	�	��27��(�/��y�%��w��j�+;�<��
�R�!��d�#��<�q�!�f�d�K��<�q�!�f�d�K��:�Q��F�E�J��:�Q��F�E�J��:�Q��F�E�J��2�Q��F�E�B��<�q�!�f�d�K��5��1�v�t�D��7�!�Q���F��4�i��F��_�q�!�f�d�3��:�Q��F�G�L��3�a��V�U�C��,�q�!�f�i�@��J���
&��6�	�7�K��4�i��I��W�q�!�f�d�+��V�a��V�W�-��X��1�v�t�,�7��<�D����T�[�[��1�����$����1�=�=�!�$��1�;�;����/��1�>�>�4�#4�#4�5�2�1��	
���%�'�"�2�1�s
�A'G!�!G*	c��|j}|j}|j}|j}t	d�\}}}}}	tdddg�}
|
d|�|
d|�|
d|�|
d|�|
d	|	�f}|D]Q}|j
|j�
�5||j�||�|j�ddd��Sy#1swY�^xYw)NrYr]r1r_r.z%"""This is a continuation docstring.
z-'''This is a multiline-continued docstring.

rbrer0)	r
rr2�get_continuation_typerkrr5r1r_)
rr8r9r:�gettypermrnrorprqr]r;rrs
             r�test_get_continuation_typez&PyParseTest.test_get_continuation_type�s���
�
�
���K�K���*�*���)�)��27��(�/��y�%��w��j�8�^�*D�E���R����=�u�E��F��M��,�i�8��6��@����D����T�[�[��1�����$��7�9�d�/�/�0�2�1��1�1�s�+C�C	c��|j}|j}|j}|j}t	dgd��}|dddddd�|dddddd	�|d
ddddd�|d
ddddd�|dddddd�|dddddd�|dddddd�|dddddd�|dddddd�|d dd!dd"d#�|d$dd%d&dd'�|d(dd)d*dd+�|d,dd-d.dd/�|d0dd%d1dd�|d2ddddd�f}|D]�}|j|j�3�5||j�|�||jd4�||j|j�||j|j�||j|j�||j|j�||j|j �ddd���|j#|��y#1swY��xYw)5Nr])r1rU�end�lastch�openbracket�
bracketingr.r��rrz0'''This is a multiline continuation docstring.

�0�')r~�rr`)rrz # Comment\
�)r~�r`r`)r�rz #Comment\
rb��*)r~�rr`)�rrcr`�:)�r`r��r`)�.rre��,r�)r�r�rf�z3
   def function1(self, a,  # End of line comment.
�3)r�r�)r�ra)r�r`z7  a = ["first item",
  # Comment line
    "next item",
�7�)r~)r�r`)�ra)r�r`)�ra)�&r`)rDra)�5r`rgr�))r~r��rar�rdrrhrd�()r~r�r�rirY�]�r~r�r��rar`�rrz:\a
z\a�
r0ra)r
rr2�_study2rr5r1r7�
stmt_startrU�stmt_endryrz�lastopenbracketposr{�stmt_bracketingr|rT)rr8r9r:rlr]r;rrs        r�test_study2zPyParseTest.test_study2�se��
�
�
���K�K���*�*���	�	���j�+H�I��
�R��A�r�4��3��I���C��'@�
B��%���B��&?�
A�
�_���2�t�Y�
0�
�,���C��'@�
B�
�J���C��'A�
C�
�6���C��%6�
8�
�4���C��%6�
8�
�L���C��%H�
J�
�Q���C��%I�
J�
�W���3��&F�
H��V�Q��3��+C�D��X���3��&N�
P�
�X�q�!�U�D�)�<��T�1�a��T�9�5�I%��N�D����T�[�[��1�����$����1�=�=�!�$��1�<�<����,��1�:�:�t�x�x�(��1�8�8�T�[�[�)��1�'�'��)9�)9�:��1�$�$�d�o�o�6�2�1��	
���%�'�"�2�1�s
�B>G5�5G?	c�:�|j}|j}|j}|j}t	dddg�}|dd�|dd�|dd�|d	d
�|dd�|dd�|d
d�|dd�f}|d�|jt�5|�ddd�|D]Q}|j|j��5||j�||�|j�ddd��Sy#1swY�`xYw#1swY�jxYw)Nr]r1�linesz[x for x in a]
r`z[x
for x in a
raz[x\
for x in a\
z[x
for x in a
]
rdz%
"""Docstring comment L1"""
L2
L3
L4
z%
"""Docstring comment L1
L2"""
L3
L4
z&
"""Docstring comment L1\
L2\
L3\
L4\
rz+

"""Docstring comment L1\
L2\
L3\
L4\
"""
rYr.r0)
r
rr2�get_num_lines_in_stmtrr3�
IndexErrorr5r1r�)rr8r9r:�getlinesr]r;rrs        r�test_get_num_lines_in_stmtz&PyParseTest.test_get_num_lines_in_stmts��
�
�
���K�K���*�*���*�*���j�8�W�*=�>���'��+��'��+��+�Q�/��*�A�.��A�1�E��A�1�E��F��J��M�q�Q�	��	���
�
�
�z�
*��J�+��D����T�[�[��1�����$��8�:�t�z�z�*�2�1��+�
*��2�1�s�D�+D�D�D	c��|j}|j}|j}|j}t	dddg�}|dd�|dd�|dd�|d	d
�|dd
�|dd
�|d
d�|dd�|dd�|dd�|dd�f}|d�|jt�5|�ddd�|D],}||j�||�|j��.y#1swY�;xYw)Nr]r1�spaceszdef function1(self, a,
�z
    def function1(self, a,
�z
	def function1(self, a,
z
    def function1(
�z
	def function1(
z
    def function1(  
z2[
"first item",
  # Comment line
    "next item",
rz4[
  "first item",
  # Comment line
    "next item",
raz1["first item",
  # Comment line
    "next item",
r`z(
rz(a
zdef function1(self, a, b):
)	r
rr2�compute_bracket_indentrr3r4r1r�)rr8r9r:�indentr]r;rrs        r�test_compute_bracket_indentz'PyParseTest.test_compute_bracket_indent1s��
�
�
���K�K���*�*���)�)���j�8�X�*>�?���/��4��5�r�:��3�R�8��-�q�1��+�Q�/��/��3��M�q�Q��O�QR�S��K�Q�O��U�A���V�Q����"	�.�/�
�
�
�~�
.��H�/��D��D�K�K� ��v�x����%��/�
.�s�6C8�8Dc��|j}|j}|j}|j}d}|D]J}|j	|��5||�|jt�5|�ddd�ddd��Ltdd�}|dd�|dd�|dd	�|d
d�|dd�|d
d�|dd�|dd�|dd�|dd�|dd�|dd�|dd�|dd�f}|D]Q}	|j	|	j��5||	j�||�|	j�ddd��Sy#1swY��xYw#1swY��8xYw#1swY�wxYw)N)zdef function1(self, a, b\
z    """ (\
za = #\
r0r])r1r�rbrza = 1 + 2 - 5 *\
z    a = 1 + 2 - 5 *\
r�z  a = "spam"\
r�z
  a = \
"a"\
z  a = #\
"a"\
rYza == \
raza != \
z\
z    \
z	\
za\
rdz{}\
z(1 + 2) - 5 *\
)
r
rr2�compute_backslash_indentr5r3r4rr1r�)
rr8r9r:r��errorsr1r]r;rrs
          r�test_compute_backslash_indentz)PyParseTest.test_compute_backslash_indentQsx��
�
�
���K�K���*�*���+�+�����F����V��,�����&�&�~�6��H�7�-�,���j�*>�?���1�1�5��/��3��3�Q�7��,�a�0��-�q�1��.��2��+�q�)��+�q�)��&�!�$��*�a�(��(�A�&��'�1�%��(�A�&��-�q�1��� �D����T�[�[��1�����$��6�8�T�[�[�)�2�1��)7�6��-�,��.2�1�s0�
E#�(E�0E#�!+E0�E �E#�#E-	�0E9	c
��|j}|j}|j}|j}t	dddg�}|dd�|dd�|dd�|dd	�|d
d	�|dd	�|dd	�f}|D]Q}|j|j�
�5||j�||�|j�ddd��Sy#1swY�^xYw)Nr]r1r�r.�	def a():
z
	def a():
rz
    def a():
z    z    def a(
z
	
    def a(
z	
    # Comment.
r0)r
rr2�get_base_indent_stringrr5r1r�)rr8r9r:�
baseindentr]r;rrs        r�test_get_base_indent_stringz'PyParseTest.test_get_base_indent_stringxs���
�
�
���K�K���*�*���-�-�
��j�8�X�*>�?���"�b�!��,��+��.�$�/��*�F�3��.�&�1��,�f�5��0�&�9�
���D����T�[�[��1�����$��:�<����-�2�1��1�1�s�+C�C	c��|j}|j}|j}|j}|j}tdddg�}|d|�|d|�|d|�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|�|d|�|d|�f}|D]O}|j
|j��5||j�|j|��ddd��Qy#1swY�\xYw)Nr]r1�assert_r�rcz:
za:
z):
z(:
z":
rf�!def function1(self, a):
    pass
z
# A comment:
z"""A docstring:
r0)	�
assertTrue�assertFalserr2�is_block_openerrr5r1r�)	r�yes�nor9r:�openerr]r;rrs	         r�test_is_block_openerz PyParseTest.test_is_block_opener�s���o�o��
�
�
���K�K���*�*���"�"���j�8�Y�*?�@���\�3�'��J�C�P��U�C� ��V�S�!��V�S�!��V�S�!��V�R� ��4�b�9��:�B�?��%�r�*��(�"�-��(�"�-�
���D����T�[�[��1�����$����V�X�&�2�1��1�1�s�)D�D	c�,�|j}|j}|j}|j}|j}tdddg�}|d|�|d|�|d|�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|�|d|�|d|�|d|�f
}|D]O}|j
|j��5||j�|j|��ddd��Qy#1swY�\xYw)Nr]r1r�zreturn
z	break
z  continue
z     raise
z	pass    
zpass	
z	return #
zraised
z
returning
z	# return
z	"""break
z
"continue
r�r0)	r�r�rr2�is_block_closerrr5r1r�)	rr�r�r9r:�closerr]r;rrs	         r�test_is_block_closerz PyParseTest.test_is_block_closer�s���o�o��
�
�
���K�K���*�*���"�"���j�8�Y�*?�@���Z��%��[�#�&��^�S�)��^�S�)��\�3�'��Z��%��\�3�'��Z��$��]�B�'��\�2�&��\�2�&��]�B�'��:�C�@��� �D����T�[�[��1�����$����V�X�&�2�1��1�1�s�)D
�
D	c
���|j}|j}|j}|j}t	dddg�}|dd�|dd�|dd�|d	d
�|dd�|d
d�|dd�|dd�|dd�|dd�f
}|D]Q}|j|j��5||j�||�|j�ddd��Sy#1swY�^xYw)Nr]r1�bracketr.r}r/z()()
r�z(
)()
)r~r�r��rdr`�rYrz()
()
)r�r�r�z()(
)
)r~r�r�r�r�z(())
)r~r��r`rar�r�z(
())
)r~r�)rarar�r�riz(((())
)r~r�r�)rard)rdr)rYrd)r�rar0)r
rr2�get_last_stmt_bracketingrr5r1r�)rr8r9r:r|r]r;rrs        r�test_get_last_stmt_bracketingz)PyParseTest.test_get_last_stmt_bracketing�s���
�
�
���K�K���*�*���/�/�
��j�8�Y�*?�@���R��#��U�I�&��X�G�H��Z�!I�J��Z�!9�:��Z�!I�J��X�G�H��Z�!I�J��X�G�H��Z�M�
O�
���D����T�[�[��1�����$��:�<����.�2�1��1�1�s�2+C(�(C1	N)rrr�classmethodr'r*r,r<rWr[rsrwr�r�r�r�r�r�r�r�rrrr!r!st���?��?�����2�%�$?D�B-�00#�d1�*;#�z+�8&�@%*�N.�*'�8'�:/rr!�__main__ra)�	verbosity)�__doc__�idlelibr�unittest�collectionsr�TestCaserr!r�mainrrr�<module>r�sU�����"�
/�8�$�$�
/� G/�(�#�#�G/�T�z���H�M�M�A��r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists