Your IP : 18.227.21.181


Current Path : /opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_pyparse.cpython-37.pyc

B

� fK�@s`dZddlmZddlZddlmZGdd�dej�ZGdd�dej�Ze	d	kr\ej
d
d�dS)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�C/opt/alt/python37/lib64/python3.7/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	rsrc@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)r)rrrr	�
tearDownClassszPyParseTest.tearDownClasscCs$|�|jjd�|�|jjd�dS)Nr)rrrr)rrrr	�	test_init"szPyParseTest.test_initc
Cs~|j}|j}|j}|�t��|d�WdQRXd}xD|D]<}|j|d��&||�||j|�||jd�WdQRXq:WdS)Nr)�za
)�stringr)rr�set_code�assertRaises�AssertionError�subTest�code�study_level)r�eq�p�setcode�testsr"rrr	�
test_set_code&s
zPyParseTest.test_set_codec	CsB|j}|j}|j}|j}dd�}|d�|||�d�|d�|||�d�|d�|�t��|�WdQRX|�t��|d�WdQRX|�|dd	�d
��|||�d�||dd	�d
�d�||d
d	�d
�d�||dd	�d
�d�|d�|||�d�||dd	�d
�d�||dd	�d
�d�||dd	�d
�d�dS)NcSsdS)NFr)�indexrrr	�char_in_string_false=�zDPyParseTest.test_find_good_parse_start.<locals>.char_in_string_falsezdef spam():
rzclass spam(  
zm"""This is a module docstring"""
class C():
    def __init__(self, a,
                 b=True):
        pass
FcSsdS)NTr)r.rrr	�<lambda>Zr0z8PyParseTest.test_find_good_parse_start.<locals>.<lambda>)Zis_char_in_string�,cSs|dkS)Nr2r)r.rrr	r1br0cSs|dkS)Nr2r)r.rrr	r1er0�!cSs|dkS)Nr2r)r.rrr	r1hr0z\"""This is a module docstring"""
class C():
    def __init__(self, a, b=True):
        pass
cSs|dkS)Nr2r)r.rrr	r1rr0cSs|dkS)Nr2r)r.rrr	r1sr0cSs|dkS)Nr2r)r.rrr	r1vr0)rrr#Zfind_good_parse_startr$�	TypeError�assertIsNone)rr)r*r+�startr/rrr	�test_find_good_parse_start8s0z&PyParseTest.test_find_good_parse_startc	Cspd}|j}|�|�|�t��|�d�WdQRX|�d�|�|j|�|�d�|�|j|dd��dS)Nzm"""This is a module docstring"""
class C():
    def __init__(self, a,
                 b=True):
        pass
�rr2)rr#r$r%Zset_lorr')rr'r*rrr	�test_set_loxs


zPyParseTest.test_set_loc
Cs�|j}|j}|j}|j}td�\}}}}}	tddddg�}
|
ddg|�|
ddd	g|�|
d
dd	g|�|
ddd	g|�|
ddd	g|�|
d
dd	g|�|
ddd	g|�|
dddg|�|
ddd	g|�|
ddd	g|�|
ddd	dg|�|
ddd	g|�|
ddd	g|	�|
ddd	g|�|
ddd	g|�|
ddd	dg|�|
ddd	dg|	�|
ddd	dg|	�|
ddd	g|�|
ddd	g|	�|
ddd	g|�f}x`|D]X}|j|jd��>||j�|�||jd	�||j	|j	�||j
|j
�WdQRX�qpW|�|��dS) Nr8�TestInfor"�	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.

z# Comment\
z"("""Complete string in bracket"""
z("""Open string in bracket
za = (1 + 2) - 5 *\
z0
   def function1(self, a,
                 b):
�z
   def function1(self, a,\
z
   def function1(self, a,
z())
z)(
z{)(]
)r")rrr#Z_study1�rangerr&r"r(r;r<r5)
rr)r*r+�study�NONE�	BACKSLASH�FIRST�NEXT�BRACKETr:r,�testrrr	�test_study1�sJ

zPyParseTest.test_study1c

Cs�|j}|j}|j}|j}td�\}}}}}	tdddg�}
|
d|�|
d|�|
d|�|
d|�|
d	|	�f}x>|D]6}|j|jd
��||j�||�|j�WdQRXqjWdS)Nr8r:r"r<r!z%"""This is a continuation docstring.
z-'''This is a multiline-continued docstring.

za = (1 + 2) - 5 *\
z
   def function1(self, a,\
)r")	rrr#Zget_continuation_typer@rr&r"r<)
rr)r*r+ZgettyperBrCrDrErFr:r,rGrrr	�test_get_continuation_type�s

z&PyParseTest.test_get_continuation_typecCs�|j}|j}|j}|j}tdddddddg�}|dd	d	ddd
�|dd	dd
dd�|dd	dddd�|dd	d	ddd
�|dd	dddd�|dddddd�|dddddd�|d dd!ddd�|d"dd#ddd$�|d%d	d&dd'd(�|d)d	d*d+dd,�|d-d	d.d/dd0�|d1d	d2d3dd4�|d5d	d*d6dd
�|d7d	d	ddd
�f}x�|D]�}|j|jd8��h||j�|�||jd9�||j|j	�||j
|j�||j|j�||j
|j�||j|j�WdQRX�q(W|�|��dS):Nr:r"r6�end�lastch�openbracket�
bracketingr!r))rrz0'''This is a multiline continuation docstring.

�0�'))rr)rr=)rNrz # Comment\
�))rr)r=r=)rPrz #Comment\
za = (1 + 2) - 5 *\
��*))rr)rr=)�rz0
   def function1(self, a,
                 b):
r=�:))r=r)�r=)�.rz
   def function1(self, a,\
��,rU))r=r)rUr=z
   def function1(self, a,
�z3
   def function1(self, a,  # End of line comment.
�3))r=r)rUr=)rWr>)rZr=z7  a = ["first item",
  # Comment line
    "next item",
�7�))rr)r\r=)�r>)rQr=)�r>)�&r=)�*r>)�5r=z())
r�)))rr)rr=)r>r)r?rz)(
r?�())rr)r=r)r=r=z{)(]
r8�]))rr)rr=)r>r)r>r=)rrz:\a
z\a�
)r"r>)rrr#Z_study2rr&r"r(Z
stmt_startr6Zstmt_endrJrKZlastopenbracketposrLZstmt_bracketingrMr5)rr)r*r+rAr:r,rGrrr	�test_study2�sV


zPyParseTest.test_study2c
Cs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|d	d
�|dd�|dd�|d
d�|dd�f}|d�|�t��|�WdQRXx>|D]6}|j|jd��||j�||�|j	�WdQRXq�WdS)Nr:r"�linesz[x for x in a]
r=z[x
for x in a
r>z[x\
for x in a\
z[x
for x in a
]
r?z%
"""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\
"""
r8r!)r")
rrr#Zget_num_lines_in_stmtrr$�
IndexErrorr&r"rg)rr)r*r+�getlinesr:r,rGrrr	�test_get_num_lines_in_stmts(

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��|�WdQRXx$|D]}||j�||�|j�q�WdS)Nr:r"�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",
r>z1["first item",
  # Comment line
    "next item",
r=z(
rz(a
zdef function1(self, a, b):
)	rrr#Zcompute_bracket_indentrr$r%r"rk)rr)r*r+�indentr:r,rGrrr	�test_compute_bracket_indent/s,

z'PyParseTest.test_compute_bracket_indentc
Cs(|j}|j}|j}|j}d}xH|D]@}|j|d��*||�|�t��|�WdQRXWdQRXq"Wtdd�}|dd�|dd�|dd	�|d
d�|dd�|d
d�|dd�|dd�|dd�|dd�|dd�|dd�|dd�|dd�f}x>|D]6}	|j|	jd��||	j�||�|	j	�WdQRXq�WdS)N)zdef function1(self, a, b\
z    """ (\
za = #\
)r"r:)r"rkza = (1 + 2) - 5 *\
rza = 1 + 2 - 5 *\
z    a = 1 + 2 - 5 *\
rnz  a = "spam"\
r\z
  a = \
"a"\
z  a = #\
"a"\
r8za == \
r>za != \
z\
z    \
z	\
za\
r?z{}\
z(1 + 2) - 5 *\
)
rrr#Zcompute_backslash_indentr&r$r%rr"rk)
rr)r*r+ro�errorsr"r:r,rGrrr	�test_compute_backslash_indentOs:



z)PyParseTest.test_compute_backslash_indentc
Cs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|dd	�|d
d	�|dd	�|dd	�f}x>|D]6}|j|jd
��||j�||�|j�WdQRXqhWdS)Nr:r"ror!z	def a():
z
	def a():
rz
    def a():
z    z    def a(
z
	
    def a(
z	
    # Comment.
)r")rrr#Zget_base_indent_stringrr&r"ro)rr)r*r+Z
baseindentr:r,rGrrr	�test_get_base_indent_stringvs 

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}x<|D]4}|j|jd��||j�|�|��WdQRXq�WdS)Nr:r"�assert_z	def a():
z0
   def function1(self, a,
                 b):
z:
za:
z):
z(:
z":
z
   def function1(self, a,
z!def function1(self, a):
    pass
z
# A comment:
z"""A docstring:
)r")	�
assertTrue�assertFalserr#Zis_block_openerrr&r"rt)	r�yes�nor*r+�openerr:r,rGrrr	�test_is_block_opener�s,

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
}x<|D]4}|j|jd��||j�|�|��WdQRXq�WdS)Nr:r"rtzreturn
z	break
z  continue
z     raise
z	pass    
zpass	
z	return #
zraised
z
returning
z	# return
z	"""break
z
"continue
z!def function1(self, a):
    pass
)r")	rurvrr#Zis_block_closerrr&r"rt)	rrwrxr*r+Zcloserr:r,rGrrr	�test_is_block_closer�s.

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
}x>|D]6}|j|jd��||j�||�|j�WdQRXq�WdS)Nr:r"�bracketr!))rrza
z()()
))rr)rr=)r>r)r>r=)rrz(
)()
))rr)rr=)r?r)r?r=)r8rz()
()
))r?r)r?r=)r8rz()(
)
))rr)rr=)r>r)r>r=)r8rz(())
))rr)rr=)r=r>)r?r=)rrz(
())
))rr)rr=)r>r>)rr=)r8rz{)(]
z(((())
))rr)rr=)r=r>)r>r?)r?r)r8r?)r\r>)r")rrr#Zget_last_stmt_bracketingrr&r"r|)rr)r*r+rMr:r,rGrrr	�test_get_last_stmt_bracketing�s(

z)PyParseTest.test_get_last_stmt_bracketingN)rrr�classmethodrrr r-r7r9rHrIrfrjrprrrsrzr{r}rrrr	rs @2= 'r�__main__r>)�	verbosity)�__doc__ZidlelibrZunittest�collectionsrZTestCaserrr�mainrrrr	�<module>sK

?>