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 | 012b122d94ebe235d1056340bd48eb28c57a859d (patch) | |
tree | a5f6a0ae59c2a3837315c6d609f4e3f52b2a9407 /coverage/misc.py | |
parent | 2e311cb75673a1b1f646bc5fd9390c0d34671652 (diff) | |
download | python-coveragepy-012b122d94ebe235d1056340bd48eb28c57a859d.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 6411135..6131ec2 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 |