ó
‹²,]c           @   s  d  Z  d d l m Z d d l Z d d l m Z d d l m Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e j j d „  ƒ Z e j j d „  ƒ Z e j j d „  ƒ Z e d k rı e j ƒ  n  d S(   s;   
Tests for the automatic insertion of colons in the editor
iÿÿÿÿ(   t   QTextCursorN(   t   qapplication(   t
   CodeEditorc         C   sb   t  ƒ  } t d d  ƒ } | j d d ƒ | j |  ƒ | j ƒ  } | j t j ƒ | j	 | ƒ | S(   Nt   parentt   languaget   Python(
   R   R   t   Nonet   setup_editort   set_textt
   textCursort   movePositionR    t   Endt   setTextCursor(   t   textt   appt   editort   cursor(    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt   construct_editor   s    	c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   x = 1(   R   t   autoinsert_colonst   Falset   AssertionError(   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt)   test_no_auto_colon_after_simple_statement#   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns	   if x == 1(   R   R   t   TrueR   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt"   test_auto_colon_after_if_statement'   s    c          C   sQ   t  d ƒ }  |  j ƒ  } | j t j ƒ |  j | ƒ |  j ƒ  t k sM t ‚ d  S(   Ns	   if x == 1(	   R   R	   R
   R    t   LeftR   R   R   R   (   R   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt(   test_no_auto_colon_if_not_at_end_of_line+   s
    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns
   if x == '1(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt)   test_no_auto_colon_if_unterminated_string2   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   if x == 1 # comment(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt   test_no_auto_colon_in_comment6   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns
   if x == 1:(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt+   test_no_auto_colon_if_already_ends_in_colon:   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   if x == 1 \(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt'   test_no_auto_colon_if_ends_in_backslash>   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   if x < 0: x = 0(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt+   test_no_auto_colon_in_one_line_if_statementB   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   if text[:-1].endswith('bla')(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt-   test_auto_colon_even_if_colon_inside_bracketsF   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns)   ns = [ n for ns in range(10) 
 if n < 5 ](   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt-   test_no_auto_colon_in_listcomp_over_two_linesJ   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   if text == ':'(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt+   test_auto_colon_even_if_colon_inside_quotesQ   s    c          C   sa   t  d ƒ }  |  j ƒ  } | j t j ƒ | j t j ƒ |  j | ƒ |  j ƒ  t k s] t	 ‚ d  S(   Ns+   ns = [ n 
 for ns in range(10) 
 if n < 5 ](
   R   R	   R
   R    t   Upt	   EndOfLineR   R   R   R   (   R   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt/   test_no_auto_colon_in_listcomp_over_three_linesV   s    c          C   s(   t  d ƒ }  |  j ƒ  t k s$ t ‚ d  S(   Ns   if x < 0: x = 0; if x == 0(   R   R   R   R   (   R   (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt0   test_auto_colon_in_two_if_statements_on_one_line_   s    t   __main__(   t   __doc__t
   qtpy.QtGuiR    t   pytestt   spyder.utils.qthelpersR   t$   spyder.widgets.sourcecode.codeeditorR   R   R   R   R   R   R   R   R   R   R   R    t   markt   xfailR!   R$   R%   t   __name__t   main(    (    (    sM   lib/python2.7/site-packages/spyder/widgets/sourcecode/tests/test_autocolon.pyt   <module>	   s(   												