summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-12-24 09:24:11 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-12-24 09:24:11 -0500
commit670ce62b70c50a4e84bc185e42998c860565a5fc (patch)
tree133f056074715069f039259055919198f6cf2f5b
parent46df263f42226987bb690371e1a5e87a978cc114 (diff)
downloadpython-coveragepy-git-670ce62b70c50a4e84bc185e42998c860565a5fc.tar.gz
Add a failing test of double coding declarations, for #453
-rw-r--r--tests/test_phystokens.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/test_phystokens.py b/tests/test_phystokens.py
index e28fb176..7acc3225 100644
--- a/tests/test_phystokens.py
+++ b/tests/test_phystokens.py
@@ -103,6 +103,7 @@ ENCODING_DECLARATION_SOURCES = [
b"# This Python file uses this encoding: cp850\n",
b"# This file uses a different encoding:\n# coding: cp850\n",
b"\n# coding=cp850\n\n",
+ b"# -*- coding:cp850 -*-\n# vim: fileencoding=cp850\n",
]
class SourceEncodingTest(CoverageTest):
@@ -168,6 +169,8 @@ class NeuterEncodingDeclarationTest(CoverageTest):
)
self.assertEqual(lines_different, 1)
+ # The neutered source will be detected as having no encoding
+ # declaration.
self.assertEqual(
source_encoding(neutered),
DEF_ENCODING,
@@ -181,5 +184,9 @@ class CompileUnicodeTest(CoverageTest):
run_in_temp_dir = False
def test_cp1252(self):
- uni = u"""# coding: cp1252\n# \u201C curly \u201D\n"""
- compile_unicode(uni, "<string>", "exec")
+ uni = u"""# coding: cp1252\n# \u201C curly \u201D\na = 42"""
+ # This doesn't raise an exception:
+ code = compile_unicode(uni, "<string>", "exec")
+ globs = {}
+ exec(code, globs)
+ self.assertEqual(globs['a'], 42)