Skip to content

Commit

Permalink
100% coverage through standardizing the no cover pragma directives an…
Browse files Browse the repository at this point in the history
…d adding two.
  • Loading branch information
jamadden committed Apr 24, 2017
1 parent 04cbcc4 commit e5169b9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ parts
docs/_build
.tox
.coverage
htmlcov
nosetests.xml
coverage.xml
2 changes: 1 addition & 1 deletion src/zope/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__('pkg_resources').declare_namespace(__name__) # pragma: no cover
4 changes: 2 additions & 2 deletions src/zope/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
# avoid dependency on zope.security:
try:
import zope.security
except ImportError as v: #pragma NO COVER
except ImportError as v: #pragma: no cover
# "ImportError: No module named security"
if 'security' not in str(v):
raise
else: #pragma NO COVER
else: #pragma: no cover
from zope.security.interfaces import IUnauthorized
from zope.security.interfaces import Unauthorized
from zope.security.interfaces import IForbidden
Expand Down
8 changes: 4 additions & 4 deletions src/zope/exceptions/exceptionformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def formatSupplement(self, supplement, tb):
extra = getInfo()
if extra:
result.append(self.formatSupplementInfo(extra))
except: #pragma NO COVER
except: #pragma: no cover
if DEBUG_EXCEPTION_FORMATTER:
traceback.print_exc()
# else just swallow the exception.
Expand Down Expand Up @@ -145,7 +145,7 @@ def formatLine(self, tb=None, f=None):
try:
supp = factory(*args)
result.extend(self.formatSupplement(supp, tb))
except: #pragma NO COVER
except: #pragma: no cover
if DEBUG_EXCEPTION_FORMATTER:
traceback.print_exc()
# else just swallow the exception.
Expand All @@ -154,7 +154,7 @@ def formatLine(self, tb=None, f=None):
tbi = locals.get('__traceback_info__', None)
if tbi is not None:
result.append(self.formatTracebackInfo(tbi))
except: #pragma NO COVER
except: #pragma: no cover
if DEBUG_EXCEPTION_FORMATTER:
traceback.print_exc()
# else just swallow the exception.
Expand Down Expand Up @@ -291,7 +291,7 @@ def print_exception(t, v, tb, limit=None, file=None, as_html=False,
information to the traceback and accepts two options, 'as_html'
and 'with_filenames'.
"""
if file is None: #pragma NO COVER
if file is None: #pragma: no cover
file = sys.stderr
lines = format_exception(t, v, tb, limit, as_html, with_filenames)
for line in lines:
Expand Down
2 changes: 1 addition & 1 deletion src/zope/exceptions/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import logging
try:
from StringIO import StringIO
except ImportError: #pragma NO COVER Python3
except ImportError: #pragma: no cover Python3
from io import StringIO

from zope.exceptions.exceptionformatter import print_exception
Expand Down
2 changes: 1 addition & 1 deletion src/zope/exceptions/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#
#
6 changes: 3 additions & 3 deletions src/zope/exceptions/tests/test_exceptionformatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ class _Monkey(object):
# context-manager for replacing module names in the scope of a test.
def __init__(self, module, **kw):
self.module = module
self.to_restore = dict([(key, getattr(module, key, self))
for key in kw])
self.to_restore = {key: getattr(module, key, self)
for key in kw}
for key, value in kw.items():
setattr(module, key, value)

Expand All @@ -854,7 +854,7 @@ def __enter__(self):

def __exit__(self, exc_type, exc_val, exc_tb):
for key, value in self.to_restore.items():
if value is not self:
if value is not self: # pragma: no cover
setattr(self.module, key, value)
else:
delattr(self.module, key)
Expand Down

0 comments on commit e5169b9

Please sign in to comment.