Catch specific exception rather than anything

The bare "except" also catches exceptions like "NameError" and
"SystemExit", which we really should not catch.  In scour.py, use the
most specific exception (NotFoundErr) and in the tests just catch any
"regular" exception.

Reported by flake8.

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-02-17 09:15:45 +00:00 committed by Eduard Braun
parent f3d8936b5e
commit 843706be39
2 changed files with 6 additions and 6 deletions

View file

@ -66,7 +66,7 @@ class EmptyOptions(unittest.TestCase):
try:
scourString(self.MINIMAL_SVG, options)
fail = False
except:
except Exception:
fail = True
self.assertEqual(fail, False,
'Exception when calling "scourString" with empty options object')
@ -76,7 +76,7 @@ class EmptyOptions(unittest.TestCase):
try:
scourXmlFile('unittests/minimal.svg', options)
fail = False
except:
except Exception:
fail = True
self.assertEqual(fail, False,
'Exception when calling "scourXmlFile" with empty options object')
@ -91,7 +91,7 @@ class EmptyOptions(unittest.TestCase):
try:
start(options, input, output)
fail = False
except:
except Exception:
fail = True
sys.stdout = stdout_temp
@ -109,7 +109,7 @@ class InvalidOptions(unittest.TestCase):
try:
scourXmlFile('unittests/ids-to-strip.svg', options)
fail = False
except:
except Exception:
fail = True
self.assertEqual(fail, False,
'Exception when calling Scour with invalid options')