Merge "Fixed order of arguments in assertEqual"

This commit is contained in:
Jenkins 2017-07-14 16:34:11 +00:00 committed by Gerrit Code Review
commit 84a2eb97bb
2 changed files with 43 additions and 43 deletions

View File

@ -51,9 +51,9 @@ class ManagerTests(testtools.TestCase):
def test_create_manager(self):
# make sure we can create a manager
self.assertEqual(self.manager.debug, False)
self.assertEqual(self.manager.verbose, False)
self.assertEqual(self.manager.agg_type, 'file')
self.assertEqual(False, self.manager.debug)
self.assertEqual(False, self.manager.verbose)
self.assertEqual('file', self.manager.agg_type)
def test_create_manager_with_profile(self):
# make sure we can create a manager
@ -61,9 +61,9 @@ class ManagerTests(testtools.TestCase):
debug=False, verbose=False,
profile=self.profile)
self.assertEqual(m.debug, False)
self.assertEqual(m.verbose, False)
self.assertEqual(m.agg_type, 'file')
self.assertEqual(False, m.debug)
self.assertEqual(False, m.verbose)
self.assertEqual('file', m.agg_type)
def test_matches_globlist(self):
self.assertTrue(manager._matches_glob_list('test', ['*tes*']))
@ -101,8 +101,8 @@ class ManagerTests(testtools.TestCase):
included_globs=['*.py'],
excluded_path_strings=None)
self.assertEqual(exc, set(['/a/c.ww']))
self.assertEqual(inc, set(['/a/a.py', '/a/b.py']))
self.assertEqual(set(['/a/c.ww']), exc)
self.assertEqual(set(['/a/a.py', '/a/b.py']), inc)
def test_populate_baseline_success(self):
# Test populate_baseline with valid JSON
@ -183,8 +183,8 @@ class ManagerTests(testtools.TestCase):
def test_discover_files_recurse_skip(self, isdir):
isdir.return_value = True
self.manager.discover_files(['thing'], False)
self.assertEqual(self.manager.files_list, [])
self.assertEqual(self.manager.excluded_files, [])
self.assertEqual([], self.manager.files_list)
self.assertEqual([], self.manager.excluded_files)
@mock.patch('os.path.isdir')
def test_discover_files_recurse_files(self, isdir):
@ -192,8 +192,8 @@ class ManagerTests(testtools.TestCase):
with mock.patch.object(manager, '_get_files_from_dir') as m:
m.return_value = (set(['files']), set(['excluded']))
self.manager.discover_files(['thing'], True)
self.assertEqual(self.manager.files_list, ['files'])
self.assertEqual(self.manager.excluded_files, ['excluded'])
self.assertEqual(['files'], self.manager.files_list)
self.assertEqual(['excluded'], self.manager.excluded_files)
@mock.patch('os.path.isdir')
def test_discover_files_exclude(self, isdir):
@ -201,8 +201,8 @@ class ManagerTests(testtools.TestCase):
with mock.patch.object(manager, '_is_file_included') as m:
m.return_value = False
self.manager.discover_files(['thing'], True)
self.assertEqual(self.manager.files_list, [])
self.assertEqual(self.manager.excluded_files, ['thing'])
self.assertEqual([], self.manager.files_list)
self.assertEqual(['thing'], self.manager.excluded_files)
@mock.patch('os.path.isdir')
def test_discover_files_exclude_cmdline(self, isdir):
@ -219,8 +219,8 @@ class ManagerTests(testtools.TestCase):
with mock.patch.object(manager, '_is_file_included') as m:
m.return_value = True
self.manager.discover_files(['thing'], True)
self.assertEqual(self.manager.files_list, ['thing'])
self.assertEqual(self.manager.excluded_files, [])
self.assertEqual(['thing'], self.manager.files_list)
self.assertEqual([], self.manager.excluded_files)
def test_run_tests_keyboardinterrupt(self):
# Test that bandit manager exits when there is a keyboard interrupt

View File

@ -66,73 +66,73 @@ class BanditTestSetTests(testtools.TestCase):
def test_has_defaults(self):
ts = test_set.BanditTestSet(self.config)
self.assertEqual(len(ts.get_tests('Str')), 1)
self.assertEqual(1, len(ts.get_tests('Str')))
def test_profile_include_id(self):
profile = {'include': ['B000']}
ts = test_set.BanditTestSet(self.config, profile)
self.assertEqual(len(ts.get_tests('Str')), 1)
self.assertEqual(1, len(ts.get_tests('Str')))
def test_profile_exclude_id(self):
profile = {'exclude': ['B000']}
ts = test_set.BanditTestSet(self.config, profile)
self.assertEqual(len(ts.get_tests('Str')), 0)
self.assertEqual(0, len(ts.get_tests('Str')))
def test_profile_include_none(self):
profile = {'include': []} # same as no include
ts = test_set.BanditTestSet(self.config, profile)
self.assertEqual(len(ts.get_tests('Str')), 1)
self.assertEqual(1, len(ts.get_tests('Str')))
def test_profile_exclude_none(self):
profile = {'exclude': []} # same as no exclude
ts = test_set.BanditTestSet(self.config, profile)
self.assertEqual(len(ts.get_tests('Str')), 1)
self.assertEqual(1, len(ts.get_tests('Str')))
def test_profile_has_builtin_blacklist(self):
ts = test_set.BanditTestSet(self.config)
self.assertEqual(len(ts.get_tests('Import')), 1)
self.assertEqual(len(ts.get_tests('ImportFrom')), 1)
self.assertEqual(len(ts.get_tests('Call')), 1)
self.assertEqual(1, len(ts.get_tests('Import')))
self.assertEqual(1, len(ts.get_tests('ImportFrom')))
self.assertEqual(1, len(ts.get_tests('Call')))
def test_profile_exclude_builtin_blacklist(self):
profile = {'exclude': ['B001']}
ts = test_set.BanditTestSet(self.config, profile)
self.assertEqual(len(ts.get_tests('Import')), 0)
self.assertEqual(len(ts.get_tests('ImportFrom')), 0)
self.assertEqual(len(ts.get_tests('Call')), 0)
self.assertEqual(0, len(ts.get_tests('Import')))
self.assertEqual(0, len(ts.get_tests('ImportFrom')))
self.assertEqual(0, len(ts.get_tests('Call')))
def test_profile_exclude_builtin_blacklist_specific(self):
profile = {'exclude': ['B302', 'B401']}
ts = test_set.BanditTestSet(self.config, profile)
self.assertEqual(len(ts.get_tests('Import')), 0)
self.assertEqual(len(ts.get_tests('ImportFrom')), 0)
self.assertEqual(len(ts.get_tests('Call')), 0)
self.assertEqual(0, len(ts.get_tests('Import')))
self.assertEqual(0, len(ts.get_tests('ImportFrom')))
self.assertEqual(0, len(ts.get_tests('Call')))
def test_profile_filter_blacklist_none(self):
ts = test_set.BanditTestSet(self.config)
blacklist = ts.get_tests('Import')[0]
self.assertEqual(len(blacklist._config['Import']), 2)
self.assertEqual(len(blacklist._config['ImportFrom']), 2)
self.assertEqual(len(blacklist._config['Call']), 2)
self.assertEqual(2, len(blacklist._config['Import']))
self.assertEqual(2, len(blacklist._config['ImportFrom']))
self.assertEqual(2, len(blacklist._config['Call']))
def test_profile_filter_blacklist_one(self):
profile = {'exclude': ['B401']}
ts = test_set.BanditTestSet(self.config, profile)
blacklist = ts.get_tests('Import')[0]
self.assertEqual(len(blacklist._config['Import']), 1)
self.assertEqual(len(blacklist._config['ImportFrom']), 1)
self.assertEqual(len(blacklist._config['Call']), 1)
self.assertEqual(1, len(blacklist._config['Import']))
self.assertEqual(1, len(blacklist._config['ImportFrom']))
self.assertEqual(1, len(blacklist._config['Call']))
def test_profile_filter_blacklist_include(self):
profile = {'include': ['B001', 'B401']}
ts = test_set.BanditTestSet(self.config, profile)
blacklist = ts.get_tests('Import')[0]
self.assertEqual(len(blacklist._config['Import']), 1)
self.assertEqual(len(blacklist._config['ImportFrom']), 1)
self.assertEqual(len(blacklist._config['Call']), 1)
self.assertEqual(1, len(blacklist._config['Import']))
self.assertEqual(1, len(blacklist._config['ImportFrom']))
self.assertEqual(1, len(blacklist._config['Call']))
def test_profile_filter_blacklist_all(self):
profile = {'exclude': ['B401', 'B302']}
@ -140,9 +140,9 @@ class BanditTestSetTests(testtools.TestCase):
# if there is no blacklist data for a node type then we wont add a
# blacklist test to it, as this would be pointless.
self.assertEqual(len(ts.get_tests('Import')), 0)
self.assertEqual(len(ts.get_tests('ImportFrom')), 0)
self.assertEqual(len(ts.get_tests('Call')), 0)
self.assertEqual(0, len(ts.get_tests('Import')))
self.assertEqual(0, len(ts.get_tests('ImportFrom')))
self.assertEqual(0, len(ts.get_tests('Call')))
def test_profile_blacklist_compat(self):
data = [utils.build_conf_dict(
@ -157,4 +157,4 @@ class BanditTestSetTests(testtools.TestCase):
self.assertNotIn('Import', blacklist._config)
self.assertNotIn('ImportFrom', blacklist._config)
self.assertEqual(len(blacklist._config['Call']), 1)
self.assertEqual(1, len(blacklist._config['Call']))