Your IP : 18.188.114.150


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/test_pyparse.cpython-36.pyc

3

� f�H�@s`dZddlmZddlZddlmZGdd�dej�ZGdd�dej�Ze	d	kr\ej
d
d�dS)zTest pyparse, coverage 96%.�)�pyparseN)�
namedtuplec@seZdZdd�Zdd�ZdS)�ParseMapTestcCs`dd�dD�}tj|�}|j|td�td��|j|td�td��|j|dtd��dS)NcSsi|]}t|�t|��qS�)�ord)�.0�crr�C/opt/alt/python36/lib64/python3.6/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$tjdd�}|jdjtj�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$|j|jjd�|j|jjd�dS)Nr)rrrr)rrrr	�	test_init"szPyParseTest.test_initcCs~|j}|j}|j}|jt��|d�WdQRXd}xD|D]<}|j|d��&||�||j|�||jd�WdQRXq:WdS)Nr��a
)�stringr)r!r")rr�set_code�assertRaises�AssertionError�subTest�code�study_level)r�eq�p�setcode�testsr#rrr	�
test_set_code&s
zPyParseTest.test_set_codecCs�|j}|j}|j}|j}|d�|j|��|j|dd�d��||dd�d�d�||dd�d�d�||dd�d�d	�||d
d�d�d�|d�||dd�d�d�||d
d�d�d�||dd�d�d	�||dd�d�d�dS)Nzm"""This is a module docstring"""
class C():
    def __init__(self, a,
                 b=True):
        pass
cSsdS)NTr)�indexrrr	�<lambda>Ksz8PyParseTest.test_find_good_parse_start.<locals>.<lambda>)Zis_char_in_stringcSsdS)NFr)r/rrr	r0Os�,cSs|dkS)Nr1r)r/rrr	r0SscSs|dkS)Nr1r)r/rrr	r0Vs�!cSs|dkS)Nr1r)r/rrr	r0Ysz\"""This is a module docstring"""
class C():
    def __init__(self, a, b=True):
        pass
cSsdS)NFr)r/rrr	r0bscSs|dkS)Nr1r)r/rrr	r0cscSs|dkS)Nr1r)r/rrr	r0dscSs|dkS)Nr1r)r/rrr	r0gs)rrr$Zfind_good_parse_start�assertIsNone)rr*r+r,�startrrr	�test_find_good_parse_start8s z&PyParseTest.test_find_good_parse_startcCspd}|j}|j|�|jt��|jd�WdQRX|jd�|j|j|�|jd�|j|j|dd��dS)Nzm"""This is a module docstring"""
class C():
    def __init__(self, a,
                 b=True):
        pass
�rr1)rr$r%r&Zset_lorr()rr(r+rrr	�test_set_lois


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|j|��dS) Nr6�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)r9r:r3)
rr*r+r,�study�NONE�	BACKSLASH�FIRST�NEXT�BRACKETr8r-�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)Nr6r8r#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,Zgettyper@rArBrCrDr8r-rErrr	�test_get_continuation_type�s

z&PyParseTest.test_get_continuation_typecCs�|j}|j}|j}|j}tdddddddg�}|dd	d	ddd8�|d
d	dddd<�|dd	dddd@�|dd	d	dddB�|dd	ddddF�|dd
ddddJ�|dd
ddddM�|dd
ddddP�|d d
d!dddU�|d#d	d$dd%d^�|d+d	dd,ddc�|d.d	d-d/d
dg�|d0d	d1d2ddm�|d3d	dd4ddo�|d5d	d	dddq�f}x�|D]�}|j|jd6��h||j�|�||jd"�||j|j	�||j
|j�||j|j�||j
|j�||j|j�WdQRX�q(W|j|��dS)rNr8r#r4�end�lastch�openbracket�
bracketingr!rz1'''This is a multiline continutation docstring.

�1�'r;z # Comment\
�z #Comment\
za = (1 + 2) - 5 *\
��*r�z0
   def function1(self, a,
                 b):
�0�:��.z
   def function1(self, a,\
��,z
   def function1(self, a,
�z3
   def function1(self, a,  # End of line comment.
�3r<z7  a = ["first item",
  # Comment line
    "next item",
�7����&�*�5z())
�)r=z)(
�(z{)(]
r6�]z:\a
z\a�
)r#�rr)re�rr�rr;�rLr)rfrgrh�rr�r;r;�rNr)rirjrk�rr)rl�rr�rr;�rQr)rmrnro�r;r�rTr;�rUr)rprqrr�r;r�rTr;)rsrt�r;r�rTr;)rurv�r;r�rTr;�rVr<�rYr;)rwrxryrz�rr�r[r;�r\r<�rOr;�r]r<�r^r;�r_r<�r`r;)r{r|r}r~rr�r�r��rr�rr;�r<r�r=r)r�r�r�r��rr�r;r�r;r;)r�r�r��rr�rr;�r<r�r<r;�rr)r�r�r�r�r��rr)r��rr)r�)rrr$Z_study2rr'r#r)Z
stmt_startr4Zstmt_endrHrIZlastopenbracketposrJZstmt_bracketingrKr3)rr*r+r,r?r8r-rErrr	�test_study2�sX


zPyParseTest.test_study2cCs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|d	d
�|dd�|dd�|d
d�|dd�f}|d�|jt��|�WdQRXx>|D]6}|j|jd��||j�||�|j	�WdQRXq�WdS)Nr8r#�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\
"""
r6r!)r#)
rrr$Zget_num_lines_in_stmtrr%�
IndexErrorr'r#r�)rr*r+r,�getlinesr8r-rErrr	�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�|jt��|�WdQRXx$|D]}||j�||�|j�q�WdS)Nr8r#�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#r�)rr*r+r,�indentr8r-rErrr	�test_compute_bracket_indent s,

z'PyParseTest.test_compute_bracket_indentc
Cs(|j}|j}|j}|j}d}xH|D]@}|j|d��*||�|jt��|�WdQRXWdQRXq"Wtdd�}|dd	�|d
d	�|dd�|d
d�|dd	�|dd�|dd�|dd�|dd�|dd�|dd�|dd�|dd	�|dd�f}x>|D]6}	|j|	jd��||	j�||�|	j	�WdQRXq�WdS)N�def function1(self, a, b\
�    """ (\
�a = #\
)r#r8r#r�za = (1 + 2) - 5 *\
rza = 1 + 2 - 5 *\
z    a = 1 + 2 - 5 *\
r�z  a = "spam"\
r[z
  a = \
"a"\
z  a = #\
"a"\
r6za == \
r<za != \
z\
z    \
z	\
za\
r=z{}\
z(1 + 2) - 5 *\
)r�r�r�)r#r�)
rrr$Zcompute_backslash_indentr'r%r&rr#r�)
rr*r+r,r��errorsr#r8r-rErrr	�test_compute_backslash_indent@s>



z)PyParseTest.test_compute_backslash_indentcCs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|dd	�|d
d	�|dd	�|dd	�f}x>|D]6}|j|jd
��||j�||�|j�WdQRXqhWdS)Nr8r#r�r!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#r�)rr*r+r,Z
baseindentr8r-rErrr	�test_get_base_indent_stringgs 

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�|j|��WdQRXq�WdS)Nr8r#�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#r�)	r�yes�nor+r,�openerr8r-rErrr	�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�|j|��WdQRXq�WdS)Nr8r#r�zreturn
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#)	r�r�rr$Zis_block_closerrr'r#r�)	rr�r�r+r,Zcloserr8r-rErrr	�test_is_block_closer�s.

z PyParseTest.test_is_block_closercCs�|j}|j}|j}|j}tdddg�}|dd�|dd�|dd�|dd%�|dd)�|dd/�|dd5�|dd;�|ddA�|ddI�f
}x@|D]8}|j|jd��||j�||�|j�WdQRX�q�WdS)JNr8r#�bracketr!rza
z()()
r;r<rz(
)()
r=r6z()
()
z()(
)
z(())
z(
())
z{)(]
z(((())
r[)r#�rr)r��rr)r��rr�rr;�r<r�r<r;�rr)r�r�r�r�r��rr�rr;�r=r�r=r;�r6r)r�r�r�r�r��r=r�r=r;�r6r)r�r�r��rr�rr;�r<r�r<r;�r6r)r�r�r�r�r��rr�rr;�r;r<�r=r;�rr)r�r�r�r�r��rr�rr;�r<r<�rr;�r6r)r�r�r�r�r��rr�rr;�r<r�r<r;�rr)r�r�r�r�r��rr�rr;�r;r<�r<r=�r=r�r6r=�r[r<)r�r�r�r�r�r�r�)rrr$Zget_last_stmt_bracketingrr'r#r�)rr*r+r,rKr8r-rErrr	�test_get_last_stmt_bracketing�s(

z)PyParseTest.test_get_last_stmt_bracketingN)rrr�classmethodrrr r.r5r7rFrGr�r�r�r�r�r�r�r�rrrr	rs 12= 'r�__main__r<)�	verbosity)�__doc__ZidlelibrZunittest�collectionsrZTestCaserrr�mainrrrr	�<module>s<

?>