summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/env.py9
-rw-r--r--coverage/inorout.py9
-rw-r--r--coverage/misc.py46
-rw-r--r--requirements/pytest.in4
4 files changed, 9 insertions, 59 deletions
diff --git a/coverage/env.py b/coverage/env.py
index 820016f4..f77f22ee 100644
--- a/coverage/env.py
+++ b/coverage/env.py
@@ -130,14 +130,7 @@ METACOV = os.getenv('COVERAGE_COVERAGE', '') != ''
# test-specific behavior like contracts.
TESTING = os.getenv('COVERAGE_TESTING', '') == 'True'
-# Environment COVERAGE_NO_CONTRACTS=1 can turn off contracts while debugging
-# tests to remove noise from stack traces.
-# $set_env.py: COVERAGE_NO_CONTRACTS - Disable PyContracts to simplify stack traces.
-USE_CONTRACTS = (
- TESTING
- and not bool(int(os.environ.get("COVERAGE_NO_CONTRACTS", 0)))
- and (PYVERSION < (3, 11))
-)
+USE_CONTRACTS = False
def debug_info():
"""Return a list of (name, value) pairs for printing debug information."""
diff --git a/coverage/inorout.py b/coverage/inorout.py
index d69837f9..fcb45974 100644
--- a/coverage/inorout.py
+++ b/coverage/inorout.py
@@ -176,15 +176,6 @@ def add_coverage_paths(paths):
# Don't include our own test code.
paths.add(os.path.join(cover_path, "tests"))
- # When testing, we use PyContracts, which should be considered
- # part of coverage.py, and it uses six. Exclude those directories
- # just as we exclude ourselves.
- if env.USE_CONTRACTS:
- import contracts
- import six
- for mod in [contracts, six]:
- paths.add(canonical_path(mod))
-
class InOrOut:
"""Machinery for determining what files to measure."""
diff --git a/coverage/misc.py b/coverage/misc.py
index 212790a1..34b743dc 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -98,44 +98,14 @@ def dummy_decorator_with_args(*args_unused, **kwargs_unused):
return _decorator
-# Use PyContracts for assertion testing on parameters and returns, but only if
-# we are running our own test suite.
-if env.USE_CONTRACTS:
- from contracts import contract # pylint: disable=unused-import
- from contracts import new_contract as raw_new_contract
-
- def new_contract(*args, **kwargs):
- """A proxy for contracts.new_contract that doesn't mind happening twice."""
- try:
- raw_new_contract(*args, **kwargs)
- except ValueError:
- # During meta-coverage, this module is imported twice, and
- # PyContracts doesn't like redefining contracts. It's OK.
- pass
-
- # Define contract words that PyContract doesn't have.
- new_contract('bytes', lambda v: isinstance(v, bytes))
- new_contract('unicode', lambda v: isinstance(v, str))
-
- def one_of(argnames):
- """Ensure that only one of the argnames is non-None."""
- def _decorator(func):
- argnameset = {name.strip() for name in argnames.split(",")}
- def _wrapper(*args, **kwargs):
- vals = [kwargs.get(name) for name in argnameset]
- assert sum(val is not None for val in vals) == 1
- return func(*args, **kwargs)
- return _wrapper
- return _decorator
-else: # pragma: not testing
- # We aren't using real PyContracts, so just define our decorators as
- # stunt-double no-ops.
- contract = dummy_decorator_with_args
- one_of = dummy_decorator_with_args
-
- def new_contract(*args_unused, **kwargs_unused):
- """Dummy no-op implementation of `new_contract`."""
- pass
+# We aren't using real PyContracts, so just define our decorators as
+# stunt-double no-ops.
+contract = dummy_decorator_with_args
+one_of = dummy_decorator_with_args
+
+def new_contract(*args_unused, **kwargs_unused):
+ """Dummy no-op implementation of `new_contract`."""
+ pass
def nice_pair(pair):
diff --git a/requirements/pytest.in b/requirements/pytest.in
index 855ac3e1..2b23477b 100644
--- a/requirements/pytest.in
+++ b/requirements/pytest.in
@@ -10,10 +10,6 @@ flaky
hypothesis
pytest
pytest-xdist
-# Use a fork of PyContracts that supports Python 3.9
-#PyContracts==1.8.12
-# git+https://github.com/slorg1/contracts@collections_and_validator
-https://github.com/slorg1/contracts/archive/c5a6da27d4dc9985f68e574d20d86000880919c3.zip
# Pytest has a windows-only dependency on colorama:
# https://github.com/pytest-dev/pytest/blob/main/setup.cfg#L49