summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/cmdline.py4
-rw-r--r--coverage/misc.py18
-rw-r--r--tests/test_summary.py11
3 files changed, 17 insertions, 16 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py
index 9d9d6536..ce929f48 100644
--- a/coverage/cmdline.py
+++ b/coverage/cmdline.py
@@ -13,7 +13,7 @@ import traceback
from coverage import env
from coverage.collector import CTracer
from coverage.execfile import run_python_file, run_python_module
-from coverage.misc import CoverageException, ExceptionDuringRun, NoSource
+from coverage.misc import BaseCoverageException, ExceptionDuringRun, NoSource
from coverage.debug import info_formatter, info_header
@@ -760,7 +760,7 @@ def main(argv=None):
# exception.
traceback.print_exception(*err.args)
status = ERR
- except CoverageException as err:
+ except BaseCoverageException as err:
# A controlled error inside coverage.py: print the message to the user.
print(err)
status = ERR
diff --git a/coverage/misc.py b/coverage/misc.py
index cb9248d2..d3723e29 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -255,8 +255,13 @@ class SimpleRepr(object):
)
-class CoverageException(Exception):
- """An exception specific to coverage.py."""
+class BaseCoverageException(Exception):
+ """The base of all Coverage exceptions."""
+ pass
+
+
+class CoverageException(BaseCoverageException):
+ """A run-of-the-mill exception specific to coverage.py."""
pass
@@ -298,6 +303,11 @@ class StopEverything(getattr(unittest, 'SkipTest', Exception)):
pass
-class IncapablePython(CoverageException, StopEverything):
- """An operation is attempted that this version of Python cannot do."""
+class IncapablePython(BaseCoverageException, StopEverything):
+ """An operation is attempted that this version of Python cannot do.
+
+ This is derived from BaseCoverageException, not CoverageException, so that
+ it won't get caught by 'except CoverageException'.
+
+ """
pass
diff --git a/tests/test_summary.py b/tests/test_summary.py
index b661819f..8eed08fe 100644
--- a/tests/test_summary.py
+++ b/tests/test_summary.py
@@ -13,7 +13,6 @@ import sys
import coverage
from coverage import env
-from coverage.backunittest import unittest
from coverage.backward import StringIO
from coverage.config import CoverageConfig
from coverage.control import Coverage
@@ -778,12 +777,4 @@ class TestSummaryReporterConfiguration(CoverageTest):
opts.from_args(sort='Xyzzy')
msg = "Invalid sorting option: 'Xyzzy'"
with self.assertRaisesRegex(CoverageException, msg):
- try:
- self.get_summary_text(data, opts)
- except unittest.SkipTest:
- # This is weird: it's because StopEverything derives from
- # SkipTest and CoverageException. When we throw StopEverything,
- # it's caught by the assertRaisesRegex, but the message is
- # wrong. By catching SkipTest, and raising SkipTest, we get
- # the behavior we wanted.
- self.skipTest("No, really, skip...") # pragma: only jython
+ self.get_summary_text(data, opts)