ó
'![c           @   s×   d  Z  d d l Z d d l Z d d l m Z d d l m Z m Z m Z m	 Z	 y d d l
 Z
 Wn e k
 ry d Z
 n Xd Z e
 d k	 r½ y e
 j d ƒ d Z Wq½ e
 j k
 r¹ q½ Xn  d e f d „  ƒ  YZ d S(   s"   Unittest for the spelling checker.iÿÿÿÿN(   t   spelling(   t   CheckerTestCaset   Messaget
   set_configt   _tokenize_strt   en_USt   TestSpellingCheckerc           B   s$  e  Z e j Z e j j e d k d  d ƒZ
 d d „ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ e d d ƒ d „  ƒ ƒ ƒ Z e
 e d e ƒ d	 „  ƒ ƒ Z e j j e d  d
 ƒe
 e d e ƒ d „  ƒ ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z e
 e d e ƒ d „  ƒ ƒ Z RS(   t   reasons?   missing python-enchant package or missing spelling dictionariesi   c         C   s)   d j  d j |  j j j | ƒ |  ƒ ƒ S(   Ns   '{0}'s   ' or '(   t   formatt   joint   checkert   spelling_dictt   suggest(   t   selft   wordt   count(    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   _get_msg_suggestions+   s    R   c         C   sW   |  j  t d d d d d d d |  j d ƒ f ƒƒ  |  j j t d ƒ ƒ Wd  QXd  S(   Ns   wrong-spelling-in-commentt   linei   t   argst   coments   # bad coments         ^^^^^^(   t   assertAddsMessagesR   R   R
   t   process_tokensR   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_check_bad_coment.   s    t   max_spelling_suggestionsi   c         C   s]   |  j  t d d d d d d d |  j d d d	 ƒf ƒƒ  |  j j t d ƒ ƒ Wd  QXd  S(
   Ns   wrong-spelling-in-commentR   i   R   R   s   # bad coments         ^^^^^^R   i   (   R   R   R   R
   R   R   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt-   test_check_bad_coment_custom_suggestion_count8   s    c         C   s¼   t  j d ƒ } |  j t d d d d d d d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXt  j d	 ƒ } |  j t d d d d d d d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXd  S(
   Ns&   def fff():
   """bad coment"""
   passs   wrong-spelling-in-docstringR   i   R   R   s
   bad coments
       ^^^^^^s.   class Abc(object):
   """bad coment"""
   pass(   t   astroidt   extract_nodeR   R   R   R
   t   visit_functiondeft   visit_classdef(   R   t   stmt(    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_check_bad_docstringC   s     		s"   pyenchant's tokenizer strips thesec         C   sK   t  j d ƒ } |  j t d d d d d ƒƒ  |  j j | ƒ Wd  QXd  S(   Ns$   def fff():
   """test\x00"""
   passs   invalid-characters-in-docstringR   i   R   s   test (   s   test (   R   R   R   R   R
   R   (   R   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt!   test_invalid_docstring_charactersX   s    	c         C   s5   |  j  j t d ƒ ƒ |  j j ƒ  g  k s1 t ‚ d  S(   Ns   #!/usr/bin/env python(   R
   R   R   t   lintert   release_messagest   AssertionError(   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_shebangsc   s    c         C   s*  |  j  j t d ƒ ƒ |  j j ƒ  g  k s1 t ‚ |  j  j t d ƒ ƒ |  j j ƒ  g  k sb t ‚ |  j  j t d ƒ ƒ |  j j ƒ  g  k s“ t ‚ |  j  j t d ƒ ƒ |  j j ƒ  g  k sÄ t ‚ |  j  j t d ƒ ƒ |  j j ƒ  g  k sõ t ‚ |  j  j t d ƒ ƒ |  j j ƒ  g  k s&t ‚ d  S(   Ns   # -*- coding: utf-8 -*-s   # coding=utf-8s   # vim: set fileencoding=utf-8 :s-   #!/usr/bin/env python
# -*- coding: utf-8 -*-s$   #!/usr/bin/env python
# coding=utf-8s5   #!/usr/bin/env python
# vim: set fileencoding=utf-8 :(   R
   R   R   R    R!   R"   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt    test_skip_python_coding_commentsi   s$    





c         C   s5   |  j  j t d ƒ ƒ |  j j ƒ  g  k s1 t ‚ d  S(   Ns4   # Line 1
 Line 2
# pylint: disable=ungrouped-imports(   R
   R   R   R    R!   R"   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt2   test_skip_top_level_pylint_enable_disable_comments€   s    c         C   s5   |  j  j t d ƒ ƒ |  j j ƒ  g  k s1 t ‚ d  S(   Ns   
# 0ne
# Thr33
# Sh3ll(   R
   R   R   R    R!   R"   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_words_with_numbers†   s    c         C   s`   t  j d ƒ } |  j t d d d d d d d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXd  S(	   NsE   class ComentAbc(object):
   """ComentAbc with a bad coment"""
   passs   wrong-spelling-in-docstringR   i   R   R   s   ComentAbc with a bad coments                        ^^^^^^(   R   R   R   R   R   R
   R   (   R   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_wiki_wordsŒ   s    	c         C   s  t  j d ƒ } |  j t d d d d d d d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXt  j d	 ƒ } |  j t d d d d d d
 d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXxQ d D]I } t  j d j | ƒ ƒ } |  j j | ƒ |  j j	 ƒ  g  k s¿ t
 ‚ q¿ Wd  S(   NsE   class ComentAbc(object):
   """comentAbc with a bad coment"""
   passs   wrong-spelling-in-docstringR   i   R   R   s   comentAbc with a bad coments                        ^^^^^^sE   class ComentAbc(object):
   """argumentN with a bad coment"""
   passs   argumentN with a bad comentt   xmlHttpRequestt   newCustomert   newCustomerIdt   innerStopwatcht   supportsIpv6OnIost   affine3Ds5   class TestClass(object):
   """{0} comment"""
   pass(   R(   R)   R*   R+   R,   R-   (   R   R   R   R   R   R
   R   R   R    R!   R"   (   R   R   t   ccn(    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_camel_cased_words˜   s,    		
c         C   s>   t  j d ƒ } |  j j | ƒ |  j j ƒ  g  k s: t ‚ d  S(   Ns5   def fff(param_name):
   """test param_name"""
   pass(   R   R   R
   R   R    R!   R"   (   R   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt    test_skip_words_with_underscoresµ   s    	c         C   s5   |  j  j t d ƒ ƒ |  j j ƒ  g  k s1 t ‚ d  S(   Ns   # uname@domain.tld(   R
   R   R   R    R!   R"   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_email_address½   s    c         C   s5   |  j  j t d ƒ ƒ |  j j ƒ  g  k s1 t ‚ d  S(   Ns"   # https://github.com/rfk/pyenchant(   R
   R   R   R    R!   R"   (   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_urlsÃ   s    c         C   s`   t  j d ƒ } |  j t d d d d d d d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXd  S(	   NsV   class ComentAbc(object):
   """This is :class:`ComentAbc` with a bad coment"""
   passs   wrong-spelling-in-docstringR   i   R   R   s,   This is :class:`ComentAbc` with a bad coments,                                         ^^^^^^(   R   R   R   R   R   R
   R   (   R   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   test_skip_sphinx_directivesÉ   s    	c         C   s`   t  j d ƒ } |  j t d d d d d d d |  j d ƒ f ƒƒ  |  j j | ƒ Wd  QXd  S(	   Nsu   
        class ComentAbc(object):
            """This is Comment/Abcz with a bad comment"""
            pass
        s   wrong-spelling-in-docstringR   i   R   t   Abczs'   This is Comment/Abcz with a bad comments                   ^^^^(   R   R   R   R   R   R
   R   (   R   R   (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt)   test_handle_words_joined_by_forward_slashÕ   s    	N(   t   __name__t
   __module__R    t   SpellingCheckert   CHECKER_CLASSt   pytestt   markt   skipift
   spell_dictt   Nonet   skip_on_missing_package_or_dictR   R   R   R   R   t   TrueR   R#   R$   R%   R&   R'   R/   R0   R1   R2   R3   R5   (    (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyR   $   sJ   						(   t   __doc__R:   R   t   pylint.checkersR    t   pylint.testutilsR   R   R   R   t   enchantt   ImportErrorR>   R=   t   Dictt   DictNotFoundErrorR   (    (    (    sD   lib/python2.7/site-packages/pylint/test/unittest_checker_spelling.pyt   <module>   s    "

