Skip to content

Commit fac6025

Browse files
committed
Use pathlib.Path for file operations per review comment
1 parent 553d1c5 commit fac6025

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎Lib/test/test_filecmp.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import tempfile
88
import unittest
99

10+
from pathlib import Path
1011
from test import support
1112
from test.support import os_helper
1213
from unittest.mock import patch
@@ -408,12 +409,11 @@ def setUp(self):
408409
self.caseinsensitive = os.path.normcase('A') == os.path.normcase('a')
409410
data = 'Contents of file go here.\n'
410411

411-
os.mkdir(self.dir)
412+
Path(self.dir).mkdir(parents=True, exist_ok=True)
412413
subdir_path = os.path.join(self.dir, 'subdir')
413-
os.mkdir(subdir_path)
414+
Path(subdir_path).mkdir(parents=True, exist_ok=True)
414415
dir_file_path = os.path.join(self.dir, "file")
415-
with open(dir_file_path, 'w', encoding="utf-8") as output:
416-
output.write(data)
416+
Path(dir_file_path).write_text(data, encoding="utf-8")
417417

418418
for d in (self.dir_same, self.dir_same_shallow,
419419
self.dir_diff, self.dir_diff_file):

0 commit comments

Comments
 (0)