Viewing File: /opt/alt/python35/lib64/python3.5/idlelib/idle_test/__pycache__/test_hyperparser.cpython-35.pyc



Yf#@sdZddlZddlmZddlmZmZddlmZddl	m
Z
GdddZGd	d
d
ejZ
edkrejdd
dS)z Unittest for idlelib.HyperParserN)requires)TkText)EditorWindow)HyperParserc@s.eZdZddZejZejZdS)DummyEditwincCs1||_d|_d|_d|_d|_dS)NT2)r	r
r)textZindentwidthZtabwidthcontext_use_ps1Znum_context_lines)selfrrG/opt/alt/python35/lib64/python3.5/idlelib/idle_test/test_hyperparser.py__init__	s
				zDummyEditwin.__init__N)__name__
__module____qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrrs	rc@seZdZdZeddZeddZddZdd	Zd
dZ	dd
Z
ddZddZddZ
ddZddZddZdS)HyperParserTestu#"""This is a module docstring"""
# this line is a comment
x = "this is a string"
y = 'this is also a string'
l = [i for i in range(10)]
m = [py*py for # comment
       py in l]
x.__len__
z = ((r'asdf')+('a')))
[x for x in
for = False
cliché = "this is a string with unicode, what a cliché"cCsKtdt|_|jjt|j|_t|j|_dS)NZgui)rrrootZwithdrawrrreditwin)clsrrr
setUpClass$s


zHyperParserTest.setUpClasscCs#|`|`|jj|`dS)N)rrrZdestroy)rrrr
tearDownClass,s
zHyperParserTest.tearDownClasscCs|jjd|jdS)Ninsert)rrcode)rrrrsetUp2szHyperParserTest.setUpcCs#|jjddd|j_dS)Nz1.0endT)rZdeleterr
)rrrrtearDown5szHyperParserTest.tearDowncCst|j|S)z>
        Return a parser object with index at 'index'
        )rr)rindexrrr
get_parser9szHyperParserTest.get_parsercCs|jt,}|jjddd|jd}WdQRX|jdt|jd|j_	|jd}|j
|j|jjdd|jj
d|jjddd	|jd
}dS)z6
        test corner cases in the init method
        Zconsolez1.0z1.endz1.5NZprecedesFrz54.5)assertRaises
ValueErrorrZtag_addr!assertInstr	exceptionrr
assertEqualZrawtextgetr)rveprrr	test_init?s"&zHyperParserTest.test_initcCs|j}|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|jdS)Nz1.0z1.4z2.3z3.3z3.7z4.6z12.54)r!assertFalseZis_in_string
assertTrue)rr)r+rrrtest_is_in_stringSs	z!HyperParserTest.test_is_in_stringcCs|j}|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|j|d}|j|jdS)Nz1.0z1.1z2.5z3.4z3.6z4.14)r!r.Z
is_in_coder-)rr)r+rrrtest_is_in_codees	zHyperParserTest.test_is_in_codecCs:|j}dd}dd}|d}|j|||j|||d}|j||d|j|||||d	}|j||d|j|||||d}|j||d|j|||d}|j|||j||dS)NcSs|jddS)N	mustcloseF)get_surrounding_brackets)parserrrrwithout_mustclosexszGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosecSs|jddS)Nr1T)r2)r3rrrwith_mustclose}szDHyperParserTest.test_get_surrounding_bracket.<locals>.with_mustclosez3.2z5.65.45.25z5.235.215.24z6.156.46.endz9.end)r6r7)r8r9)r:r;)r!ZassertIsNoneZassertTupleEqual)rr)r4r5r+rrrtest_get_surrounding_bracketus$	z,HyperParserTest.test_get_surrounding_bracketcCsW|j}|d}|j|jd|d}|jt}|jWdQRX|jdt|j|d}|j|jd|d}|j|jd|d	}|j|jd
|d}|j|jd|d}|j|jd
|d}|j|jd|d}|jt}|jWdQRX|jdt|j|d}|j|jd
|d}|j|jd
|d}|j|jd
|d}|j|jd
|d}|j|jd|d}|j|jddS)Nz4.2zy z4.7zis inside a codez5.25z	range(10)z6.7pyz6.8z7.9z8.endz	x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11Falsez12.6ucliché)r!r(Zget_expressionr#r$r%r&r')rr)r+r*rrrtest_get_expressionsF	z#HyperParserTest.test_get_expressioncCsZdd}|j|d|j|d|j|d|j|d|j|d|j|d|j|d	|j|d
|j|d|j|d|j|d
|j|d|j|d|j|d|j|d|j|d|j|d|jtjdddtd|jtjdddtd|jtjdddtd|j|d|j|d|j|d|j|d|j|d|j|d |j|d!|j|d"dS)#NcSsitj|dt|}|t|kr1dS|dkrAdSdj|t|}t|dS)NrTFz'Unexpected result: {} (expected 0 or {})r_eat_identifierlenformat	Exception)	candidateresultZerr_msgrrris_valid_idsz8HyperParserTest.test_eat_identifier.<locals>.is_valid_idZ2notidZvalid_idZ	_valid_idZ	valid_id_Z
_2valid_idTruer?NoneforimportreturnZclicheuclichéua٢Z2au٢aua²z+ varrvarz+varr"z.var+ :?^\"z
"a string")r-r.r(rrArB)rrGrrrtest_eat_identifiers:
%%%z#HyperParserTest.test_eat_identifiercCswtj}xgtddD]V}|j|d|d|||j|d|d|||j|dd|dd|||j|dd|dd|||j|dd|dd|||j|d|ddd|||j|d|d|d|j|dd|dd|d|j|dd|dd|dqWdS)Naré2rO)rrAranger()rZeat_idZlengthrrr#test_eat_identifier_various_lengthss	  (((( (z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrrclassmethodrrrrr!r,r/r0r<r@rVr]rrrrrs!49r__main__	verbosity)__doc__ZunittestZtest.supportrZtkinterrrZidlelib.EditorWindowrZidlelib.HyperParserrrZTestCaserrmainrrrr<module>s
Back to Directory File Manager