Calm down try,except,pass and try,except,continue

These tests default to the strict setting, this is quite noisy and
normally produces false positives. Probably not a good default, so
this calms down these tests.

Change-Id: Ia22569bdae1705a2a499ad17bbfffdf211e9d2b2
This commit is contained in:
Tim Kelsey 2016-03-31 13:11:44 +01:00
parent 0fabff579d
commit 43a102face
3 changed files with 14 additions and 18 deletions

View File

@ -89,7 +89,7 @@ from bandit.core import test_properties as test
def gen_config(name):
if name == 'try_except_continue':
return {'check_typed_exception': True}
return {'check_typed_exception': False}
@test.takes_config

View File

@ -88,7 +88,7 @@ from bandit.core import test_properties as test
def gen_config(name):
if name == 'try_except_pass':
return {'check_typed_exception': True}
return {'check_typed_exception': False}
@test.takes_config

View File

@ -408,32 +408,28 @@ class FunctionalTests(testtools.TestCase):
def test_try_except_continue(self):
'''Test try, except, continue detection.'''
expect = {'SEVERITY': {'LOW': 3},
'CONFIDENCE': {'HIGH': 3}}
self.check_example('try_except_continue.py', expect)
test = next((x for x in self.b_mgr.b_ts.tests['ExceptHandler']
if x.__name__ == 'try_except_continue'))
test._config = {'check_typed_exception': False}
expect = {'SEVERITY': {'LOW': 2},
'CONFIDENCE': {'HIGH': 2}}
test._config = {'check_typed_exception': True}
expect = {'SEVERITY': {'LOW': 3}, 'CONFIDENCE': {'HIGH': 3}}
self.check_example('try_except_continue.py', expect)
test._config = {'check_typed_exception': False}
expect = {'SEVERITY': {'LOW': 2}, 'CONFIDENCE': {'HIGH': 2}}
self.check_example('try_except_continue.py', expect)
def test_try_except_pass(self):
'''Test try, except pass detection.'''
expect = {'SEVERITY': {'LOW': 3},
'CONFIDENCE': {'HIGH': 3}}
self.check_example('try_except_pass.py', expect)
test = next((x for x in self.b_mgr.b_ts.tests['ExceptHandler']
if x.__name__ == 'try_except_pass'))
test._config = {'check_typed_exception': False}
expect = {'SEVERITY': {'LOW': 2},
'CONFIDENCE': {'HIGH': 2}}
test._config = {'check_typed_exception': True}
expect = {'SEVERITY': {'LOW': 3}, 'CONFIDENCE': {'HIGH': 3}}
self.check_example('try_except_pass.py', expect)
test._config = {'check_typed_exception': False}
expect = {'SEVERITY': {'LOW': 2}, 'CONFIDENCE': {'HIGH': 2}}
self.check_example('try_except_pass.py', expect)
def test_metric_gathering(self):