summaryrefslogtreecommitdiff
path: root/tests/test_testing.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-01-26 07:36:07 -0500
committerNed Batchelder <ned@nedbatchelder.com>2017-01-26 07:36:07 -0500
commit72fb471371f1d8e2c79d3c7f682628f5d6d1a28d (patch)
treeac228ec3a763ffbd644adaf574eee053054d1f92 /tests/test_testing.py
parent2d124b93708636179f5c611eb698ac68901c5931 (diff)
downloadpython-coveragepy-git-72fb471371f1d8e2c79d3c7f682628f5d6d1a28d.tar.gz
Move the decorator out of the metaclass, so we can test it
Diffstat (limited to 'tests/test_testing.py')
-rw-r--r--tests/test_testing.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/test_testing.py b/tests/test_testing.py
index a7f60b31..9776acb4 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -11,10 +11,11 @@ import sys
import pytest
import coverage
-from coverage.backunittest import TestCase
+from coverage.backunittest import TestCase, unittest
from coverage.files import actual_path
+from coverage.misc import StopEverything
-from tests.coveragetest import CoverageTest
+from tests.coveragetest import CoverageTest, convert_skip_exceptions
from tests.helpers import CheckUniqueFilenames, re_lines, re_line
@@ -203,6 +204,26 @@ def test_re_line_bad(text, pat):
re_line(text, pat)
+def test_convert_skip_exceptions():
+ @convert_skip_exceptions
+ def some_method(ret=None, exc=None):
+ """Be like a test case."""
+ if exc:
+ raise exc("yikes!")
+ return ret
+
+ # Normal flow is normal.
+ assert some_method(ret=[17, 23]) == [17, 23]
+
+ # Exceptions are raised normally.
+ with pytest.raises(ValueError):
+ some_method(exc=ValueError)
+
+ # But a StopEverything becomes a SkipTest.
+ with pytest.raises(unittest.SkipTest):
+ some_method(exc=StopEverything)
+
+
def _same_python_executable(e1, e2):
"""Determine if `e1` and `e2` refer to the same Python executable.