HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/idlelib/idle_test/__pycache__/test_hyperparser.cpython-310.pyc
o

�iz#�@s|dZddlmZddlZddlmZddlmZmZddl	m
Z
Gdd�d�ZGd	d
�d
ej�Z
edkr<ejdd
�dSdS)zTest hyperparser, coverage 98%.�)�HyperParserN)�requires)�Tk�Text)�EditorWindowc@s eZdZdd�ZejZejZdS)�DummyEditwincCs"||_d|_d|_d|_d|_dS)N��>>>)�2i�i�)�textZindentwidthZtabwidth�prompt_last_lineZnum_context_lines)�selfr�r�?/usr/local/lib/python3.10/idlelib/idle_test/test_hyperparser.py�__init__
s

zDummyEditwin.__init__N)�__name__�
__module__�__qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrr	s
rc@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�|_|j��t|j�|_t|j�|_dS)NZgui)rr�rootZwithdrawrrr�editwin��clsrrr�
setUpClass%s

zHyperParserTest.setUpClasscCs|`|`|j��|`dS)N)rrrZdestroyrrrr�
tearDownClass-s
zHyperParserTest.tearDownClasscCs|j�d|j�dS)N�insert)rr�code�r
rrr�setUp3szHyperParserTest.setUpcCs|j�dd�d|j_dS)N�1.0�endr	)r�deleterrrrrr�tearDown6szHyperParserTest.tearDowncCst|j|�S)z>
        Return a parser object with index at 'index'
        )rr)r
�indexrrr�
get_parser:szHyperParserTest.get_parsercCs�|�t��}|j�ddd�|�d�}Wd�n1swY|�dt|j��d|j_	|�d�}|�
|j|j�dd��|j�
d|j�dd�d	�|�d
�}dS)z6
        test corner cases in the init method
        Zconsolerz1.endz1.5N�precedes�r �z54.5)�assertRaises�
ValueErrorrZtag_addr$�assertIn�str�	exceptionrr�assertEqualZrawtext�getr)r
�ve�prrr�	test_init@s�
zHyperParserTest.test_initcCs�|j}|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���dS)Nrz1.4z2.3z3.3z3.7z4.6z12.54)r$�assertFalseZis_in_string�
assertTrue�r
r.r0rrr�test_is_in_stringTsz!HyperParserTest.test_is_in_stringcCs�|j}|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���dS)Nrz1.1z2.5z3.4z3.6z4.14)r$r3Z
is_in_coder2r4rrr�test_is_in_codefszHyperParserTest.test_is_in_codecCs�|j}dd�}dd�}|d�}|�||��|�||��|d�}|�||�d�|�||�||��|d�}|�||�d	�|�||�||��|d
�}|�||�d�|�||��|d�}|�||��|�||��dS)
NcS�|jdd�S)NF�Z	mustclose�Zget_surrounding_brackets��parserrrr�without_mustclosey�zGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosecSr7)NTr8r9r:rrr�with_mustclose~r=zDHyperParserTest.test_get_surrounding_bracket.<locals>.with_mustclosez3.2z5.6)z5.4�5.25z5.23)z5.21z5.24z6.15)z6.4z6.endz9.end)r$ZassertIsNoneZassertTupleEqual)r
r.r<r>r0rrr�test_get_surrounding_bracketvs$z,HyperParserTest.test_get_surrounding_bracketcCs�|j}|d�}|�|��d�|d�}|�t��}|��Wd�n1s'wY|�dt|j��|d�}|�|��d�|d�}|�|��d�|d	�}|�|��d
�|d�}|�|��d�|d�}|�|��d
�|d�}|�|��d�|d�}|�t��}|��Wd�n1s�wY|�dt|j��|d�}|�|��d
�|d�}|�|��d
�|d�}|�|��d
�|d�}|�|��d
�|d�}|�|��d�|d�}|�|��d�dS)Nz4.2zy z4.7zis inside a coder?z	range(10)z6.7�pyz6.8r&z7.9z8.endz	x.__len__z9.13zr'asdf'z9.17z10.0z10.6z10.11z11.3z11.11�Falsez12.6�cliché)r$r-Zget_expressionr(r)r*r+r,)r
r.r0r/rrr�test_get_expression�sJ
�
�z#HyperParserTest.test_get_expressioncCs�dd�}|�|d��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d	��|�|d
��|�|d��|�|d��|�|d
��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d��|�t�ddd�td��|�t�ddd�td��|�t�ddd�td��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d ��|�|d!��|�|d"��dS)#NcSsFt�|dt|��}|t|�krdS|dkrdSd�|t|��}t|��)NrTFz'Unexpected result: {} (expected 0 or {})r�_eat_identifier�len�format�	Exception)�	candidate�result�err_msgrrr�is_valid_id�s�z8HyperParserTest.test_eat_identifier.<locals>.is_valid_idZ2notidZvalid_idZ	_valid_idZ	valid_id_Z
_2valid_id�TruerB�None�for�import�returnZclicherCua٢Z2au٢aua²z+ varr��varz+varr'z.var�+� �:�?�^�\�"z
"a string")r2r3r-rrErF)r
rLrrr�test_eat_identifier�s:
z#HyperParserTest.test_eat_identifiercCs"tj}tdd�D]�}|�|d|d|�|�|�|d|d|�|�|�|dd|dd|�|�|�|dd|dd|�|�|�|dd|dd|�|�|�|d|ddd|�|�|�|d|d|�d�|�|dd|dd|�d�|�|dd|dd|�d�qdS)N���ar�é�2rT)rrE�ranger-)r
Zeat_id�lengthrrr�#test_eat_identifier_various_lengthss     "�z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr�classmethodrrrr"r$r1r5r6r@rDr[rcrrrrrs"�

!49r�__main__�)�	verbosity)�__doc__Zidlelib.hyperparserrZunittestZtest.supportr�tkinterrrZidlelib.editorrrZTestCaserr�mainrrrr�<module>s�