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

Unified Diff: Lib/test/test_tokenize.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/test/test_importlib/source/test_source_encoding.py ('k') | Lib/tokenize.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_tokenize.py Thu Sep 05 18:02:31 2013 +0300
+++ b/Lib/test/test_tokenize.py Sat Sep 07 17:49:25 2013 +0300
@@ -946,6 +946,13 @@
readline = self.get_readline((b'# coding: bad\n',))
self.assertRaises(SyntaxError, detect_encoding, readline)
+ def test_false_encoding(self):
+ # Issue 18873: "Encoding" detected in non-comment lines
+ readline = self.get_readline((b'print("#coding=fake")',))
+ encoding, consumed_lines = detect_encoding(readline)
+ self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(consumed_lines, [b'print("#coding=fake")'])
+
def test_open(self):
filename = support.TESTFN + '.py'
self.addCleanup(support.unlink, filename)
« no previous file with comments | « Lib/test/test_importlib/source/test_source_encoding.py ('k') | Lib/tokenize.py » ('j') | no next file with comments »

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