From 3c814d547705640e91a1a876fad3ee7fb93efc2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8E=E9=96=93?= Date: Tue, 18 Apr 2023 17:59:36 +0900 Subject: [PATCH] =?UTF-8?q?win=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecs/jskult-batch-daily/tests/testing_utility.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ecs/jskult-batch-daily/tests/testing_utility.py b/ecs/jskult-batch-daily/tests/testing_utility.py index e95da8e7..5a6c3a42 100644 --- a/ecs/jskult-batch-daily/tests/testing_utility.py +++ b/ecs/jskult-batch-daily/tests/testing_utility.py @@ -1,5 +1,5 @@ -"""テスト用共通処理関数""" import csv +import os import tempfile from datetime import datetime @@ -22,12 +22,13 @@ def create_ultmarc_test_data_from_csv(file_path: str) -> DatFile: """ # 一度、Shift-JISファイルで書き出す - with open(file_path, encoding='utf8') as csv_file, tempfile.NamedTemporaryFile('w', encoding='cp932') as tmp_file: + with open(file_path, encoding='utf8') as csv_file, tempfile.NamedTemporaryFile('w', encoding='cp932', delete=False) as tmp_file: tmp_file.write(csv_file.read()) tmp_file.seek(0) tmpfile_path = tmp_file.name - dat_file = DatFile.from_path(tmpfile_path) + dat_file = DatFile.from_path(tmpfile_path) + os.unlink(tmpfile_path) return dat_file