summaryrefslogtreecommitdiff
path: root/tests/test_parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-05-17 20:15:42 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-05-17 20:15:42 -0400
commit9e764b195723b15f29ed8182d1c6e37ac4a52c58 (patch)
treeb36b42b2c83c1c7fa27b9955ea257a64d36391c4 /tests/test_parser.py
parent5c78f193074cd74154020a6053720fa09dc26928 (diff)
downloadpython-coveragepy-git-9e764b195723b15f29ed8182d1c6e37ac4a52c58.tar.gz
All Python source is Unicode internally.
Unfortunately, this meant hacking around a silly Python 2 restriction (can't compile a Unicode string containing an encoding declaration).
Diffstat (limited to 'tests/test_parser.py')
-rw-r--r--tests/test_parser.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 81916a98..9359c408 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -1,7 +1,10 @@
"""Tests for Coverage.py's code parsing."""
import textwrap
+
from tests.coveragetest import CoverageTest
+
+from coverage import env
from coverage.parser import PythonParser
@@ -12,6 +15,8 @@ class PythonParserTest(CoverageTest):
def parse_source(self, text):
"""Parse `text` as source, and return the `PythonParser` used."""
+ if env.PY2:
+ text = text.decode("ascii")
text = textwrap.dedent(text)
parser = PythonParser(text=text, exclude="nocover")
parser.parse_source()