diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-05-23 07:29:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-05-23 07:29:51 -0400 |
commit | 3d8f486b2974772a7524b64fcba68bea4a2929fb (patch) | |
tree | 06f27cfa64ec89b97a8c2131e2cdf65c445d0e21 /coverage/misc.py | |
parent | fdfdb2432dcf9e544e7c6a70421e74e5c56adf45 (diff) | |
download | python-coveragepy-git-3d8f486b2974772a7524b64fcba68bea4a2929fb.tar.gz |
PyContracts is conditional, but not optional
Diffstat (limited to 'coverage/misc.py')
-rw-r--r-- | coverage/misc.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/coverage/misc.py b/coverage/misc.py index 64111358..6131ec2a 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -14,19 +14,15 @@ from coverage.backward import string_class, to_bytes, unicode_class contract = None if env.TESTING: - try: - from contracts import contract - except ImportError: - pass - else: - from contracts import new_contract + from contracts import contract + 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)) + # 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)) -if not contract: +else: # We aren't using real PyContracts, so just define a no-op decorator as a # stunt double. def contract(**unused): # pylint: disable=function-redefined |