ó
'![c           @   s‘  d  d l  Z  d  d l Z d  d l 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 Z d e f d „  ƒ  YZ d „  Z d „  Z e j d	 „  ƒ Z e j j d
 i d/ d 6d0 d 6d f i d d d i d1 g d 6f d 6d2 d 6d f i d3 d 6d d d i d4 g d 6f d 6d f i d d d i d5 g d 6f d 6d d d i d6 g d 6f d 6d f i d7 d 6d8 d 6d f i d d d i d9 g d 6f d 6d: d 6d f i d; d 6d d d i d< g d 6f d 6d f i d d d i d= g d 6f d 6d d d i d> g d 6f d 6d! f g ƒ d" „  ƒ Z d# „  Z e j j d$ d? d@ g ƒ d) „  ƒ Z d* „  Z d+ „  Z d, „  Z d- dA d. „  ƒ  YZ d S(B   iÿÿÿÿN(   t   utils(   t   check_messagest   get_node_last_lineno(   t   InvalidMessageErrort   TestPyLintASTWalkerc           B   sF   e  Z d  e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z RS(   t
   MockLinterc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  d  S(   N(   t   _msgs(   t   selft   msgs(    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   __init__   s    c         C   s   |  j  j | t ƒ S(   N(   R   t   gett   True(   R   t   msgid(    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   is_message_enabled"   s    (   t   __name__t
   __module__R	   R   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR      s   	t   Checkerc           B   sh   e  Z d  „  Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d d ƒ d „  ƒ Z e d ƒ d „  ƒ Z RS(   c         C   s   t  ƒ  |  _ d  S(   N(   t   sett   called(   R   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR	   &   s    s   first-messagec         C   s   |  j  j d ƒ d  S(   Nt   module(   R   t   add(   R   R   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   visit_module)   s    s   second-messagec         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R   R   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt
   visit_call-   s    s   third-messagec         C   s   |  j  j d ƒ d  S(   Nt
   assignname(   R   R   (   R   R   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   visit_assignname1   s    c         C   s
   t  ‚ d  S(   N(   R   (   R   R   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   leave_assignname5   s    (   R   R   R	   R   R   R   R   R   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR   %   s
   	c         C   s   |  j  i t d 6t d 6t d 6ƒ } t j | ƒ } |  j ƒ  } | j | ƒ | j t j	 d ƒ ƒ d d h | j
 k s} t ‚ d  S(   Ns   first-messages   second-messages   third-messages
   x = func()R   R   (   R   R   t   FalseR    t   PyLintASTWalkerR   t   add_checkert   walkt   astroidt   parseR   t   AssertionError(   R   t   lintert   walkert   checker(    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_check_messages9   s    c         C   s¡   d t  f d „  ƒ  Y} |  j i t d 6ƒ } t j | ƒ } | ƒ  } | j | ƒ t j d t ƒ 8 t j d ƒ | j	 t
 j d ƒ ƒ | j s— t ‚ Wd  QXd  S(   NR   c           B   s&   e  Z d  „  Z e d ƒ d „  ƒ Z RS(   c         S   s   t  |  _ d  S(   N(   R   R   (   R   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR	   E   s    s   first-messagec         S   s   t  |  _ d  S(   N(   R   R   (   R   t   node(    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   visit_assnameH   s    (   R   R   R	   R   R'   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR   D   s   	s   first-messaget   recordt   alwayss   x = 1(   t   objectR   R   R    R   R   t   warningst   catch_warningst   simplefilterR   R   R    R   R!   (   R   R   R"   R#   R$   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_deprecated_methodsC   s    	(   R   R   R*   R   R   R%   R.   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR      s   	
c          C   sR   t  j d ƒ t  j d ƒ g }  t j d |  ƒ s6 t ‚ t j d |  ƒ sN t ‚ d  S(   Ns   .*enchilada.*s   unittest_.*s   unittest_utils.pys   cheese_enchiladas.xml(   t   ret   compileR    t   _basename_in_blacklist_reR!   (   t   patterns(    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt$   test__basename_in_blacklist_re_matchW   s    c          C   sT   t  j d ƒ t  j d ƒ g }  t j d |  ƒ s7 t ‚ t j d |  ƒ sP t ‚ d  S(   Ns   .*enchilada.*s   unittest_.*s   test_utils.pys   enchilad.py(   R/   R0   R    R1   R!   (   R2   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt&   test__basename_in_blacklist_re_nomatch]   s    c           C   s
   t  j ƒ  S(   N(   R    t   MessagesStore(    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   storec   s    s   messages,expecteds   message ones   msg-symbol-ones   msg descriptiont   W1234s   message twos   msg-symbol-twot   W4321sB   Inconsistent checker part in message id 'W4321' (expected 'x12xx')s
   old-symbolt	   old_namest   W1233s%   Message id 'W1234' is already definedt   W1235t   W1201s   old-symbol-ones   old-symbol-twos%   Message id 'W1201' is already defineds
   msg-symbols.   Message symbol 'msg-symbol' is already definedt   W1230s2   Message symbol 'msg-symbol-one' is already definedt   W1231s:   Message alternate name 'old-symbol-one' is already definedc            sc   d t  f ‡  f d †  ƒ  Y} t j t ƒ  } |  j | ƒ  ƒ Wd  QXt | j ƒ | k s_ t ‚ d  S(   NR   c              s   e  Z d  Z ˆ  Z RS(   R$   (   R   R   t   nameR   (    (   t   messages(    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyR   ’   s   (   R*   t   pytestt   raisesR   t   register_messagest   strt   valueR!   (   R6   R@   t   expectedR   t   cm(    (   R@   s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_register_errorh   s    *c         C   sW   d t  f d „  ƒ  Y} d t  f d „  ƒ  Y} |  j | ƒ  ƒ t |  i d
 d 6d	 ƒ d  S(   Nt
   CheckerOnec           B   s   e  Z d  Z i d d 6Z RS(   t   checker_ones   message ones   msg-symbol-ones   msg description.R7   (   s   message ones   msg-symbol-ones   msg description.(   R   R   R?   R   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyRI   ›   s   t
   CheckerTwoc           B   s   e  Z d  Z i d d 6Z RS(   t   checker_twos   message twos   msg-symbol-twos   another msg description.R7   (   s   message twos   msg-symbol-twos   another msg description.(   R   R   R?   R   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyRK   ¡   s   s   message twos   msg-symbol-twos   another msg description.R7   s%   Message id 'W1234' is already defined(   s   message twos   msg-symbol-twos   another msg description.(   R*   RC   RH   (   R6   RI   RK   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt+   test_register_error_new_id_duplicate_of_newš   s    
s   msgid,expectedt   Q1234s   Bad message type Q in 'Q1234't   W12345s   Invalid message id 'W12345'c         C   sS   t  j t ƒ # } t j d |  d d d d ƒ Wd  QXt | j ƒ | k sO t ‚ d  S(   NR$   t   msgt   descrt   symbolt   scope(   RA   RB   R   R    t   MessageDefinitionRD   RE   R!   (   R   RF   RG   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt    test_create_invalid_message_type¬   s    c          C   su   t  j d ƒ }  t j |  d ƒ } g  } | ƒ  } x& | d k rX | j | ƒ | ƒ  } q3 W| d d g k sq t ‚ d S(   s  _decoding_readline should yield line at a time even if the binary
    representation of the text is not splittable line-by-line.

    For convenience this test uses a codec that is easy to understand, though
    this *specific* codec is unlikely to be seen in the wild for files.
    s
   foo\nbaz\nt   unicode_escapet    s   foo
s   baz
N(   t   iot   BytesIOR    t   _decoding_readlinet   appendR!   (   t	   binary_iot   readlinet   rett   s(    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test__decoding_readline·   s    	c          C   sI   t  j d ƒ }  t j |  d ƒ } | j ƒ  } | d d g k sE t ‚ d S(   s\   decoding_stream should fall back to *some* decoding when given an
    unknown encoding.
    s   foo
bars   garbage-encodings   foo
t   barN(   RX   RY   R    t   decoding_streamt	   readlinesR!   (   R\   t   streamR^   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt%   test_decoding_stream_unknown_encodingÊ   s    c          C   sF   t  j d j d ƒ ƒ }  t j |  d ƒ } | j ƒ  d k sB t ‚ d  S(   Nu   â‚¬t   cp1252(   RX   RY   t   encodeR    Rb   t   readR!   (   R\   Rd   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt#   test_decoding_stream_known_encodingÕ   s    t   TestGetNodeLastLinenoc           B   s˜   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Ns   
            pass
        i   (   R   t   extract_nodeR   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt    test_get_node_last_lineno_simpleÜ   s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   NsP   
            if True:
                print(1)
                pass
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt#   test_get_node_last_lineno_if_simpleã   s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Ns—   
            if True:
                print(1)
            elif False:
                print(2)
            else:
                print(3)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt(   test_get_node_last_lineno_if_elseif_elseì   s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Ns>   
            while True:
                print(1)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_get_node_last_lineno_whileø   s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Nsi   
            while True:
                print(1)
            else:
                print(2)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt$   test_get_node_last_lineno_while_else   s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   NsH   
            for x in range(0, 5):
                print(1)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_get_node_last_lineno_for
  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Nss   
            for x in range(0, 5):
                print(1)
            else:
                print(2)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt"   test_get_node_last_lineno_for_else  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Ns¦   
            try:
                print(1)
            except ValueError:
                print(2)
            except Exception:
                print(3)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_get_node_last_lineno_try  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Ns²   
            try:
                print(1)
            except Exception:
                print(2)
                print(3)
            else:
                print(4)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt)   test_get_node_last_lineno_try_except_else(  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Nsœ   
            try:
                print(1)
            except Exception:
                print(2)
            finally:
                print(4)
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt,   test_get_node_last_lineno_try_except_finally5  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   NsÇ   
            try:
                print(1)
            except Exception:
                print(2)
            else:
                print(3)
            finally:
                print(4)
            i	   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt1   test_get_node_last_lineno_try_except_else_finallyA  s    		c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   NsT   
            with x as y:
                print(1)
                pass
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_get_node_last_lineno_withO  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   NsW   
            def x(a, b):
                print(a, b)
                pass
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt    test_get_node_last_lineno_methodX  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Nsl   
            @decor()
            def x(a, b):
                print(a, b)
                pass
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt#   test_get_node_last_lineno_decoratora  s    	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   NsÕ   
            class C(object):
                CONST = True

                def x(self, b):
                    print(b)

                def y(self):
                    pass
                    pass
            i
   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   test_get_node_last_lineno_classj  s    
	c         C   s+   t  j d ƒ } t | ƒ d k s' t ‚ d  S(   Ns  
            class C(object):
                CONST = True

                def y(self):
                    try:
                        pass
                    except:
                        pass
                    finally:
                        pass
            i   (   R   Rk   R   R!   (   R   R&   (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt"   test_get_node_last_lineno_combinedy  s    	(   R   R   Rl   Rm   Rn   Ro   Rp   Rq   Rr   Rs   Rt   Ru   Rv   Rw   Rx   Ry   Rz   R{   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyRj   Ú   s    						
		
											(   s   message ones   msg-symbol-ones   msg description(   s   message twos   msg-symbol-twos   msg description(   R7   s
   old-symbol(   s   message ones   msg-symbol-ones   msg description(   s   message ones   msg-symbol-ones   msg description(   R7   s
   old-symbol(   R<   s   old-symbol-one(   R<   s   old-symbol-two(   s   message ones
   msg-symbols   msg description(   s   message twos
   msg-symbols   msg description(   R=   s   msg-symbol-one(   s   message ones   msg-symbol-ones   msg description(   s   message ones   msg-symbol-ones   msg description(   R=   s   msg-symbol-one(   R=   s   old-symbol-one(   R>   s   old-symbol-one(   RN   s   Bad message type Q in 'Q1234'(   RO   s   Invalid message id 'W12345'(    (   RX   R/   R+   R   t   pylintR    t   pylint.checkers.utilsR   R   t   pylint.exceptionsR   RA   R*   R   R3   R4   t   fixtureR6   t   markt   parametrizeRH   RM   RU   R`   Re   Ri   Rj   (    (    (    s9   lib/python2.7/site-packages/pylint/test/unittest_utils.pyt   <module>   sh   :		

		

							