Your IP : 18.227.72.27
��Yf�# � @ s� d Z d d l Z d d l m Z d d l m Z m Z d d l m Z d d l m
Z
Gd d � d � Z Gd d
� d
e j � Z
e d k r� e j d d
� d S)z Unittest for idlelib.HyperParser� N)�requires)�Tk�Text)�EditorWindow)�HyperParserc @ s. e Z d Z d d � Z e j Z e j Z d S)�DummyEditwinc C s1 | | _ d | _ d | _ d | _ d | _ d S)N� T�2 �� �� )r r
r )�textZindentwidthZtabwidth�context_use_ps1Znum_context_lines)�selfr � r �G/opt/alt/python35/lib64/python3.5/idlelib/idle_test/test_hyperparser.py�__init__ s
zDummyEditwin.__init__N)�__name__�
__module__�__qualname__r r Z_build_char_in_string_funcZis_char_in_stringr r r r r s r c @ s� e Z d Z d Z e d d � � Z e d d � � Z d d � Z d d � Z d
d � Z d d
� Z
d d � Z d d � Z d d � Z
d d � Z d d � Z d d � Z d S)�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é"c C sK t d � t � | _ | j j � t | j � | _ t | j � | _ d S)NZgui)r r �rootZwithdrawr r r �editwin)�clsr r r �
setUpClass$ s
zHyperParserTest.setUpClassc C s# | ` | ` | j j � | ` d S)N)r r r Zdestroy)r r r r �
tearDownClass, s
zHyperParserTest.tearDownClassc C s | j j d | j � d S)N�insert)r r �code)r r r r �setUp2 s zHyperParserTest.setUpc C s# | j j d d � d | j _ d S)Nz1.0�endT)r Zdeleter r
)r r r r �tearDown5 s zHyperParserTest.tearDownc C s t | j | � S)z>
Return a parser object with index at 'index'
)r r )r �indexr r r �
get_parser9 s zHyperParserTest.get_parserc C s� | j t � �, } | j j d d d � | j d � } Wd QRX| j d t | j � � d | j _ | j d � } | j
| j | j j d d � � | j j
d | j j d d � d � | j d
� } d S)z6
test corner cases in the init method
Zconsolez1.0z1.endz1.5NZprecedesFr � z54.5)�assertRaises�
ValueErrorr Ztag_addr! �assertIn�str� exceptionr r
�assertEqualZrawtext�getr )r �ve�pr r r � test_init? s "&zHyperParserTest.test_initc C s� | j } | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � d S)Nz1.0z1.4z2.3z3.3z3.7z4.6z12.54)r! �assertFalseZis_in_string�
assertTrue)r r) r+ r r r �test_is_in_stringS s z!HyperParserTest.test_is_in_stringc C s� | j } | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � | d � } | j | j � � d S)Nz1.0z1.1z2.5z3.4z3.6z4.14)r! r. Z
is_in_coder- )r r) r+ r r r �test_is_in_codee s zHyperParserTest.test_is_in_codec C s: | j } d d � } d d � } | d � } | j | | � � | j | | � � | d � } | j | | � d � | j | | � | | � � | d � } | j | | � d � | j | | � | | � � | d � } | j | | � d � | j | | � � | d � } | j | | � � | j | | � � d S)Nc S s | j d d � S)N� mustcloseF)�get_surrounding_brackets)�parserr r r �without_mustclosex s zGHyperParserTest.test_get_surrounding_bracket.<locals>.without_mustclosec S s | j d d � S)Nr1 T)r2 )r3 r r r �with_mustclose} s zDHyperParserTest.test_get_surrounding_bracket.<locals>.with_mustclosez3.2z5.6�5.4�5.25z5.23�5.21�5.24z6.15�6.4�6.endz9.end)r6 r7 )r8 r9 )r: r; )r! ZassertIsNoneZassertTupleEqual)r r) r4 r5 r+ r r r �test_get_surrounding_bracketu s$ z,HyperParserTest.test_get_surrounding_bracketc C sW | j } | d � } | j | j � d � | d � } | j t � � } | j � Wd QRX| j d t | 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 � } | j t � � } | j � Wd QRX| j d t | 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 S)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.6u cliché)r! r( Zget_expressionr# r$ r% r&