summaryrefslogtreecommitdiff
path: root/tests/coveragetest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-01-14 10:01:03 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-01-14 10:01:03 -0500
commite5c5b0eda9c000987ecafaa914ff1d0513b342ac (patch)
treedf1bf4876796c426515009d4d42287abcd70c2d8 /tests/coveragetest.py
parentc9aa6917e8ae67640f14dcd302b30d2cbe234fa8 (diff)
downloadpython-coveragepy-git-e5c5b0eda9c000987ecafaa914ff1d0513b342ac.tar.gz
Reporting doesn't work on Jython, so don't run reporting tests there.
--HG-- extra : amend_source : 144fd0ffb49fdef1139ae3f0085831ece14de43f
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r--tests/coveragetest.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 7ec623b3..a98462c4 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -20,6 +20,7 @@ from unittest_mixins import (
)
import coverage
+from coverage import env
from coverage.backunittest import TestCase
from coverage.backward import StringIO, import_local_file, string_class, shlex_quote
from coverage.backward import invalidate_import_caches
@@ -377,7 +378,7 @@ class CoverageTest(
"""
# Make sure "python" and "coverage" mean specifically what we want
# them to mean.
- split_commandline = cmd.split(" ", 1)
+ split_commandline = cmd.split()
command_name = split_commandline[0]
command_args = split_commandline[1:]
@@ -387,14 +388,26 @@ class CoverageTest(
# get executed as "python3.3 foo.py". This is important because
# Python 3.x doesn't install as "python", so you might get a Python
# 2 executable instead if you don't use the executable's basename.
- command_name = os.path.basename(sys.executable)
+ command_words = [os.path.basename(sys.executable)]
+
+ elif command_name == "coverage":
+ if env.JYTHON:
+ # Jython can't do reporting, so let's skip the test now.
+ if command_args and command_args[0] in ('report', 'html', 'xml', 'annotate'):
+ self.skipTest("Can't run reporting commands in Jython")
+ # Jython can't run "coverage" as a command because the shebang
+ # refers to another shebang'd Python script. So run them as
+ # modules.
+ command_words = "jython -m coverage".split()
+ else:
+ # The invocation requests the Coverage.py program. Substitute the
+ # actual Coverage.py main command name.
+ command_words = [self.coverage_command]
- if command_name == "coverage":
- # The invocation requests the Coverage.py program. Substitute the
- # actual Coverage.py main command name.
- command_name = self.coverage_command
+ else:
+ command_words = [command_name]
- cmd = " ".join([shlex_quote(command_name)] + command_args)
+ cmd = " ".join([shlex_quote(w) for w in command_words] + command_args)
# Add our test modules directory to PYTHONPATH. I'm sure there's too
# much path munging here, but...