
'![c           @   s8  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l m Z d  d l m Z d  d l Td  d l m Z d  d l Z d  d l m Z e e e   Z e  j d    Z e  j d	    Z d
 e f d     YZ d e f d     YZ d S(   iN(   t   joint   dirnamet   abspath(   t   Run(   t   BaseReporter(   t   *(   t   JSONReporter(   t   utilsc         c   s9   |  t  _ t  _ z	 d  VWd  t  j t  _ t  j t  _ Xd  S(   N(   t   syst   stderrt   stdoutt
   __stderr__t
   __stdout__(   t   out(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   _patch_streams)   s
    	c         c   s\   d } t  j j |  } |  t  j | <z	 d  VWd  t  j j |  | rW | t  j | <n  Xd  S(   Nt   LC_CTYPE(   t   ost   environt   gett   pop(   t   lc_ctypet   lc_ctype_envt   original_lctype(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   _configure_lc_ctype3   s    	t   MultiReporterc           B   s\   e  Z d    Z d   Z d   Z d   Z e d    Z e d    Z e j	 d    Z RS(   c         C   s#   | |  _  t j   t j |  _ d  S(   N(   t
   _reportersR   t   getcwdt   sept   path_strip_prefix(   t   selft	   reporters(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   __init__A   s    	c         O   s(   x! |  j  D] } | j | |   q
 Wd  S(   N(   R   t   on_set_current_module(   R   t   argst   kwargst   rep(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR    E   s    c         C   s%   x |  j  D] } | j |  q
 Wd  S(   N(   R   t   handle_message(   R   t   msgR#   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR$   I   s    c         C   s   d  S(   N(    (   R   t   layout(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   display_reportsM   s    c         C   s   |  j  d j S(   Ni    (   R   R   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR   P   s    c         C   s   |  j  S(   N(   t   _linter(   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   linterT   s    c         C   s*   | |  _  x |  j D] } | | _ q Wd  S(   N(   R(   R   R)   (   R   t   valueR#   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR)   X   s    	(
   t   __name__t
   __module__R   R    R$   R'   t   propertyR   R)   t   setter(    (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR   @   s   				t	   TestRunTCc           B   s  e  Z d+ d+ d  d  Z d+ 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 d   Z d   Z d   Z e j j e j d d k d d d    Z e j j e j d d k d d 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, d*   Z- RS(,   i   c         C   s   | d  k r t j   } n  |  j | d | d | } | rN | j j   } n$ t | d  rl | j   } n d  } d | | f } | d  k	 r d | | f } n  | | k s t |   d  S(   Nt   reporterR   t   getvalues!   expected output status %s, got %ss   %s. Below pylint output: 
%s(   t   Nonet   sixt   StringIOt   _run_pylintR   R1   t   hasattrt   AssertionError(   R   R!   R0   R   t   codet   pylint_codet   outputR%   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   _runtesta   s    c         C   sv   | d g } t  |  W t j t  7 } t j   " t j d  t | d | Wd  QXWd  QX| j j	 SWd  QXd  S(   Ns   --persistent=not   ignoreR0   (
   R   t   pytestt   raisest
   SystemExitt   warningst   catch_warningst   simplefilterR   R*   R8   (   R   R!   R   R0   t   cm(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR5   p   s    c         C   sM   t  j   } |  j | d | | j   } | j   | j   k sI t  d  S(   NR   (   R3   R4   R5   R1   t   stripR7   (   R   R!   t   expected_outputR   t   actual_output(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   _test_outputy   s    c         C   s,   |  j  d g d t t j    d d d S(   s   Make pylint check itself.s   pylint.__pkginfo__R0   R8   i    N(   R;   t   TextReporterR3   R4   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_pkginfo   s    !c         C   sY   t  t j    t t j    t t j    g } |  j d g d t |  d d d S(   s   Make pylint check itself.s#   pylint/test/functional/arguments.pyR0   R8   i   N(   RH   R3   R4   t   ColorizedTextReporterR   R;   R   (   R   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_all   s
    c         C   s&   |  j  t t d d  g d d d  S(   Nt   inputt   noextR8   i    (   R;   R    t   HERE(   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_no_ext_file   s    c         C   s&   |  j  t t d d  g d d d  S(   NRL   s    ignore_except_pass_by_default.pyR8   i    (   R;   R    RN   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_w0704_ignored   s    c         C   s   |  j  d g d d d  S(   Ns   --generate-rcfileR8   i    (   R;   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_generate_config_option   s    c         C   s~   t  j   } t  j   } |  j d g d d d | |  j d g d d d | | j   } | j   } | | k sz t  d  S(   Ns   --generate-rcfileR8   i    R   (   R3   R4   R;   R1   R7   (   R   t   out1t   out2t   output1t   output2(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt!   test_generate_config_option_order   s    c         C   s   t  j   } |  j d d g d | | j   } t j d |  } t  j | | j    } t  j j j	   } | j
 |  t j | j d d   } d | k s t  d  S(   Ns   --generate-rcfiles	   --rcfile=R   s   \[MASTERs   MESSAGES CONTROLt   disables   suppressed-message(   R3   R4   R5   R1   t   ret   searcht   startt   movest   configparsert   RawConfigParsert   readfpR   t   _splitstripR   R7   (   R   R   R:   t   mastert   parsert   messages(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt+   test_generate_config_disable_symbolic_names   s    c         C   sD   t  j   } |  j d g d | | j   } d | k s@ t  d  S(   Ns   --generate-rcfileR   t   profile(   R3   R4   R5   R1   R7   (   R   R   R:   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt(   test_generate_rcfile_no_obsolete_methods   s    c         C   sY   t  j   } t j t   } |  j d g d | Wd  QXd t | j  k sU t  d  S(   Ns   --rcfile=/tmp/norcfile.txtR   s0   The config file /tmp/norcfile.txt doesn't exist!(	   R3   R4   R=   R>   t   IOErrorR5   t   strR*   R7   (   R   R   t   excinfo(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_inexisting_rcfile   s    c         C   s   |  j  d d g d d d  S(   Ns
   --help-msgt   W0101R8   i    (   R;   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_help_message_option   s    c         C   s   |  j  d d g d d d  S(   Ns
   --help-msgt   WX101R8   i    (   R;   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_error_help_message_option   s    c         C   s   |  j  g  d d d  S(   NR8   i    (   R;   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_error_missing_arguments   s    c         C   sk   t  j d	 k  r t j   } n t j   } | j d k s? t  |  j	 t
 t d  d g d | d d d S(
   s<   test redirection of stdout with non ascii caracters
        i   i    s#   regrtest_data/no_stdout_encoding.pys   --enable=allR   R8   i   N(   i   i    (   R   t   version_infot   tempfilet   TemporaryFileR3   R4   t   encodingR2   R7   R;   R    RN   (   R   t   strio(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_no_out_encoding   s    	c         C   s    |  j  d d d g d d d  S(   Ns   -j 2s#   pylint/test/functional/arguments.pys*   pylint/test/functional/bad_continuation.pyR8   i   (   R;   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_parallel_execution   s    c         C   s    |  j  d d d g d d d  S(   Ns   -j 2t   not_heret   not_here_tooR8   i   (   R;   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt)   test_parallel_execution_missing_arguments   s    c         C   s>   t  j r d n d } |  j t t d d  d g d | d  S(   Ni   i    t
   functionals   unpacked_exceptions.pys   --py3kR8   (   R3   t   PY2R;   R    RN   (   R   t   rc_code(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_py3k_option   s    	c         C   sA   t  j r d n d } |  j t t d d  d d g d | d  S(   Ni   i    Ry   s   unpacked_exceptions.pys   --py3ks   -j 2R8   (   R3   Rz   R;   R    RN   (   R   R{   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_py3k_jobs_option   s    i    i   t   reasons   Requires the --py3k flag.c         C   s   t  t d d  } t j d  } |  j | d d g d | t j d  } |  j | d d d g d | |  j | d d d g d | d  S(	   Nt   regrtest_datas   py3k_error_flag.pysZ   
        ************* Module py3k_error_flag
        Explicit return in __init__
        s   -Es   --msg-template='{msg}'RE   s|   
        ************* Module py3k_error_flag
        Use raise ErrorClass(args) instead of raise ErrorClass, args.
        s   --py3k(   R    RN   t   textwrapt   dedentRG   (   R   t   modulet   expected(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt&   test_py3k_commutative_with_errors_only   s    		c         C   s   t  t d d  } t  t d d  } | d d g } t j d  } |  j | d g d | t j d	  } |  j | d d
 | g d | t j d  } |  j | d d d
 | g d | |  j | d d d
 | g d | d  S(   NR   s   py3k_errors_and_warnings.pys   py3k-disabled.rcs   --msg-template='{msg}'s   --reports=ns  
        ************* Module py3k_errors_and_warnings
        import missing `from __future__ import absolute_import`
        Use raise ErrorClass(args) instead of raise ErrorClass, args.
        Calling a dict.iter*() method
        print statement used
        s   --py3kRE   s   
        ************* Module py3k_errors_and_warnings
        Use raise ErrorClass(args) instead of raise ErrorClass, args.
        Calling a dict.iter*() method
        print statement used
        s   --rcfiles   
        ************* Module py3k_errors_and_warnings
        Use raise ErrorClass(args) instead of raise ErrorClass, args.
        print statement used
        s   -E(   R    RN   R   R   RG   (   R   R   t   rcfilet   cmdR   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt)   test_py3k_commutative_with_config_disable  s     			c         C   s#   d } |  j  d d g d | d  S(   Ns   no such option: --load-plugint   .s   --load-pluginRE   (   RG   (   R   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt$   test_abbreviations_are_not_supported$  s    c         C   sD   t  t d d  } t j d  } |  j | d d d g d | d  S(   Nt   datas   clientmodule_test.pys   
        ************* Module data.clientmodule_test
        W: 10, 8: Unused variable 'local_variable' (unused-variable)
        C: 18, 4: Missing method docstring (missing-docstring)
        C: 22, 0: Missing class docstring (missing-docstring)
        s   --disable=alls   --enable=alls   -rnRE   (   R    RN   R   R   RG   (   R   R   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_enable_all_works(  s
    	c         C   s   t  j d  } t t d d  } t t d d  } | | d d d d g } t j   } |  j | d	 | | j   j   } d
 } | | k r | t	 |  } n  | j
 d  r | | j d  } n  | j   | j   k s t  d  S(   Ns   
        ************* Module wrong_import_position
        C: 11, 0: Import "import os" should be placed at the top of the module (wrong-import-position)
        R   s   import_something.pys   wrong_import_position.pys   --disable=alls   --enable=wrong-import-positions   -rns   -snR   s1   No config file found, using default configurations   Using config file s   
(   R   R   R    RN   R3   R4   R5   R1   RD   t   lent
   startswitht   findR7   (   R   RE   t   module1t   module2R!   R   RF   t	   to_remove(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt/   test_wrong_import_position_when_others_disabled3  s     	c         C   s8   d } t  t d d  } |  j | d d g d | d  S(   Ns$   Your code has been rated at 10.00/10R   t   dummys   --disable=locally-disableds   -rnRE   (   R    RN   RG   (   R   R   t   package(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt5   test_import_itself_not_accounted_for_relative_importsJ  s    c         C   s5   d } t  t d d  } |  j | d g d | d  S(   Ns   indent string can't be emptyR   s   clientmodule_test.pys   --indent-string=RE   (   R    RN   RG   (   R   R   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt    test_reject_empty_indent_stringsP  s    c         C   s:  t  j   } t t d d  } |  j | g d d d t |  t j | j    } t	 | t
  sj t  t |  d k s t  t	 | d t  s t  i d d	 6d d
 6d d 6d d 6d d 6d d 6} | d } xB | j   D]4 \ } } | | k s t  | | | k s t  q Wd | d j   k s6t  d  S(   NR   s   syntax_error.pyR8   i   R0   i   i    t    t   objt   columnt   linet   errort   types   syntax-errort   symbolt   syntax_errorR   s   invalid syntaxt   message(   R3   R4   R    RN   R;   R   t   jsont   loadsR1   t
   isinstancet   listR7   R   t   dictt   itemst   lower(   R   R   R   R:   R   R   t   keyR*   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt+   test_json_report_when_file_has_syntax_errorV  s&    "

c         C   s7  t  j   } t t d d  } |  j | g d d d t |  t j | j    } t	 | t
  sj t  t |  d k s t  t	 | d t  s t  i d d 6d d	 6d d
 6d d 6d d 6| d 6} | d } xB | j   D]4 \ } } | | k s t  | | | k s t  q W| d j d  s3t  d  S(   NR   s   totally_missing.pyR8   i   R0   i    R   R   R   R   t   fatalR   R   R   R   s   No module named(   R3   R4   R    RN   R;   R   R   R   R1   R   R   R7   R   R   R   R   (   R   R   R   R:   R   R   R   R*   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt%   test_json_report_when_file_is_missingl  s&    "

c         C   s2   d } t  t d d  } |  j | g d | d  S(   Ns$   Your code has been rated at 10.00/10R   s   meta.pyRE   (   R    RN   RG   (   R   R   t   path(    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt-   test_information_category_disabled_by_default  s    c         C   s>   t  j d  } t t d d  } |  j | d g d | d  S(   Ns   
        ************* Module application_crash
        E:  1, 6: Undefined variable 'something_undefined' (undefined-variable)
        R   s   application_crash.pys   -ERE   (   R   R   R    RN   RG   (   R   RE   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_error_mode_shows_no_score  s    	c         C   s2   d } t  t d d  } |  j | g d | d  S(   Ns   Your code has been rated at R   s   application_crash.pyRE   (   R    RN   RG   (   R   RE   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt&   test_evaluation_score_shown_by_default  s    c         C   s5   d } t  t d d  } |  j | d g d | d  S(   Ns   Your code has been rated atR   s   meta.pys   --confidence=HIGH,INFERENCERE   (   R    RN   RG   (   R   R   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_confidence_levels  s    c         C   sN   t  t d d  } t  t d d  } d } |  j | d | d g d | d  S(   NR   s   meta.pys	   .pylintrcs$   Your code has been rated at 10.00/10s   --rcfile=%ss   -rnRE   (   R    RN   RG   (   R   R   t   config_pathR   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   test_bom_marker  s
    c         C   s   t  t d d  } t j j |  t  t d d  } d } |  j d | d g d | d } |  j d | d	 g d | t j j |  d  S(
   NR   t   dummy_plugins   dummy_plugin.rcs   :dummy-message-01 (I9061): *Dummy short desc 01*
  Dummy long desc This message belongs to the dummy_plugin checker.

:dummy-message-02 (I9060): *Dummy short desc 02*
  Dummy long desc This message belongs to the dummy_plugin checker.s   --rcfile=%ss,   --help-msg=dummy-message-01,dummy-message-02RE   sl   [DUMMY_PLUGIN]

# Dummy option 1
dummy_option_1=dummy value 1

# Dummy option 2
dummy_option_2=dummy value 2s   --generate-rcfile(   R    RN   R   R   t   appendRG   t   remove(   R   t   dummy_plugin_pathR   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt&   test_pylintrc_plugin_duplicate_options  s    	c         C   sW   t  t d d  } t  t d d  } t j d  } |  j | d | d g d | d  S(   NR   s   test_pylintrc_comments.pyt   comments_pylintrcs  
        ************* Module test_pylintrc_comments
        W:  2, 0: Bad indentation. Found 1 spaces, expected 4 (bad-indentation)
        C:  1, 0: Missing module docstring (missing-docstring)
        C:  1, 0: Missing function docstring (missing-docstring)
        s   --rcfile=%ss   -rnRE   (   R    RN   R   R   RG   (   R   R   R   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt    test_pylintrc_comments_in_values  s    	c         C   s,   |  j  d g d t t j    d d d  S(   Ns   --ignore-patterns=aR0   R8   i    (   R;   RH   R3   R4   (   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt,   test_no_crash_with_formatting_regex_defaults  s    !c         C   sQ   t  j d  } t t d d  } t d   |  j | d g d | Wd  QXd  S(   Ns   
        ************* Module application_crash
        E:  1, 6: Undefined variable 'something_undefined' (undefined-variable)
        R   s   application_crash.pys   UTF-8s   -ERE   (   R   R   R    RN   R   RG   (   R   RE   R   (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt2   test_getdefaultencoding_crashes_with_lc_ctype_utf8  s
    	N(.   R+   R,   R2   R;   R5   RG   RI   RK   RO   RP   RQ   RV   Rc   Re   Ri   Rk   Rm   Rn   Rt   Ru   Rx   R|   R}   R=   t   markt   skipifR   Ro   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyR/   _   sL   				
																..#															(   t
   contextlibR   RX   R   R   t   os.pathR    R   R   Rp   R   R3   t   pylint.lintR   t   pylint.reportersR   t   pylint.reporters.textt   pylint.reporters.jsonR   R=   t   pylintR   t   __file__RN   t   contextmanagerR   R   R   t   objectR/   (    (    (    s4   lib/python2.7/site-packages/pylint/test/test_self.pyt   <module>   s&   

