Your IP : 3.12.146.108


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/idle_test/__pycache__/test_hyperparser.cpython-34.pyo

�
e fe#�@s�dZddlZddlmZddlmZmZddlmZddl	m
Z
Gdd�d�ZGd	d
�d
ej�Z
edkr�ejdd
�ndS)z Unittest for idlelib.HyperParser�N)�requires)�Tk�Text)�EditorWindow)�HyperParserc@s.eZdZdd�ZejZejZdS)�DummyEditwincCs1||_d|_d|_d|_d|_dS)N�T�2����)r	r
r)�textZindentwidthZtabwidth�context_use_ps1Znum_context_lines)�selfr�r�G/opt/alt/python34/lib64/python3.4/idlelib/idle_test/test_hyperparser.py�__init__	s
				zDummyEditwin.__init__N)�__name__�
__module__�__qualname__rrZ_build_char_in_string_funcZis_char_in_stringrrrrrs	rc@s�eZdZdZedd��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é"cCs>td�t�|_t|j�|_t|j�|_dS)NZgui)rr�rootrr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�setUp1szHyperParserTest.setUpcCs#|jjdd�d|j_dS)Nz1.0�endT)rZdeleterr
)rrrr�tearDown4szHyperParserTest.tearDowncCst|j|�S)z>
        Return a parser object with index at 'index'
        )rr)r�indexrrr�
get_parser8szHyperParserTest.get_parsercCs�|jt��,}|jjddd�|jd�}WdQX|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_stringRs	z!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_codeds	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|jdd�S)N�	mustcloseF)�get_surrounding_brackets)�parserrrr�without_mustclosewszGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosecSs|jdd�S)Nr1T)r2)r3rrr�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)r6r7)r8r9)r:r;)r!ZassertIsNoneZassertTupleEqual)rr)r4r5r+rrr�test_get_surrounding_bracketts$	z,HyperParserTest.test_get_surrounding_bracketcCsU|j}|d�}|j|j�d�|d�}|jt��}|j�WdQX|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�WdQX|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_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��|jtjddd�td��|jtjddd�td��|jtjddd�td��|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_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(rrArB)rrGrrr�test_eat_identifier�s:
%%%z#HyperParserTest.test_eat_identifiercCswtj}xgtdd�D]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|�d�qWdS)N���ar�é�2rO)rrA�ranger()rZeat_idZlengthrrr�#test_eat_identifier_various_lengthss	  (((( (z3HyperParserTest.test_eat_identifier_various_lengthsN)rrrr�classmethodrrrrr!r,r/r0r<r@rVr]rrrrrs!49r�__main__�	verbosity�)�__doc__ZunittestZtest.supportrZtkinterrrZidlelib.EditorWindowrZidlelib.HyperParserrrZTestCaserr�mainrrrr�<module>s�

?>