o
    br*                     @   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	 zddl
Z
W n ey-   dZ
Y nw dZe
durHz	e
d dZW n
 e
jyG   Y nw G dd deZdS )z"Unittest for the spelling checker.    N)spelling)CheckerTestCaseMessage
set_config_tokenize_stren_USc                   @   s  e Zd ZejZejje	du ddZ
d*ddZe
ee	ddd	 Ze
ee	ded
ddd Ze
ee	ddd Zejjddde
ee	ddd Ze
ee	ddd Ze
ee	ddd Ze
ee	ddd Ze
ee	ddd Ze
ee	ddd Ze
ee	ddd Ze
ee	dd d! Ze
ee	dd"d# Ze
ee	dd$d% Ze
ee	dd&d' Ze
ee	dd(d) ZdS )+TestSpellingCheckerNz?missing python-enchant package or missing spelling dictionaries)reason   c                 C   s"   d d| jj|d | S )Nz'{}'z' or ')formatjoincheckerspelling_dictZsuggest)selfwordcount r   d/var/www/secure340b-portal/env/lib/python3.10/site-packages/pylint/test/unittest_checker_spelling.py_get_msg_suggestions-   s   z(TestSpellingChecker._get_msg_suggestions)r   c                 C   sX   |  tddddd| dfd | jtd W d    d S 1 s%w   Y  d S )Nwrong-spelling-in-comment   coment# bad coment      ^^^^^^lineargsassertAddsMessagesr   r   r   process_tokensr   r   r   r   r   test_check_bad_coment2   s   "z)TestSpellingChecker.test_check_bad_coment   )Zmax_spelling_suggestionsc                 C   s\   |  tddddd| jdddfd | jtd W d    d S 1 s'w   Y  d S )	Nr   r   r   r   r   r"   )r   r   r   r    r   r   r   -test_check_bad_coment_custom_suggestion_countC   s   "zATestSpellingChecker.test_check_bad_coment_custom_suggestion_countc                 C   s   t d}| tddddd| dfd | j| W d    n1 s'w   Y  t d}| tddddd| dfd | j| W d    d S 1 sTw   Y  d S )	Nz&def fff():
   """bad coment"""
   passwrong-spelling-in-docstringr"   r   z
bad comentz
    ^^^^^^r   z.class Abc(object):
   """bad coment"""
   pass)astroidextract_noder   r   r   r   visit_functiondefvisit_classdefr   stmtr   r   r   test_check_bad_docstringU   s8   

"z,TestSpellingChecker.test_check_bad_docstringTz"pyenchant's tokenizer strips thesec                 C   sP   t d}| tdddd | j| W d    d S 1 s!w   Y  d S )Nz$def fff():
   """test\x00"""
   passzinvalid-characters-in-docstringr"   )ztest r   )r%   r&   r   r   r   r'   r)   r   r   r   !test_invalid_docstring_charactersv   s   
"z5TestSpellingChecker.test_invalid_docstring_charactersc                 C   &   | j td | j g ksJ d S )Nz#!/usr/bin/env pythonr   r   r   linterrelease_messagesr    r   r   r   test_skip_shebangs      z&TestSpellingChecker.test_skip_shebangsc                 C   s   | j td | j g ksJ | j td | j g ks"J | j td | j g ks3J | j td | j g ksDJ | j td | j g ksUJ | j td | j g ksfJ d S )Nz# -*- coding: utf-8 -*-z# coding=utf-8z# vim: set fileencoding=utf-8 :z-#!/usr/bin/env python
# -*- coding: utf-8 -*-z$#!/usr/bin/env python
# coding=utf-8z5#!/usr/bin/env python
# vim: set fileencoding=utf-8 :r.   r    r   r   r    test_skip_python_coding_comments   s$   z4TestSpellingChecker.test_skip_python_coding_commentsc                 C   r-   )Nz4# Line 1
 Line 2
# pylint: disable=ungrouped-importsr.   r    r   r   r   2test_skip_top_level_pylint_enable_disable_comments   s   zFTestSpellingChecker.test_skip_top_level_pylint_enable_disable_commentsc                 C   r-   )Nz
# 0ne
# Thr33
# Sh3llr.   r    r   r   r   test_skip_words_with_numbers   r2   z0TestSpellingChecker.test_skip_words_with_numbersc                 C   ^   t d}| tddddd| dfd | j| W d    d S 1 s(w   Y  d S )NzEclass ComentAbc(object):
   """ComentAbc with a bad coment"""
   passr$   r"   r   zComentAbc with a bad coment                     ^^^^^^r   r%   r&   r   r   r   r   r(   r)   r   r   r   test_skip_wiki_words       "z(TestSpellingChecker.test_skip_wiki_wordsc                 C   s   t d}| tddddd| dfd | j| W d    n1 s'w   Y  t d}| tdddd	d| dfd | j| W d    n1 sSw   Y  d
D ]}t d|}| j| | j	 g kssJ qZd S )NzEclass ComentAbc(object):
   """comentAbc with a bad coment"""
   passr$   r"   r   zcomentAbc with a bad comentr7   r   zEclass ComentAbc(object):
   """argumentN with a bad coment"""
   passzargumentN with a bad coment)ZxmlHttpRequestZnewCustomerZnewCustomerIdZinnerStopwatchZsupportsIpv6OnIosZaffine3Dz4class TestClass(object):
   """{} comment"""
   pass)
r%   r&   r   r   r   r   r(   r   r/   r0   )r   r*   Zccnr   r   r   test_skip_camel_cased_words   sN   z/TestSpellingChecker.test_skip_camel_cased_wordsc                 C   s,   t d}| j| | j g ksJ d S )Nz5def fff(param_name):
   """test param_name"""
   pass)r%   r&   r   r'   r/   r0   r)   r   r   r    test_skip_words_with_underscores   s
   z4TestSpellingChecker.test_skip_words_with_underscoresc                 C   r-   )Nz# uname@domain.tldr.   r    r   r   r   test_skip_email_address   r2   z+TestSpellingChecker.test_skip_email_addressc                 C   r-   )Nz"# https://github.com/rfk/pyenchantr.   r    r   r   r   test_skip_urls  r2   z"TestSpellingChecker.test_skip_urlsc                 C   r6   )NzVclass ComentAbc(object):
   """This is :class:`ComentAbc` with a bad coment"""
   passr$   r"   r   z,This is :class:`ComentAbc` with a bad comentz,                                      ^^^^^^r   r8   r)   r   r   r   test_skip_sphinx_directives  r:   z/TestSpellingChecker.test_skip_sphinx_directivesc                 C   r6   )Nzu
        class ComentAbc(object):
            """This is Comment/Abcz with a bad comment"""
            pass
        r$      ZAbczz'This is Comment/Abcz with a bad commentz                ^^^^r   r8   r)   r   r   r   )test_handle_words_joined_by_forward_slash  s    "z=TestSpellingChecker.test_handle_words_joined_by_forward_slash)r
   )__name__
__module____qualname__r   ZSpellingCheckerZCHECKER_CLASSpytestmarkZskipif
spell_dictZskip_on_missing_package_or_dictr   r   r!   r#   r+   r,   r1   r3   r4   r5   r9   r;   r<   r=   r>   r?   rA   r   r   r   r   r   %   sl    
2r   )__doc__rE   r%   Zpylint.checkersr   Zpylint.testutilsr   r   r   r   ZenchantImportErrorrG   DictZDictNotFoundErrorr   r   r   r   r   <module>   s&   
