diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-02-02 10:53:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 10:53:27 -0500 |
commit | b7160a896252bb92ffe921a37e3cde98c5cb78b9 (patch) | |
tree | a0edae6ca0996217b9f0fa3213f824eab8b1cbe1 /tests/coveragetest.py | |
parent | 35d91c7aa186a84d0edb333bad60b520f3b1d719 (diff) | |
parent | 80c021d9174e7ae3e5183f1902903fb90a891246 (diff) | |
download | python-coveragepy-git-b7160a896252bb92ffe921a37e3cde98c5cb78b9.tar.gz |
Merge pull request #1113 from nedbat/nedbat/capsys
More unittest removal
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r-- | tests/coveragetest.py | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index c4a46da9..71f4e2c8 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -6,7 +6,6 @@ import contextlib import datetime import difflib -import functools import glob import os import os.path @@ -14,20 +13,19 @@ import random import re import shlex import sys -import types import pytest -from unittest_mixins import EnvironmentAwareMixin, StdStreamCapturingMixin, TempDirMixin +from unittest_mixins import EnvironmentAwareMixin, TempDirMixin import coverage from coverage import env -from coverage.backunittest import TestCase, unittest +from coverage.backunittest import TestCase from coverage.backward import StringIO, import_local_file, string_class, shlex_quote from coverage.cmdline import CoverageScript -from coverage.misc import StopEverything from tests.helpers import arcs_to_arcz_repr, arcz_to_arcs from tests.helpers import run_command, SuperModuleCleaner +from tests.mixins import StdStreamCapturingMixin, StopEverythingMixin # Status returns for the command line. @@ -37,35 +35,11 @@ OK, ERR = 0, 1 TESTS_DIR = os.path.dirname(__file__) -def convert_skip_exceptions(method): - """A decorator for test methods to convert StopEverything to SkipTest.""" - @functools.wraps(method) - def _wrapper(*args, **kwargs): - try: - result = method(*args, **kwargs) - except StopEverything: - raise unittest.SkipTest("StopEverything!") - return result - return _wrapper - - -class SkipConvertingMetaclass(type): - """Decorate all test methods to convert StopEverything to SkipTest.""" - def __new__(cls, name, bases, attrs): - for attr_name, attr_value in attrs.items(): - if attr_name.startswith('test_') and isinstance(attr_value, types.FunctionType): - attrs[attr_name] = convert_skip_exceptions(attr_value) - - return super(SkipConvertingMetaclass, cls).__new__(cls, name, bases, attrs) - - -CoverageTestMethodsMixin = SkipConvertingMetaclass('CoverageTestMethodsMixin', (), {}) - class CoverageTest( EnvironmentAwareMixin, StdStreamCapturingMixin, TempDirMixin, - CoverageTestMethodsMixin, + StopEverythingMixin, TestCase, ): """A base class for coverage.py test cases.""" |