summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2021-04-05 03:32:35 (GMT)
committerGitHub <noreply@github.com>2021-04-05 03:32:35 (GMT)
commitee952b5c7355cb64179ca9bb77b13e7738132d3d (patch)
tree82dfc7a31bb05a37c32dde313ae723a6acd4aa58
parentde522a89e42a35da9275169b113460c3581e32d7 (diff)
downloadcpython-ee952b5c7355cb64179ca9bb77b13e7738132d3d.zip
cpython-ee952b5c7355cb64179ca9bb77b13e7738132d3d.tar.gz
cpython-ee952b5c7355cb64179ca9bb77b13e7738132d3d.tar.bz2
bpo-43651: PEP 597: Fix EncodingWarning in test_filecmp (GH-25159)
-rw-r--r--Lib/test/test_filecmp.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py
index fa4f67b..64ba5a0 100644
--- a/Lib/test/test_filecmp.py
+++ b/Lib/test/test_filecmp.py
@@ -15,10 +15,10 @@ class FileCompareTestCase(unittest.TestCase):
self.name_diff = os_helper.TESTFN + '-diff'
data = 'Contents of file go here.\n'
for name in [self.name, self.name_same, self.name_diff]:
- with open(name, 'w') as output:
+ with open(name, 'w', encoding="utf-8") as output:
output.write(data)
- with open(self.name_diff, 'a+') as output:
+ with open(self.name_diff, 'a+', encoding="utf-8") as output:
output.write('An extra line.\n')
self.dir = tempfile.gettempdir()
@@ -72,10 +72,10 @@ class DirCompareTestCase(unittest.TestCase):
fn = 'FiLe' # Verify case-insensitive comparison
else:
fn = 'file'
- with open(os.path.join(dir, fn), 'w') as output:
+ with open(os.path.join(dir, fn), 'w', encoding="utf-8") as output:
output.write(data)
- with open(os.path.join(self.dir_diff, 'file2'), 'w') as output:
+ with open(os.path.join(self.dir_diff, 'file2'), 'w', encoding="utf-8") as output:
output.write('An extra file.\n')
def tearDown(self):
@@ -103,7 +103,7 @@ class DirCompareTestCase(unittest.TestCase):
"Comparing directory to same fails")
# Add different file2
- with open(os.path.join(self.dir, 'file2'), 'w') as output:
+ with open(os.path.join(self.dir, 'file2'), 'w', encoding="utf-8") as output:
output.write('Different contents.\n')
self.assertFalse(filecmp.cmpfiles(self.dir, self.dir_same,
@@ -188,7 +188,7 @@ class DirCompareTestCase(unittest.TestCase):
self._assert_report(d.report, expected_report)
# Add different file2
- with open(os.path.join(self.dir_diff, 'file2'), 'w') as output:
+ with open(os.path.join(self.dir_diff, 'file2'), 'w', encoding="utf-8") as output:
output.write('Different contents.\n')
d = filecmp.dircmp(self.dir, self.dir_diff)
self.assertEqual(d.same_files, ['file'])