|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 | """Test suite for language_check.""" |
| 4 | +from __future__ import unicode_literals |
4 | 5 |
|
5 | 6 | import unittest |
6 | 7 | import warnings |
@@ -127,6 +128,24 @@ def test_disable_spellcheck(self): |
127 | 128 | lang_check.enable_spellchecking() |
128 | 129 | self.assertTrue(lang_check.check(sentence_with_misspelling)) |
129 | 130 |
|
| 131 | + def test_README_with_unicode(self): |
| 132 | + tool = language_check.LanguageTool('en-US') |
| 133 | + text = ('A sentence with a error in the ' |
| 134 | + 'Hitchhiker’s Guide tot he Galaxy') |
| 135 | + matches = tool.check(text) |
| 136 | + self.assertEqual(len(matches), 2) |
| 137 | + self.assertEqual((matches[0].fromy, matches[0].fromx), |
| 138 | + (0, 16)) |
| 139 | + self.assertEqual((matches[0].ruleId, matches[0].replacements), |
| 140 | + ('EN_A_VS_AN', ['an'])) |
| 141 | + self.assertEqual((matches[1].fromy, matches[1].fromx), |
| 142 | + (0, 50)) |
| 143 | + self.assertEqual((matches[1].ruleId, matches[1].replacements), |
| 144 | + ('TOT_HE', ['to the'])) |
| 145 | + corrected = language_check.correct(text, matches) |
| 146 | + self.assertEqual(corrected, 'A sentence with an error in the ' |
| 147 | + 'Hitchhiker’s Guide to the Galaxy') |
| 148 | + |
130 | 149 |
|
131 | 150 | if __name__ == '__main__': |
132 | 151 | unittest.main() |
0 commit comments