• File: test_pyparse.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_pyparse.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 13.55 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

NjK@s`dZddlmZddlZddlmZGdddejZGdddejZe	d	kr\ej
d
ddS)zTest pyparse, coverage 96%.)pyparseN)
namedtuplec@seZdZddZddZdS)ParseMapTestcCs`dddD}t|}||tdtd||tdtd||dtddS)NcSsi|]}t|t|qS)ord).0crrC/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_pyparse.py
<dictcomp>sz.ParseMapTest.test_parsemap.<locals>.<dictcomp>z 	

	axi)rZParseMapassertEqualr)selfZ	keepwhitemappingrrr	
test_parsemap
s

zParseMapTest.test_parsemapcCs$tdd}|dtjddS)Nz	 a([{b}])b"c'd
zxxx(((x)))x"x'x
)rParserr	translateZtrans)rparserrrr	
test_transszParseMapTest.test_transN)__name__
__module____qualname__rrrrrr	rsrc@seZdZeddZeddZddZddZd	d
ZddZ	d
dZ
ddZddZddZ
ddZddZddZddZddZdd Zd!S)"PyParseTestcCstjddd|_dS)Nr)indentwidthtabwidth)rrr)clsrrr	
setUpClassszPyParseTest.setUpClasscCs|`dS)N)r)rrrr	
tearDownClassszPyParseTest.tearDownClasscCs$||jjd||jjddS)Nr)rrrr)rrrr		test_init"szPyParseTest.test_initc
Cs~|j}|j}|j}|t|dWdQRXd}xD|D]<}|j|d&||||j|||jdWdQRXq:WdS)Nr)za
)stringr)rrset_codeassertRaisesAssertionErrorsubTestcodestudy_level)reqpsetcodetestsr"rrr	
test_set_code&s
zPyParseTest.test_set_codec	CsB|j}|j}|j}|j}dd}|d|||d|d|||d|d|t|WdQRX|t|dWdQRX||dd	d
|||d||dd	d
d||d
d	d
d||dd	d
d|d|||d||dd	d
d||dd	d
d||dd	d
ddS)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|dWdQRX|d||j||d||j|dddS)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
WdQRXqpW||dS) Nr8TestInfor"	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_study1rangerr&r"r(r;r<r5)
rr)r*r+studyNONE	BACKSLASHFIRSTNEXTBRACKETr:r,testrrr	test_study1sJ

zPyParseTest.test_study1c

Cs|j}|j}|j}|j}td\}}}}}	tdddg}
|
d||
d||
d||
d||
d	|	f}x>|D]6}|j|jd
||j|||jWdQRXqjWdS)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_types

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|jd8h||j|||jd9||j|j	||j
|j||j|j||j
|j||j|jWdQRXq(W||dS):Nr:r"r6endlastchopenbracket
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_study2sV


zPyParseTest.test_study2c
Cs|j}|j}|j}|j}tdddg}|dd|dd|dd|d	d
|dd|dd|d
d|ddf}|d|t|WdQRXx>|D]6}|j|jd||j|||j	WdQRXqWdS)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|ddf}|d|t|WdQRXx$|D]}||j|||jqWdS)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|ddf}x>|D]6}	|j|	jd||	j|||	j	WdQRXqWdS)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+roerrorsr"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|||jWdQRXqhWdS)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||WdQRXqWdS)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")	
assertTrueassertFalserr#Zis_block_openerrr&r"rt)	ryesnor*r+openerr:r,rGrrr	test_is_block_openers,

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||WdQRXqWdS)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_closers.

z PyParseTest.test_is_block_closercCs|j}|j}|j}|j}tdddg}|dd|dd|dd|d	d
|dd|d
d|dd|dd|dd|ddf
}x>|D]6}|j|jd||j|||jWdQRXqWdS)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_bracketings(

z)PyParseTest.test_get_last_stmt_bracketingN)rrrclassmethodrrr r-r7r9rHrIrfrjrprrrsrzr{r}rrrr	rs @2= 'r__main__r>)	verbosity)__doc__ZidlelibrZunittestcollectionsrZTestCaserrrmainrrrr	<module>sK