Fix linting E722: do not use bare except
This commit is contained in:
parent
03829fde8a
commit
b11640c1eb
|
@ -250,7 +250,7 @@ class TracebackEntry(object):
|
|||
line = str(self.statement).lstrip()
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
line = "???"
|
||||
return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
|
||||
|
||||
|
@ -478,12 +478,12 @@ class FormattedExcinfo(object):
|
|||
s = str(source.getstatement(len(source) - 1))
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
try:
|
||||
s = str(source[-1])
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
return 0
|
||||
return 4 + (len(s) - len(s.lstrip()))
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ def findsource(obj):
|
|||
sourcelines, lineno = py.std.inspect.findsource(obj)
|
||||
except py.builtin._sysex:
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
return None, -1
|
||||
source = Source()
|
||||
source.lines = [line.rstrip() for line in sourcelines]
|
||||
|
|
|
@ -210,7 +210,7 @@ class AssertionRewritingHook(object):
|
|||
mod.__cached__ = pyc
|
||||
mod.__loader__ = self
|
||||
py.builtin.exec_(co, mod.__dict__)
|
||||
except:
|
||||
except: # noqa
|
||||
if name in sys.modules:
|
||||
del sys.modules[name]
|
||||
raise
|
||||
|
|
|
@ -749,7 +749,7 @@ class FixtureDef:
|
|||
try:
|
||||
func = self._finalizer.pop()
|
||||
func()
|
||||
except:
|
||||
except: # noqa
|
||||
exceptions.append(sys.exc_info())
|
||||
if exceptions:
|
||||
e = exceptions[0]
|
||||
|
|
|
@ -118,7 +118,7 @@ def wrap_session(config, doit):
|
|||
excinfo.typename, excinfo.value.msg))
|
||||
config.hook.pytest_keyboard_interrupt(excinfo=excinfo)
|
||||
session.exitstatus = EXIT_INTERRUPTED
|
||||
except:
|
||||
except: # noqa
|
||||
excinfo = _pytest._code.ExceptionInfo()
|
||||
config.notify_exception(excinfo, config.option)
|
||||
session.exitstatus = EXIT_INTERNALERROR
|
||||
|
@ -375,7 +375,7 @@ class Node(object):
|
|||
res = function()
|
||||
except py.builtin._sysex:
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
failure = sys.exc_info()
|
||||
setattr(self, exattrname, failure)
|
||||
raise
|
||||
|
|
|
@ -84,7 +84,7 @@ class ApproxNumpy(ApproxBase):
|
|||
|
||||
try:
|
||||
actual = np.asarray(actual)
|
||||
except:
|
||||
except: # noqa
|
||||
raise TypeError("cannot compare '{0}' to numpy.ndarray".format(actual))
|
||||
|
||||
if actual.shape != self.expected.shape:
|
||||
|
|
|
@ -197,7 +197,7 @@ class CallInfo:
|
|||
except KeyboardInterrupt:
|
||||
self.stop = time()
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
self.excinfo = ExceptionInfo()
|
||||
self.stop = time()
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ class TestCaseFunction(Function):
|
|||
fail("".join(values), pytrace=False)
|
||||
except (fail.Exception, KeyboardInterrupt):
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
fail("ERROR: Unknown Incompatible Exception "
|
||||
"representation:\n%r" % (rawexcinfo,), pytrace=False)
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
@ -244,7 +244,7 @@ class TestTraceback_f_g_h(object):
|
|||
def f(n):
|
||||
try:
|
||||
do_stuff()
|
||||
except:
|
||||
except: # noqa
|
||||
reraise_me()
|
||||
|
||||
excinfo = pytest.raises(RuntimeError, f, 8)
|
||||
|
@ -434,7 +434,7 @@ class TestFormattedExcinfo(object):
|
|||
exec(source.compile())
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except:
|
||||
except: # noqa
|
||||
return _pytest._code.ExceptionInfo()
|
||||
assert 0, "did not raise"
|
||||
|
||||
|
@ -1217,7 +1217,7 @@ def test_exception_repr_extraction_error_on_recursion():
|
|||
|
||||
try:
|
||||
a(numpy_like())
|
||||
except:
|
||||
except: # noqa
|
||||
from _pytest._code.code import ExceptionInfo
|
||||
from _pytest.pytester import LineMatcher
|
||||
exc_info = ExceptionInfo()
|
||||
|
@ -1241,7 +1241,7 @@ def test_no_recursion_index_on_recursion_error():
|
|||
return getattr(self, '_' + attr)
|
||||
|
||||
RecursionDepthError().trigger
|
||||
except:
|
||||
except: # noqa
|
||||
from _pytest._code.code import ExceptionInfo
|
||||
exc_info = ExceptionInfo()
|
||||
if sys.version_info[:2] == (2, 6):
|
||||
|
|
Loading…
Reference in New Issue