Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(43066)

Unified Diff: Lib/test/test_importlib/source/test_source_encoding.py

Issue 18873: "Encoding" detected in non-comment lines
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/lib2to3/tests/test_refactor.py ('k') | Lib/test/test_tokenize.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_importlib/source/test_source_encoding.py Thu Sep 05 18:02:31 2013 +0300
+++ b/Lib/test/test_importlib/source/test_source_encoding.py Sat Sep 07 17:49:25 2013 +0300
@@ -10,7 +10,7 @@
import unittest
-CODING_RE = re.compile(r'coding[:=]\s*([-\w.]+)')
+CODING_RE = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)', re.ASCII)
class EncodingTest(unittest.TestCase):
@@ -41,7 +41,7 @@
def create_source(self, encoding):
encoding_line = "# coding={0}".format(encoding)
- assert CODING_RE.search(encoding_line)
+ assert CODING_RE.match(encoding_line)
source_lines = [encoding_line.encode('utf-8')]
source_lines.append(self.source_line.encode(encoding))
return b'\n'.join(source_lines)
@@ -50,7 +50,7 @@
# Make sure that an encoding that has never been a standard one for
# Python works.
encoding_line = "# coding=koi8-r"
- assert CODING_RE.search(encoding_line)
+ assert CODING_RE.match(encoding_line)
source = "{0}\na=42\n".format(encoding_line).encode("koi8-r")
self.run_test(source)
« no previous file with comments | « Lib/lib2to3/tests/test_refactor.py ('k') | Lib/test/test_tokenize.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+