summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-03-11 15:25:11 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-03-11 15:25:11 -0500
commit1bdcc691f5127edf9f197f8b509a2eeff51edcd6 (patch)
tree60fdc179154ae813e53abc0493b9b01eb9e933ab /tests/conftest.py
parentd2985974a0fba46df7552a9958c7f9ef34f75868 (diff)
downloadpython-coveragepy-git-nedbat/remove-unittest-testcase.tar.gz
test: simplify how StopEverything is converted to skipnedbat/remove-unittest-testcase
The auto-decorating metaclass was interfering with parameterized methods on Python 2.7. But we don't need it anymore anyway, since pytest will let us hook to deal with the exception in a simpler way.
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 81ec9f77..11d7aece 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -14,6 +14,7 @@ import warnings
import pytest
from coverage import env
+from coverage.misc import StopEverything
# Pytest will rewrite assertions in test modules, but not elsewhere.
@@ -92,3 +93,11 @@ def fix_xdist_sys_path():
del os.environ['PYTHONPATH']
except KeyError:
pass
+
+
+@pytest.hookimpl(hookwrapper=True)
+def pytest_runtest_call(item):
+ """Convert StopEverything into skipped tests."""
+ outcome = yield
+ if outcome.excinfo and issubclass(outcome.excinfo[0], StopEverything):
+ pytest.skip("Skipping {} for StopEverything: {}".format(item.nodeid, outcome.excinfo[1]))