summaryrefslogtreecommitdiff
path: root/tests/test_phystokens.py
diff options
context:
space:
mode:
authorNed Batchelder <nedbat@gmail.com>2014-07-05 07:26:30 -0400
committerNed Batchelder <nedbat@gmail.com>2014-07-05 07:26:30 -0400
commitdcaa0ae12a1ad2545d53204d1809ac439b394b6d (patch)
treebfc00cff86262ccfaa2f36e56ddb537146d9fb32 /tests/test_phystokens.py
parent4cc85293e42efc262d9e7224435bbbc3afb1596b (diff)
parent3d697b2583ceb8c6267ba82d8573686e44b9b71b (diff)
downloadpython-coveragepy-dcaa0ae12a1ad2545d53204d1809ac439b394b6d.tar.gz
Merged in asottile/coverage.py/fix_source_encoding (pull request #38)
Fix non-comment encoding detection.
Diffstat (limited to 'tests/test_phystokens.py')
-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 e15400b..4755c16 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"