Merge pull request #492 from ApricityXX/1029-9

fix:测试中临时文件未在异常情况下清理
This commit is contained in:
Jerry Z H
2025-10-31 14:45:30 +08:00
committed by GitHub

View File

@@ -36,11 +36,15 @@ class TestReadImageTool(unittest.TestCase):
test_text = "Sample text for testing."
test_filename = "test_extracted_text.txt"
save_text_to_file(test_text, test_filename)
self.assertTrue(os.path.exists(test_filename))
with open(test_filename, 'r', encoding='utf-8') as f:
content = f.read()
self.assertEqual(content, test_text)
os.remove(test_filename)
try:
self.assertTrue(os.path.exists(test_filename))
with open(test_filename, 'r', encoding='utf-8') as f:
content = f.read()
self.assertEqual(content, test_text)
finally:
if os.path.exists(test_filename):
os.remove(test_filename)
def test_extract_text_from_image_without_east(self):
# Save the test OCR image as a temporary file