HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/idlelib/idle_test/__pycache__/test_pyparse.cpython-310.pyc
o

�i�K�@sddZddlmZddlZddlmZGdd�dej�ZGdd�dej�Ze	d	kr0ej
d
d�dSdS)zTest pyparse, coverage 96%.�)�pyparseN)�
namedtuplec@seZdZdd�Zdd�ZdS)�ParseMapTestcCs`dd�dD�}t�|�}|�|td�td��|�|td�td��|�|dtd��dS)NcSsi|]	}t|�t|��qS�)�ord)�.0�crr�;/usr/local/lib/python3.10/idlelib/idle_test/test_pyparse.py�
<dictcomp>sz.ParseMapTest.test_parsemap.<locals>.<dictcomp>z 	

�	�a�xi�)rZParseMap�assertEqualr)�selfZ	keepwhite�mappingrrr	�
test_parsemap
s

zParseMapTest.test_parsemapcCs$t�dd�}|�d�tj�d�dS)N�z	 a([{b}])b"c'd
zxxx(((x)))x"x'x
)r�Parserr�	translateZtrans)r�parserrrr	�
test_transs�zParseMapTest.test_transN)�__name__�
__module__�__qualname__rrrrrr	rsrc@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�PyParseTestcCstjddd�|_dS)Nr)�indentwidth�tabwidth)rrr��clsrrr	�
setUpClassszPyParseTest.setUpClasscCs|`dS�N)rrrrr	�
tearDownClassszPyParseTest.tearDownClasscCs$|�|jjd�|�|jjd�dS)Nr)rrrr)rrrr	�	test_init"szPyParseTest.test_initc	Cs�|j}|j}|j}|�t��|d�Wd�n1swYd}|D](}|j|d��||�||j|�||jd�Wd�n1sIwYq&dS)Nr)��a
��stringr)rr�set_code�assertRaises�AssertionError�subTest�code�study_level)r�eq�p�setcode�testsr&rrr	�
test_set_code&s
����zPyParseTest.test_set_codecs�|j}|j}|j}|j}dd�}|d�|||�d�|d�|||�d�|d�d\}�|�t��|�Wd�n1sAwY|�t��|d�Wd�n1sZwY|�|d	d
�d��|||���||�fdd
�d���||�fd
d
�d�|�||�fdd
�d�d�|d�|||���||�fdd
�d���||�fdd
�d�|�||�fdd
�d���dS)NcS�dS)NFr��indexrrr	�char_in_string_false=�zDPyParseTest.test_find_good_parse_start.<locals>.char_in_string_falsezdef spam():
rzclass spam(  
�k"""This is a module docstring"""
class C:
    def __init__(self, a,
                 b=True):
        pass
)�!�*FcSr2)NTrr3rrr	�<lambda>[r6z8PyParseTest.test_find_good_parse_start.<locals>.<lambda>)Zis_char_in_stringc�|�kSr rr3��posrr	r:c�c�|�kSr rr3r<rr	r:fr>c�|�kSr rr3r<rr	r:ir>zZ"""This is a module docstring"""
class C:
    def __init__(self, a, b=True):
        pass
cr;r rr3r<rr	r:sr>cr?r rr3r<rr	r:tr>cr@r rr3r<rr	r:wr>)rrr'Zfind_good_parse_startr(�	TypeError�assertIsNone)rr-r.r/�startr5Zpos0rr<r	�test_find_good_parse_start8s6�
�z&PyParseTest.test_find_good_parse_startcCs�d}d}|j}|�|�|�t��
|�d�Wd�n1s!wY|�d�|�|j|�|�|�|�|j||d��dS)Nr7r9�r)rr'r(r)Zset_lorr+)rr+r=r.rrr	�test_set_loys�
�

zPyParseTest.test_set_loc
Cs�|j}|j}|j}|j}td�\}}}}}	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]5}|j|jd��$||j�|�||jd�||j	|j	�||j
|j
�Wd�n1s�wYq�|�|��dS)NrE�TestInfo)r&�	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.

)rrJrKz# Comment\
z"("""Complete string in bracket"""
z("""Open string in bracket
�a = (1 + 2) - 5 *\
�0
   def function1(self, a,
                 b):
)rrJ��
   def function1(self, a,\
�
   def function1(self, a,
�())
�)(
�{)(]
r%)rrr'Z_study1�rangerr*r&r,rHrIrB)
rr-r.r/�study�NONE�	BACKSLASH�FIRST�NEXT�BRACKETrGr0�testrrr	�test_study1�sP��
��zPyParseTest.test_study1c
	Cs�|j}|j}|j}|j}td�\}}}}}	tdddg�}
|
d|�|
d|�|
d|�|
d|�|
d	|	�f}|D]%}|j|jd
��||j�||�|j�Wd�n1sTwYq4dS)NrErGr&rIr#z%"""This is a continuation docstring.
z-'''This is a multiline-continued docstring.

rLrOr%)	rrr'Zget_continuation_typerTrr*r&rI)
rr-r.r/ZgettyperVrWrXrYrZrGr0r[rrr	�test_get_continuation_type�s&�
���z&PyParseTest.test_get_continuation_typecCs�|j}|j}|j}|j}tdgd��}|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|jd3��9||j�|�||jd4�||j|j	�||j
|j�||j|j�||j
|j�||j|j�Wd�n1s�wYq�|�|��dS)5NrG)r&rC�end�lastch�openbracket�
bracketingr#r��rrz0'''This is a multiline continuation docstring.

�0�')rc�rrJ)rdrz # Comment\
�)rc�rJrJ)rgrz #Comment\
rL��*)rc�rrJ)�rrMrJ�:)�rJr��rJ)�.rrO��,rp)rnrorP�z3
   def function1(self, a,  # End of line comment.
�3)rnro)rrrK)rurJz7  a = ["first item",
  # Comment line
    "next item",
�7�)rc)rwrJ)�rK)rirJ)�rK)�&rJ)r9rK)�5rJrQr�))rcrf�rKr�rNrrRrN�()rcrnrhrSrE�]�rcrfr}�rKrJ�rrz:\a
z\a�
r%rK)rrr'Z_study2rr*r&r,Z
stmt_startrCZstmt_endr^r_Zlastopenbracketposr`Zstmt_bracketingrarB)rr-r.r/rUrGr0r[rrr	�test_study2�sp
�
�
�
�
�
�
�
�
�
�
��'
��zPyParseTest.test_study2c
Cs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|d	d
�|dd�|dd�|d
d�|dd�f}|d�|�t��|�Wd�n1sLwY|D]%}|j|jd��||j�||�|j	�Wd�n1sswYqSdS)NrGr&�linesz[x for x in a]
rJz[x
for x in a
rKz[x\
for x in a\
z[x
for x in a
]
rNz%
"""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\
"""
rEr#r%)
rrr'Zget_num_lines_in_stmtrr(�
IndexErrorr*r&r�)rr-r.r/�getlinesrGr0r[rrr	�test_get_num_lines_in_stmts2��
���z&PyParseTest.test_get_num_lines_in_stmtc
Cs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|d	d
�|dd
�|dd
�|d
d�|dd�|dd�|dd�|dd�f}|d�|�t��|�Wd�n1sXwY|D]}||j�||�|j�q_dS)NrGr&�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",
rKz1["first item",
  # Comment line
    "next item",
rJz(
rz(a
zdef function1(self, a, b):
)	rrr'Zcompute_bracket_indentrr(r)r&r�)rr-r.r/�indentrGr0r[rrr	�test_compute_bracket_indent1s2��
�z'PyParseTest.test_compute_bracket_indentc
Cs\|j}|j}|j}|j}d}|D]4}|j|d��$||�|�t��|�Wd�n1s0wYWd�n1s?wYqtdd�}|dd�|dd�|dd	�|d
d�|dd�|d
d�|dd�|dd�|dd�|dd�|dd�|dd�|dd�|dd�f}|D]%}	|j|	jd��||	j�||�|	j	�Wd�n1s�wYq�dS)N)zdef function1(self, a, b\
z    """ (\
za = #\
r%rG)r&r�rLrza = 1 + 2 - 5 *\
z    a = 1 + 2 - 5 *\
r�z  a = "spam"\
rwz
  a = \
"a"\
z  a = #\
"a"\
rEza == \
rKza != \
z\
z    \
z	\
za\
rNz{}\
z(1 + 2) - 5 *\
)
rrr'Zcompute_backslash_indentr*r(r)rr&r�)
rr-r.r/r��errorsr&rGr0r[rrr	�test_compute_backslash_indentQsJ����
�
���z)PyParseTest.test_compute_backslash_indentc	Cs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|dd	�|d
d	�|dd	�|dd	�f}|D]%}|j|jd
��||j�||�|j�Wd�n1sSwYq3dS)NrGr&r�r#�	def a():
z
	def a():
rz
    def a():
z    z    def a(
z
	
    def a(
z	
    # Comment.
r%)rrr'Zget_base_indent_stringrr*r&r�)rr-r.r/Z
baseindentrGr0r[rrr	�test_get_base_indent_stringxs(�	
���z'PyParseTest.test_get_base_indent_stringc	Cs�|j}|j}|j}|j}|j}tdddg�}|d|�|d|�|d|�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|�|d|�|d|�f}|D]$}|j|jd��||j�|�|��Wd�n1siwYqJdS)NrGr&�assert_r�rMz:
za:
z):
z(:
z":
rP�!def function1(self, a):
    pass
z
# A comment:
z"""A docstring:
r%)	�
assertTrue�assertFalserr'Zis_block_openerrr*r&r�)	r�yes�nor.r/�openerrGr0r[rrr	�test_is_block_opener�s4�
���z PyParseTest.test_is_block_openerc	Cs�|j}|j}|j}|j}|j}tdddg�}|d|�|d|�|d|�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|�|d|�|d|�|d|�f
}|D]$}|j|jd��||j�|�|��Wd�n1smwYqNdS)NrGr&r�zreturn
z	break
z  continue
z     raise
z	pass    
zpass	
z	return #
zraised
z
returning
z	# return
z	"""break
z
"continue
r�r%)	r�r�rr'Zis_block_closerrr*r&r�)	rr�r�r.r/ZcloserrGr0r[rrr	�test_is_block_closer�s6�
���z PyParseTest.test_is_block_closercCs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|d	d
�|dd�|d
d�|dd�|dd�|dd�|dd�f
}|D]%}|j|jd��||j�||�|j�Wd�n1s_wYq?dS)NrGr&�bracketr#rbr$z()()
r�z(
)()
)rcrfr~�rNrJ�rErz()
()
)r~r�r�z()(
)
)rcrfr}r�r�z(())
)rcrf�rJrKr�r�z(
())
)rcrf)rKrKrkr�rSz(((())
)rcrfr�)rKrN)rNr)rErN)rwrKr%)rrr'Zget_last_stmt_bracketingrr*r&r�)rr-r.r/rarGr0r[rrr	�test_get_last_stmt_bracketing�s2��
���z)PyParseTest.test_get_last_stmt_bracketingN)rrr�classmethodrr!r"r1rDrFr\r]r�r�r�r�r�r�r�r�rrrr	rs&

A2= 'r�__main__rK)�	verbosity)�__doc__ZidlelibrZunittest�collectionsrZTestCaserrr�mainrrrr	�<module>sM�