Skip to content

Commit 39d41e3

Browse files
committed
fix: update main_test.py
1 parent 83fd88b commit 39d41e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

main_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def tearDown(self):
319319
os.chdir(self._orig_dir)
320320

321321
def _write_result(self, content: str):
322-
with open("result.txt", "w") as f:
322+
with open("result.txt", "w", encoding="utf-8") as f:
323323
f.write(content)
324324

325325
def test_empty_file_returns_none(self):
@@ -351,7 +351,8 @@ def setUp(self):
351351
self._tmpdir = tempfile.mkdtemp()
352352
os.chdir(self._tmpdir)
353353
# Create an empty result.txt
354-
open("result.txt", "w").close()
354+
with open("result.txt", "w", encoding="utf-8"):
355+
pass
355356

356357
def tearDown(self):
357358
os.chdir(self._orig_dir)
@@ -370,7 +371,7 @@ def test_success_writes_success_title(self):
370371
):
371372
rc = main.add_job_summary()
372373
self.assertEqual(rc, 0)
373-
with open(summary_path) as f:
374+
with open(summary_path, encoding="utf-8") as f:
374375
content = f.read()
375376
self.assertIn(main.SUCCESS_TITLE, content)
376377

@@ -383,7 +384,7 @@ def test_failure_writes_failure_title(self):
383384
):
384385
rc = main.add_job_summary()
385386
self.assertEqual(rc, 1)
386-
with open(summary_path) as f:
387+
with open(summary_path, encoding="utf-8") as f:
387388
content = f.read()
388389
self.assertIn(main.FAILURE_TITLE, content)
389390
self.assertIn("bad commit message", content)
@@ -489,7 +490,8 @@ def setUp(self):
489490
self._orig_dir = os.getcwd()
490491
self._tmpdir = tempfile.mkdtemp()
491492
os.chdir(self._tmpdir)
492-
open("result.txt", "w").close()
493+
with open("result.txt", "w", encoding="utf-8"):
494+
pass
493495

494496
def tearDown(self):
495497
os.chdir(self._orig_dir)

0 commit comments

Comments
 (0)