summaryrefslogtreecommitdiff
path: root/coverage/misc.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-11-03 12:05:11 -0400
committerNed Batchelder <ned@nedbatchelder.com>2018-11-03 13:03:21 -0400
commitd469f30b3126159a7a6693703203556d124a3dea (patch)
tree84248962c6c630b688514dcf47a0e0dc86648087 /coverage/misc.py
parent649c70527ae602512cfa6ea62b60ebc43fc69797 (diff)
downloadpython-coveragepy-git-d469f30b3126159a7a6693703203556d124a3dea.tar.gz
You can turn off contracts while debugging tests
Diffstat (limited to 'coverage/misc.py')
-rw-r--r--coverage/misc.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/coverage/misc.py b/coverage/misc.py
index 59114863..1782d285 100644
--- a/coverage/misc.py
+++ b/coverage/misc.py
@@ -47,9 +47,13 @@ def dummy_decorator_with_args(*args_unused, **kwargs_unused):
return _decorator
+# Environment COVERAGE_NO_CONTRACTS=1 can turn off contracts while debugging
+# tests to remove noise from stack traces.
+USE_CONTRACTS = env.TESTING and not bool(int(os.environ.get("COVERAGE_NO_CONTRACTS", 0)))
+
# Use PyContracts for assertion testing on parameters and returns, but only if
# we are running our own test suite.
-if env.TESTING:
+if USE_CONTRACTS:
from contracts import contract # pylint: disable=unused-import
from contracts import new_contract as raw_new_contract