Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
r9y9 committed Nov 18, 2023
1 parent e8955a6 commit f4ed8dc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/test_openjtalk.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import tempfile

import pyopenjtalk
Expand Down Expand Up @@ -92,17 +93,25 @@ def test_userdic():
p = pyopenjtalk.g2p(text)
assert p != expected

with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8", suffix=".csv") as f:
f.write("nnmn,,,1,名詞,一般,*,*,*,*,nnmn,ナナミン,ナナミン,1/4,*\n") #
with tempfile.NamedTemporaryFile(
mode="w", encoding="utf-8", suffix=".csv", delete=False
) as f:
f.write("nnmn,,,1,名詞,一般,*,*,*,*,nnmn,ナナミン,ナナミン,1/4,*\n")
f.write("GNU,,,1,名詞,一般,*,*,*,*,GNU,グヌー,グヌー,2/3,*\n")
f.flush()
f.close()

with tempfile.NamedTemporaryFile(
mode="w", encoding="utf-8", suffix=".dic"
mode="w",
encoding="utf-8",
suffix=".dic",
delete=False,
) as f2:
pyopenjtalk.mecab_dict_index(f.name, f2.name)
pyopenjtalk.update_global_jtalk_with_user_dict(f2.name)

os.remove(f.name)
os.remove(f2.name)

for text, expected in [
("nnmn", "n a n a m i N"),
("GNU", "g u n u u"),
Expand Down

0 comments on commit f4ed8dc

Please sign in to comment.