[Python-checkins] bpo-43651: Fix EncodingWarning in test_warnings (GH-25126)
methane
webhook-mailer at python.org
Thu Apr 1 19:57:13 EDT 2021
https://github.com/python/cpython/commit/036fc7de24cc961d65b60fba266104009feb2797
commit: 036fc7de24cc961d65b60fba266104009feb2797
branch: master
author: Inada Naoki <songofacandy at gmail.com>
committer: methane <songofacandy at gmail.com>
date: 2021-04-02T08:57:05+09:00
summary:
bpo-43651: Fix EncodingWarning in test_warnings (GH-25126)
files:
M Lib/test/test_warnings/__init__.py
diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py
index 04f7560ecc09c..4b1b4e193cb16 100644
--- a/Lib/test/test_warnings/__init__.py
+++ b/Lib/test/test_warnings/__init__.py
@@ -935,10 +935,10 @@ class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
def test_tracemalloc(self):
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
- with open(os_helper.TESTFN, 'w') as fp:
+ with open(os_helper.TESTFN, 'w', encoding="utf-8") as fp:
fp.write(textwrap.dedent("""
def func():
- f = open(__file__)
+ f = open(__file__, "rb")
# Emit ResourceWarning
f = None
@@ -973,7 +973,7 @@ def run(*args):
File "{filename}", lineno 7
func()
File "{filename}", lineno 3
- f = open(__file__)
+ f = open(__file__, "rb")
''').strip()
self.assertEqual(stderr, expected)
More information about the Python-checkins
mailing list