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.opt-2.pyc
o

�iz#�@sz	ddlmZddlZddlmZddlmZmZddlm	Z	Gdd�d�Z
Gdd	�d	ej�Ze
d
kr;ejdd�dSdS)
�)�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|�Sr)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)
NZconsoler z1.endz1.5�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)Nr z1.4z2.3z3.3z3.7z4.6z12.54)r%�assertFalseZis_in_string�
assertTrue�r
r/r1rrr�test_is_in_stringTsz!HyperParserTest.test_is_in_stringcCs�|j}|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���|d�}|�|���dS)Nr z1.1z2.5z3.4z3.6z4.14)r%r4Z
is_in_coder3r5rrr�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_mustclosecSr8)NTr9r:r;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?r1rrr�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/r1r0rrr�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�TruerC�None�for�import�returnZclicherDua٢Z2au٢aua²z+ varr��varz+varr(z.var�+� �:�?�^�\�"z
"a string")r3r4r.rrFrG)r
rMrrr�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�é�2rU)rrF�ranger.)r
Zeat_id�lengthrrr�#test_eat_identifier_various_lengthss     "�z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr�classmethodrrrr#r%r2r6r7rArEr\rdrrrrrs"�

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