summaryrefslogtreecommitdiff
path: root/coverage/env.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2021-11-04 07:20:50 -0400
committerNed Batchelder <ned@nedbatchelder.com>2021-11-04 07:20:50 -0400
commitc7c32846ea2af9863fa921c5f5735ff3958b775f (patch)
treed455d8e4da0e4101bfffff1d1d6f62f2a61cad85 /coverage/env.py
parent8aa27024bdeb8950d61455b37a18bd508bf37904 (diff)
downloadpython-coveragepy-git-c7c32846ea2af9863fa921c5f5735ff3958b775f.tar.gz
refactor(test): don't even import contracts if not using PyContracts
On CPython 3.11, PyContracts fails on import, so we need to shut it off more completely. PyContracts is unmaintained these days, so we'll probably get rid of it completely soon.
Diffstat (limited to 'coverage/env.py')
-rw-r--r--coverage/env.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/coverage/env.py b/coverage/env.py
index 68da83dd..a01bb816 100644
--- a/coverage/env.py
+++ b/coverage/env.py
@@ -124,3 +124,8 @@ METACOV = os.getenv('COVERAGE_COVERAGE', '') != ''
# Even when running tests, you can use COVERAGE_TESTING=0 to disable the
# 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)))