summaryrefslogtreecommitdiff
path: root/tests/test_oddball.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-01-01 12:41:15 -0500
committerNed Batchelder <ned@nedbatchelder.com>2020-01-01 13:15:42 -0500
commit016af5f6352d69206ac8f7537c2b18828767bcae (patch)
tree0b93d1381754486e769e480835ee7bf011c4720f /tests/test_oddball.py
parent5bb5da50b182583036b7808bb32f2c8c191d9d26 (diff)
downloadpython-coveragepy-git-016af5f6352d69206ac8f7537c2b18828767bcae.tar.gz
Don't trace non-encodable file names. #891
Diffstat (limited to 'tests/test_oddball.py')
-rw-r--r--tests/test_oddball.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_oddball.py b/tests/test_oddball.py
index 3574806c..90b92249 100644
--- a/tests/test_oddball.py
+++ b/tests/test_oddball.py
@@ -3,6 +3,7 @@
"""Oddball cases for testing coverage.py"""
+import os.path
import sys
from flaky import flaky
@@ -562,6 +563,18 @@ class ExecTest(CoverageTest):
self.assertEqual(statements, [31])
self.assertEqual(missing, [])
+ def test_unencodable_filename(self):
+ # https://github.com/nedbat/coveragepy/issues/891
+ if env.PYVERSION < (3, 0):
+ self.skipTest("Python 2 can't seem to compile the file.")
+ self.make_file("bug891.py", r"""exec(compile("pass", "\udcff.py", "exec"))""")
+ cov = coverage.Coverage()
+ self.start_import_stop(cov, "bug891")
+ # Saving would fail trying to encode \udcff.py
+ cov.save()
+ files = [os.path.basename(f) for f in cov.get_data().measured_files()]
+ assert "bug891.py" in files
+
class MockingProtectionTest(CoverageTest):
"""Tests about protecting ourselves from aggressive mocking.