8000 bpo-43651: PEP 597: Fix EncodingWarning in test_filecmp (GH-25159) · python/cpython@ee952b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee952b5

Browse files
authored
bpo-43651: PEP 597: Fix EncodingWarning in test_filecmp (GH-25159)
1 parent de522a8 commit ee952b5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Lib/test/test_filecmp.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ def setUp(self):
1515
self.name_diff = os_helper.TESTFN + '-diff'
1616
data = 'Contents of file go here.\n'
1717
for name in [self.name, self.name_same, self.name_diff]:
18-
with open(name, 'w') as output:
18+
with open(name, 'w', encoding="utf-8") as output:
1919
output.write(data)
2020

21-
with open(self.name_diff, 'a+') as output:
21+
with open(self.name_diff, 'a+', encoding="utf-8") as output:
2222
output.write('An extra line.\n')
2323
self.dir = tempfile.gettempdir()
2424

@@ -72,10 +72,10 @@ def setUp(self):
7272
fn = 'FiLe' # Verify case-insensitive comparison
7373
else:
7474
fn = 'file'
75-
with open(os.path.join(dir, fn), 'w') as output:
75+
with open(os.path.join(dir, fn), 'w', encoding="utf-8") as output:
7676
output.write(data)
7777

78-
with open(os.path.join(self.dir_diff, 'file2'), 'w') as output:
78+
with open(os.path.join(self.dir_diff, 'file2'), 'w', encoding="utf-8") as output:
7979
output.write('An extra file.\n')
8080

8181
def tearDown(self):
@@ -103,7 +103,7 @@ def test_cmpfiles(self):
103103
"Comparing directory to same fails")
104104

105105
# Add different file2
106-
with open(os.path.join(self.dir, 'file2'), 'w') as output:
106+
with open(os.path.join(self.dir, 'file2'), 'w', encoding="utf-8") as output:
107107
output.write('Different contents.\n')
108108

109109
self.assertFalse(filecmp.cmpfiles(self.dir, self.dir_same,
@@ -188,7 +188,7 @@ def test_dircmp(self):
188188
self._assert_report(d.report, expected_report)
189189

190190
# Add different file2
191-
with open(os.path.join(self.dir_diff, 'file2'), 'w') as output:
191+
with open(os.path.join(self.dir_diff, 'file2'), 'w', encoding="utf-8") as output:
192192
output.write('Different contents.\n')
193193
d = filecmp.dircmp(self.dir, self.dir_diff)
194194
self.assertEqual(d.same_files, ['file'])

0 commit comments

Comments
 (0)
0