summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_linecache.py
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2021-04-06 02:18:41 (GMT)
committerGitHub <noreply@github.com>2021-04-06 02:18:41 (GMT)
commitfb78692f2ad5ee4747f13a73943fbf134b637669 (patch)
treebeb9f1abe584a74f281955ead6541cdeeeaa17a8 /Lib/test/test_linecache.py
parentf84d5a113680c5a6aaaf9130aed7a34d611748ff (diff)
downloadcpython-fb78692f2ad5ee4747f13a73943fbf134b637669.zip
cpython-fb78692f2ad5ee4747f13a73943fbf134b637669.tar.gz
cpython-fb78692f2ad5ee4747f13a73943fbf134b637669.tar.bz2
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25189)
* Fix _sitebuiltins * Fix test_inspect * Fix test_interpreters * Fix test_io * Fix test_iter * Fix test_json * Fix test_linecache * Fix test_lltrace * Fix test_logging * Fix logging
Diffstat (limited to 'Lib/test/test_linecache.py')
-rw-r--r--Lib/test/test_linecache.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/test/test_linecache.py b/Lib/test/test_linecache.py
index cfc6ba8..59e00da 100644
--- a/Lib/test/test_linecache.py
+++ b/Lib/test/test_linecache.py
@@ -116,7 +116,7 @@ class LineCacheTests(unittest.TestCase):
# Check module loading
for entry in MODULES:
filename = os.path.join(MODULE_PATH, entry) + '.py'
- with open(filename) as file:
+ with open(filename, encoding='utf-8') as file:
for index, line in enumerate(file):
self.assertEqual(line, getline(filename, index + 1))
@@ -126,7 +126,7 @@ class LineCacheTests(unittest.TestCase):
def test_no_ending_newline(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(SOURCE_3)
lines = linecache.getlines(os_helper.TESTFN)
self.assertEqual(lines, ["\n", "def f():\n", " return 3\n"])
@@ -153,18 +153,18 @@ class LineCacheTests(unittest.TestCase):
# Create a source file and cache its contents
source_name = os_helper.TESTFN + '.py'
self.addCleanup(os_helper.unlink, source_name)
- with open(source_name, 'w') as source:
+ with open(source_name, 'w', encoding='utf-8') as source:
source.write(SOURCE_1)
getline(source_name, 1)
# Keep a copy of the old contents
source_list = []
- with open(source_name) as source:
+ with open(source_name, encoding='utf-8') as source:
for index, line in enumerate(source):
self.assertEqual(line, getline(source_name, index + 1))
source_list.append(line)
- with open(source_name, 'w') as source:
+ with open(source_name, 'w', encoding='utf-8') as source:
source.write(SOURCE_2)
# Try to update a bogus cache entry
@@ -176,7 +176,7 @@ class LineCacheTests(unittest.TestCase):
# Update the cache and check whether it matches the new source file
linecache.checkcache(source_name)
- with open(source_name) as source:
+ with open(source_name, encoding='utf-8') as source:
for index, line in enumerate(source):
self.assertEqual(line, getline(source_name, index + 1))
source_list.append(line)