Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ease
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ease
Commits
cc97ad30
Commit
cc97ad30
authored
Dec 06, 2013
by
Will Daly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for spellcheck
parent
42f95138
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
ease/tests/test_spellcheck.py
+46
-0
No files found.
ease/tests/test_spellcheck.py
0 → 100644
View file @
cc97ad30
from
unittest
import
TestCase
from
nose.tools
import
assert_equal
from
mock
import
patch
from
ease.util_functions
import
spell_correct
class
SpellCheckUnitTest
(
TestCase
):
"""
Test that spell-check works correctly.
"""
def
test_all_correct
(
self
):
self
.
_assert_spell
(
"The quick brown dog jumped over the lazy fox."
,
"The quick brown dog jumped over the lazy fox."
,
0
,
"The quick brown dog jumped over the lazy fox."
)
def
test_some_misspelled
(
self
):
self
.
_assert_spell
(
"The quuick brown dog jimped over the lazy fox."
,
"The quick brown dog jumped over the lazy fox."
,
2
,
"The <bs>quuick</bs> brown dog <bs>jimped</bs> over the lazy fox."
,
)
def
test_empty_str
(
self
):
self
.
_assert_spell
(
""
,
""
,
0
,
""
)
def
test_unicode
(
self
):
self
.
_assert_spell
(
"The quick brown dog jimped over the
\u00FC
ber fox."
,
"The quick brown dog jumped over the
\u00FC
ber fox."
,
2
,
"The quick brown dog <bs>jimped</bs> over the
\u00FC
ber fox."
,
)
@patch
(
"util_functions.os.popen"
)
def
test_aspell_not_found
(
self
,
popen_mock
):
# Expected behavior when aspell is not installed is to return the original
# string with no corrections.
popen_mock
.
side_effect
=
OSError
self
.
_assert_spell
(
"Test striiing"
,
"Test striiing"
,
0
,
"Test striiing"
)
def
_assert_spell
(
self
,
input_str
,
expected_str
,
expected_num_changed
,
expected_markup
):
result
=
spell_correct
(
input_str
)
assert_equal
(
result
,
(
expected_str
,
expected_num_changed
,
expected_markup
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment