Skip to content

Commit

Permalink
added test case for #150
Browse files Browse the repository at this point in the history
  • Loading branch information
bab2min committed Feb 14, 2024
1 parent ec38238 commit d2037b7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/test_kiwipiepy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import re
import tempfile

from kiwipiepy import Kiwi, TypoTransformer, basic_typos, MorphemeSet, sw_tokenizer, PretokenizedToken
from kiwipiepy.utils import Stopwords
Expand Down Expand Up @@ -38,6 +39,28 @@ def test_morpheme_set():
print(repr(ms))
assert len(ms) == 3

def test_load_user_dictionary():
kiwi = Kiwi()
try:
raised = False
kiwi.load_user_dictionary('non-existing-file.txt')
except OSError as e:
raised = True
print(e)
finally:
assert raised

with tempfile.NamedTemporaryFile(mode='w', encoding='utf-8', delete=False) as f:
f.write('잘못된 포맷의 파일입니다\n')
try:
raised = False
kiwi.load_user_dictionary(f.name)
except ValueError as e:
raised = True
print(e)
finally:
assert raised

def test_blocklist():
kiwi = Kiwi()
tokens = kiwi.tokenize("고마움을")
Expand Down

0 comments on commit d2037b7

Please sign in to comment.