diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-23 07:35:28 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-23 07:35:28 -0400 |
commit | ddb83b43a2794b47b60ab5956297df0cc45d22a5 (patch) | |
tree | 183ecc34cd985d7ed6107d0a02034b623ade59b2 /coverage/misc.py | |
parent | 73dbce509755c4c379183df6f6c36fb12bec862e (diff) | |
download | python-coveragepy-ddb83b43a2794b47b60ab5956297df0cc45d22a5.tar.gz |
Make sure env.TESTING is true during meta-coverage.
Diffstat (limited to 'coverage/misc.py')
-rw-r--r-- | coverage/misc.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/coverage/misc.py b/coverage/misc.py index b99fbb8..6b7321d 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -15,12 +15,16 @@ if env.TESTING: from contracts import contract # pylint: disable=unused-import from contracts import new_contract - # Define contract words that PyContract doesn't have. - new_contract('bytes', lambda v: isinstance(v, bytes)) - if env.PY3: - new_contract('unicode', lambda v: isinstance(v, unicode_class)) - -else: + try: + # Define contract words that PyContract doesn't have. + new_contract('bytes', lambda v: isinstance(v, bytes)) + if env.PY3: + new_contract('unicode', lambda v: isinstance(v, unicode_class)) + except ValueError: + # During meta-coverage, this module is imported twice, and PyContracts + # doesn't like redefining contracts. It's OK. + pass +else: # pragma: not covered # We aren't using real PyContracts, so just define a no-op decorator as a # stunt double. def contract(**unused): |