summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2014-06-29 14:35:02 -0700
committerAnthony Sottile <asottile@umich.edu>2014-06-29 14:35:02 -0700
commit460d303ed2361abe554da075c184a370d7d54701 (patch)
treef01bcc1a39146c32f9ce442b442d18b21cc66d94 /tests
parentbe5178fda38750c0aae78061bf1b1bf3397a467d (diff)
downloadpython-coveragepy-git-460d303ed2361abe554da075c184a370d7d54701.tar.gz
Fix non-comment encoding detection.
--HG-- branch : fix_source_encoding
Diffstat (limited to 'tests')
-rw-r--r--tests/test_phystokens.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/test_phystokens.py b/tests/test_phystokens.py
index e15400b6..4755c167 100644
--- a/tests/test_phystokens.py
+++ b/tests/test_phystokens.py
@@ -97,6 +97,11 @@ if sys.version_info < (3, 0):
source = "# This Python file uses this encoding: utf-8\n"
self.assertEqual(source_encoding(source), 'utf-8')
+ def test_detect_source_encoding_not_in_comment(self):
+ # Should not detect anything here
+ source = 'def parse(src, encoding=None):\n pass'
+ self.assertEqual(source_encoding(source), 'ascii')
+
def test_detect_source_encoding_on_second_line(self):
# A coding declaration should be found despite a first blank line.
source = "\n# coding=cp850\n\n"