Skip to content

Commit

Permalink
test: test using file objects
Browse files Browse the repository at this point in the history
  • Loading branch information
nrnrk committed Oct 18, 2024
1 parent f17a84c commit 14d2860
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_symspellpy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from io import StringIO
from pathlib import Path
from unittest import TestCase

Expand Down Expand Up @@ -239,6 +240,18 @@ def test_load_dictionary_encoding(self, symspell_default):
assert 1 == len(result)
assert "АБИ" == result[0].term

def test_load_dictionary_from_string_io(self, symspell_default, dictionary_path):
with open(dictionary_path, "r") as f:
symspell_default.load_dictionary(StringIO(f.read()), 0, 1)
assert 82834 == symspell_default.word_count
assert 676094 == symspell_default.entry_count

def test_load_dictionary_from_text_io_wrapper(self, symspell_default, dictionary_path):
with open(dictionary_path, "r") as f:
symspell_default.load_dictionary(f, 0, 1)
assert 82834 == symspell_default.word_count
assert 676094 == symspell_default.entry_count

def test_create_dictionary_invalid_path(self, symspell_default):
with TestCase.assertLogs("symspellpy.symspellpy.logger", level="ERROR") as cm:
assert not symspell_default.create_dictionary(INVALID_PATH)
Expand Down

0 comments on commit 14d2860

Please sign in to comment.