Your IP : 18.219.255.63


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_hyperparser.cpython-36.pyc

3

� fx#�@sxdZddlmZddlZddlmZddlmZmZddl	m
Z
Gdd�d�ZGd	d
�d
ej�Z
edkrtejdd
�dS)zTest hyperparser, coverage 98%.�)�HyperParserN)�requires)�Tk�Text)�EditorWindowc@s eZdZdd�ZejZejZdS)�DummyEditwincCs"||_d|_d|_d|_d|_dS)N�T�2����)r	r
r)�textZindentwidthZtabwidth�context_use_ps1Znum_context_lines)�selfr�r�G/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_hyperparser.py�__init__
s
zDummyEditwin.__init__N)�__name__�
__module__�__qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrr	src@sxeZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�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é"cCs6td�t�|_|jj�t|j�|_t|j�|_dS)NZgui)rr�rootZwithdrawrrr�editwin)�clsrrr�
setUpClass%s

zHyperParserTest.setUpClasscCs|`|`|jj�|`dS)N)rrrZdestroy)rrrr�
tearDownClass-s
zHyperParserTest.tearDownClasscCs|jjd|j�dS)N�insert)rr�code)rrrr�setUp3szHyperParserTest.setUpcCs|jjdd�d|j_dS)Nz1.0�endT)r�deleterr
)rrrr�tearDown6szHyperParserTest.tearDowncCst|j|�S)z>
        Return a parser object with index at 'index'
        )rr)r�indexrrr�
get_parser:szHyperParserTest.get_parsercCs�|jt�� }|jjddd�|jd�}WdQRX|jdt|j��d|j_	|jd�}|j
|j|jjdd��|jj
d|jjdd�d	�|jd
�}dS)z6
        test corner cases in the init method
        Zconsolez1.0z1.endz1.5NZprecedesFr�z54.5)�assertRaises�
ValueErrorrZtag_addr"�assertIn�str�	exceptionrr
�assertEqualZrawtext�getr)r�ve�prrr�	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|j��dS)Nz1.0z1.4z2.3z3.3z3.7z4.6z12.54)r"�assertFalseZis_in_string�
assertTrue)rr*r,rrr�test_is_in_stringTsz!HyperParserTest.test_is_in_stringcCs�|j}|d�}|j|j��|d�}|j|j��|d�}|j|j��|d�}|j|j��|d�}|j|j��|d�}|j|j��dS)Nz1.0z1.1z2.5z3.4z3.6z4.14)r"r/Z
is_in_coder.)rr*r,rrr�test_is_in_codefszHyperParserTest.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|jdd�S)NF)�	mustclose)�get_surrounding_brackets)�parserrrr�without_mustcloseyszGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosecSs|jdd�S)NT)r2)r3)r4rrr�with_mustclose~szDHyperParserTest.test_get_surrounding_bracket.<locals>.with_mustclosez3.2z5.6�5.4�5.25z5.23�5.21�5.24z6.15�6.4�6.endz9.end)r7r8)r9r:)r;r<)r"ZassertIsNoneZassertTupleEqual)rr*r5r6r,rrr�test_get_surrounding_bracketvs$z,HyperParserTest.test_get_surrounding_bracketcCs�|j}|d�}|j|j�d�|d�}|jt��}|j�WdQRX|jdt|j��|d�}|j|j�d�|d�}|j|j�d�|d	�}|j|j�d
�|d�}|j|j�d�|d�}|j|j�d
�|d�}|j|j�d�|d�}|jt��}|j�WdQRX|jdt|j��|d�}|j|j�d
�|d�}|j|j�d
�|d�}|j|j�d
�|d�}|j|j�d
�|d�}|j|j�d�|d�}|j|j�d�dS)Nz4.2zy z4.7zis inside a codez5.25z	range(10)z6.7�pyz6.8�z7.9z8.endz	x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11�Falsez12.6ucliché)r"r)Zget_expressionr$r%r&r'r()rr*r,r+rrr�test_get_expression�sFz#HyperParserTest.test_get_expressioncCs�dd�}|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��|jtjddd�td��|jtjddd�td��|jtjddd�td��|j|d��|j|d��|j|d��|j|d��|j|d��|j|d ��|j|d!��|j|d"��dS)#NcSsJtj|dt|��}|t|�kr"dS|dkr.dSdj|t|��}t|��dS)NrTFz'Unexpected result: {} (expected 0 or {})r�_eat_identifier�len�format�	Exception)�	candidate�resultZerr_msgrrr�is_valid_id�sz8HyperParserTest.test_eat_identifier.<locals>.is_valid_idZ2notidZvalid_idZ	_valid_idZ	valid_id_Z
_2valid_id�Truer@�None�for�import�returnZclicheuclichéua٢Z2au٢aua²z+ varr��varz+varr#z.var�+� �:�?�^�\�"z
"a string")r.r/r)rrBrC)rrHrrr�test_eat_identifier�s:
z#HyperParserTest.test_eat_identifiercCs*tj}�xtdd�D�]}|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|�d�qWdS)N���ar�é�2rP)rrB�ranger))rZeat_idZlengthrrr�#test_eat_identifier_various_lengthss     z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr�classmethodrrrr r"r-r0r1r=rArWr^rrrrrs!49r�__main__�)�	verbosity)�__doc__Zidlelib.hyperparserrZunittestZtest.supportrZtkinterrrZidlelib.editorrrZTestCaserr�mainrrrr�<module>s

?>