]> granicus.if.org Git - python/commitdiff
Fix test_linecache change.
authorRobert Collins <rbtcollins@hp.com>
Wed, 19 Aug 2015 22:48:46 +0000 (10:48 +1200)
committerRobert Collins <rbtcollins@hp.com>
Wed, 19 Aug 2015 22:48:46 +0000 (10:48 +1200)
In non-UTF8 locales open() will have the wrong encoding for the test
data. We need to open the file via tokenize, to get a detected
encoding instead.

Lib/test/test_linecache.py

index e74aef35802aa213bff9cf78e891a7ce0cf1bb62..240db7f8747a66f591957b918fa2c32eadc0eff4 100644 (file)
@@ -4,6 +4,7 @@ import linecache
 import unittest
 import os.path
 import tempfile
+import tokenize
 from test import support
 
 
@@ -54,7 +55,7 @@ class GetLineTestsGoodData(TempFile):
         super().setUp()
 
     def test_getline(self):
-        with open(self.file_name) as fp:
+        with tokenize.open(self.file_name) as fp:
             for index, line in enumerate(fp):
                 if not line.endswith('\n'):
                     line += '\n'