bpo-43651: Fix EncodingWarning in test_warnings (GH-25126)

This commit is contained in:
Inada Naoki 2021-04-02 08:57:05 +09:00 committed by GitHub
parent bd4ab8e739
commit 036fc7de24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -935,10 +935,10 @@ class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
def test_tracemalloc(self): def test_tracemalloc(self):
self.addCleanup(os_helper.unlink, os_helper.TESTFN) 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(""" fp.write(textwrap.dedent("""
def func(): def func():
f = open(__file__) f = open(__file__, "rb")
# Emit ResourceWarning # Emit ResourceWarning
f = None f = None
@ -973,7 +973,7 @@ class PyWarningsDisplayTests(WarningsDisplayTests, unittest.TestCase):
File "{filename}", lineno 7 File "{filename}", lineno 7
func() func()
File "{filename}", lineno 3 File "{filename}", lineno 3
f = open(__file__) f = open(__file__, "rb")
''').strip() ''').strip()
self.assertEqual(stderr, expected) self.assertEqual(stderr, expected)