diff --git a/tests/test_openjtalk.py b/tests/test_openjtalk.py index f372ed6..543effd 100644 --- a/tests/test_openjtalk.py +++ b/tests/test_openjtalk.py @@ -1,3 +1,4 @@ +import os import tempfile import pyopenjtalk @@ -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"),