Mini Shell

Direktori : /usr/lib/python3.6/site-packages/enchant/checker/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/enchant/checker/__pycache__/tests.cpython-36.pyc

3

��]�(�@sJdZddlZddlZddlZddlTddlTddlTGdd�dej�ZdS)zL

    enchant.checker.tests:  Unittests for enchant SpellChecker class
    
�N)�*c@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�TestCheckerz7TestCases for checking behaviour of SpellChecker class.cCs�d}td|d�}�x�t|�D�]t\}}|dkrf|j|jd�|j|jd�|jd|j�k�|jd�|dkr||j|jd	�|d
kr�|j|jd�|j|jd�d
�|j|j	d�d�|jt
d��|dkr�|j|jd�|jd�|dk�r|j|jd�|jd t
|j��|dk�r2|j|jd�|jd�|dk�r^|j|jd�|jd�|jd�|dk�r�|j|jd�|jd�|dkr|jd�qWd}|j|j�|�dS)!z+Test a basic run of the SpellChecker class.z�This is sme text with a few speling erors in it. Its gret
        for checking wheather things are working proprly with the SpellChecker
        class. Not gret for much elss though.�en_US)�textr�sme�Zsome�Zspeling��erors�zling z in i�errors�ZgretZgreat�ZwheatherZwhether�ZproprlyZproperly�SpellChecker�Zelss�elsez%Extraneous spelling errors were foundz�This is some text with a few speling errors in it. Its great
        for checking whether things are working properly with the SpellChecker
        class. Not great for much else though.N���)r�	enumerate�assertEqual�word�wordposZ
assertTrueZsuggest�replaceZleading_contextZtrailing_context�raw_unicode�replace_always�
set_offset�len�
ignore_always�fail�get_text)�selfr�chkr�n�errZtext2�r$�/usr/lib/python3.6/tests.py�
test_basic0sF









zTestChecker.test_basiccCsDd}td|tjjgd�}x|D]}|jd�qW|j|j�|�dS)z.Test SpellChecker with the 'filters' argument.z8I contain WikiWords that ShouldBe skipped by the filtersr)r�filtersz%Extraneous spelling errors were foundN)r�enchant�tokenizeZWikiWordFilterrrr)r rr!r#r$r$r%�test_filtersds
zTestChecker.test_filterscCsDd}td|tjjgd�}x|D]}|jd�qW|j|j�|�dS)z/Test SpellChecker with the 'chunkers' argument.z9I contain <html a=xjvf>tags</html> that should be skippedr)r�chunkersz%Extraneous spelling errors were foundN)rr(r)�HTMLChunkerrrr)r rr!r#r$r$r%�
test_chunkersns
zTestChecker.test_chunkerscCs�d}td|tjjgtjjgd�}x|D]}|jd�q&W|j|j�|�td|tjjgd�}x|D]}|j|jd�PqbW|j|j�|�td|tjjgd�}x|D]}|j|jd�Pq�W|j|j�|�d	S)
z>Test SpellChecker with the 'chunkers' and 'filters' arguments.z�I contain <html a=xjvf>tags</html> that should be skipped
                  along with a <a href='http://example.com/">link to
                  http://example.com/</a> that should also be skippedr)rr'r+z%Extraneous spelling errors were found)rr'Zhtml)rr+ZhttpN)	rr(r)Z	URLFilterr,rrrr)r rr!r#r$r$r%�test_chunkers_and_filtersxs&


z%TestChecker.test_chunkers_and_filterscCstd�}td|�}x�t|�D]�\}}|dkrT|j|jtd��|j|jd�|j�|dkr�|j|jtd��|jd�|j|jtd�td��|d	kr�|j|jtd
��|j	d�|j
d�|d
kr|j|jtd��|j	d�qW|j|d
�|j|j�td��dS)z(Test SpellChecker with a unicode string.z(I am a unicode strng with unicode erors.rr�unicoderrZstrng�stringr	r
Zerrosrr
rz*I am a unicode string with unicode errors.Ni����)rrrrrrrrZ_replace_wordsrrr)r rr!r"r#r$r$r%�test_unicode�s(



zTestChecker.test_unicodecCsttkrd}nd}d}tj||�}td|�}x�t|�D]�\}}|dkrd|j|jd�|j|jjt�|dkr�|j|jd�tj|d	�||j|jt	|j��<|j
dt	|j��|d
kr6|j|jd�|jd�q6W|j|d
�ttkr�|j|j�d
�n|j|j
�d
�dS)z2Test SpellChecker with a character array as input.�u�czI wll be stord in an arayrrZwllrZstordZstoredr	Zaray�arrayzI wll be stored in an arrayNr)�strr/r4rrrr�	__class__rrrrZ	tounicodeZtostring)r ZatyperZtxtarrr!r"r#r$r$r%�test_chararray�s*
"zTestChecker.test_chararraycCs�ddlm}|ddd�}d}t||�}xHt|�D]<\}}|dkrN|j|jd�|dkr0|j|jd�|j�q0W|j|d�dS)	zTest checker loop with PWL.r)�DictWithPWLrNz=I am sme text to be cheked with personal list of cheked wordsrrZcheked)r(r8rrrr�add)r r8�dZtxtr!r"r#r$r$r%�test_pwl�s
zTestChecker.test_pwlcCsXttjd�d�}|jd�x|D]}q Wttjd�d�}|jtd��x|D]}qLWdS)zTestcases for bug #2785373.Zen�z"So, one dey when I wes 17, I left.N)rr(ZDictZset_textr)r r3r#r$r$r%�test_bug2785373�s


zTestChecker.test_bug2785373cCs4t�}|dkr|jtt�nt�}|j|j|�dS)N)Zget_default_languageZassertRaisesZDefaultLanguageNotFoundErrorrr�lang)r r>Zcheckerr$r$r%�test_default_language�s
z!TestChecker.test_default_languagecCsNd}td|�}x*t|�D]\}}|jd�|dkst�qW|j|j�d�dS)z6Testcase for replacing with a shorter string (bug #10)z. I Bezwaar tegen verguning.rZSPAMr
z. I SPAM SPAM SPAM.N)rrr�AssertionErrorrr)r rr!�ir#r$r$r%� test_replace_with_shorter_string�s

z,TestChecker.test_replace_with_shorter_stringcCsNd}td|�}x*t|�D]\}}|jd�|dkst�qW|j|j�d�dS)z5Testcase for replacing with an empty string (bug #10)z. I Bezwaar tegen verguning.rr<r
z. I   .N)rrrr@rr)r rr!rAr#r$r$r%�test_replace_with_empty_string�s

z*TestChecker.test_replace_with_empty_stringN)�__name__�
__module__�__qualname__�__doc__r&r*r-r.r1r7r;r=r?rBrCr$r$r$r%r-s4

	r)	rGZunittestr(Zenchant.tokenizeZ
enchant.utilsZenchant.errorsZenchant.checkerZTestCaserr$r$r$r%�<module>"s