Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

tests: resolve flake8 violations

Brendan Coles75010cd4581d
diff --git a/test/unit/test_spiderfoot.py b/test/unit/test_spiderfoot.py
index 8f8c444a..5c3691f3 100644
--- a/test/unit/test_spiderfoot.py
+++ b/test/unit/test_spiderfoot.py
@@ -45,7 +45,7 @@ class TestSpiderFoot(unittest.TestCase):
invalid_types = [None, "", list(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFoot(invalid_type)
def test_init_argument_options_with_empty_dict(self):
@@ -166,7 +166,7 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(self.default_options)
- with self.assertRaises(BaseException) as cm:
+ with self.assertRaises(BaseException):
sf._dblog(None, None, None)
def test_error(self):
@@ -178,7 +178,7 @@ class TestSpiderFoot(unittest.TestCase):
sf.error(None, exception=False)
self.assertEqual('TBD', 'TBD')
- with self.assertRaises(BaseException) as cm:
+ with self.assertRaises(BaseException):
sf.error(None, exception=True)
def test_fatal_should_exit(self):
@@ -278,7 +278,7 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(dict())
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sf.configSerialize(None, None)
def test_config_serialize_should_return_a_dict(self):
@@ -296,7 +296,7 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(dict())
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sf.configUnserialize(None, dict(), None)
def test_config_unserialize_invalid_reference_point_should_raise(self):
@@ -305,7 +305,7 @@ class TestSpiderFoot(unittest.TestCase):
"""
sf = SpiderFoot(dict())
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sf.configUnserialize(dict(), None, None)
def test_config_unserialize_should_return_a_dict(self):
@@ -1133,7 +1133,7 @@ class TestSpiderFoot(unittest.TestCase):
invalid_types = [None, "", list()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sf.sslDerToPem(invalid_type)
def test_parse_cert_should_return_a_dict(self):
diff --git a/test/unit/test_spiderfootdb.py b/test/unit/test_spiderfootdb.py
index e3cbc989..358c7691 100644
--- a/test/unit/test_spiderfootdb.py
+++ b/test/unit/test_spiderfootdb.py
@@ -42,21 +42,21 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", list(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootDb(invalid_type)
def test_init_argument_opts_with_empty_value_should_raise_ValueError(self):
"""
Test __init__(self, opts, init=False)
"""
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootDb(dict())
def test_init_argument_opts_with_empty_key___database_value_should_raise_ValueError(self):
"""
Test __init__(self, opts, init=False)
"""
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
opts = dict()
opts['__database'] = None
SpiderFootDb(opts)
@@ -110,7 +110,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", list(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.search(invalid_type, False)
def test_search_argument_criteria_key_of_invalid_type_should_raise_TypeError(self):
@@ -125,7 +125,7 @@ class TestSpiderFootDb(unittest.TestCase):
'regex': []
}
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.search(criteria, False)
def test_search_argument_criteria_no_valid_criteria_should_raise_ValueError(self):
@@ -138,7 +138,7 @@ class TestSpiderFootDb(unittest.TestCase):
'invalid_criteria': "example invalid criteria"
}
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.search(criteria, False)
def test_search_argument_criteria_one_criteria_should_raise_ValueError(self):
@@ -151,7 +151,7 @@ class TestSpiderFootDb(unittest.TestCase):
'type': "example type"
}
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.search(criteria, False)
def test_eventTypes_should_return_a_list(self):
@@ -180,7 +180,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanLogEvent(invalid_type, "", "")
def test_scanLogEvent_argument_classification_of_invalid_type_should_raise_TypeError(self):
@@ -193,7 +193,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanLogEvent(instance_id, invalid_type, "")
def test_scanLogEvent_argument_message_of_invalid_type_should_raise_TypeError(self):
@@ -206,7 +206,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanLogEvent(instance_id, "", invalid_type)
@unittest.skip("todo")
@@ -241,7 +241,7 @@ class TestSpiderFootDb(unittest.TestCase):
scan_name = "example scan name"
scan_target = "example scan target"
- with self.assertRaises(IOError) as cm:
+ with self.assertRaises(IOError):
sfdb.scanInstanceCreate(instance_id, scan_name, scan_target)
self.assertEqual('TBD', 'TBD')
@@ -257,7 +257,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanInstanceCreate(invalid_type, scan_name, scan_target)
def test_scanInstanceCreate_argument_scanName_of_invalid_type_should_raise_TypeError(self):
@@ -271,7 +271,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanInstanceCreate(instance_id, invalid_type, scan_target)
def test_scanInstanceCreate_argument_scanTarget_of_invalid_type_should_raise_TypeError(self):
@@ -285,7 +285,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanInstanceCreate(instance_id, scan_name, invalid_type)
def test_scanInstanceSet(self):
@@ -311,7 +311,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanInstanceSet(invalid_type, started, ended, status)
def test_scanInstanceGet_should_return_scan_info(self):
@@ -354,7 +354,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanInstanceGet(invalid_type)
def test_scanResultSummary_should_return_a_list(self):
@@ -376,7 +376,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultSummary(invalid_type)
def test_scanResultSummary_argument_by_of_invalid_type_should_raise_TypeError(self):
@@ -389,10 +389,10 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultSummary(instance_id, invalid_type)
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.scanResultSummary(instance_id, "invalid filter type")
def test_scanResultSummary_argument_by_invalid_value_should_raise_ValueError(self):
@@ -402,7 +402,7 @@ class TestSpiderFootDb(unittest.TestCase):
sfdb = SpiderFootDb(self.default_options, False)
instance_id = "example instance id"
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.scanResultSummary(instance_id, "invalid filter type")
def test_scanResultEvent_should_return_a_list(self):
@@ -427,7 +427,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultEvent(invalid_type, event_type, filter_fp)
def test_scanResultEvent_argument_eventType_of_invalid_type_should_raise_TypeError(self):
@@ -440,7 +440,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultEvent(instance_id, invalid_type, None)
def test_scanResultEventUnique_should_return_a_list(self):
@@ -465,7 +465,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultEventUnique(invalid_type, event_type, filter_fp)
def test_scanResultEventUnique_argument_eventType_of_invalid_type_should_raise_TypeError(self):
@@ -478,7 +478,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultEventUnique(instance_id, invalid_type, None)
def test_scanLogs_should_return_a_list(self):
@@ -506,7 +506,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanLogs(invalid_type, limit, from_row_id, reverse)
def test_scanErrors_should_return_a_list(self):
@@ -528,7 +528,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanErrors(invalid_type, limit)
def test_scanInstanceDelete(self):
@@ -550,7 +550,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanInstanceDelete(invalid_type)
@unittest.skip("todo")
@@ -583,7 +583,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultsUpdateFP(invalid_type, result_hashes, fp_flag)
def test_scanResultsUpdateFP_argument_resultHashes_of_invalid_type_should_raise_TypeError(self):
@@ -597,7 +597,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultsUpdateFP(instance_id, invalid_type, fp_flag)
def test_configSet_should_set_config_opts(self):
@@ -624,7 +624,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", list()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.configSet(invalid_type)
def test_configGet_should_return_a_dict(self):
@@ -665,7 +665,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, ""]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanConfigSet(instance_id, invalid_type)
def test_scanConfigSet_argument_instanceId_with_empty_value_should_raise_ValueError(self):
@@ -674,7 +674,7 @@ class TestSpiderFootDb(unittest.TestCase):
"""
sfdb = SpiderFootDb(self.default_options, False)
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.scanConfigSet("", dict())
def test_scanConfigGet_should_return_a_dict(self):
@@ -696,7 +696,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanConfigGet(invalid_type)
def test_scanEventStore_should_store_a_scan_event(self):
@@ -723,7 +723,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanEventStore(invalid_type, event)
def test_scanEventStore_argument_instanceId_with_empty_value_should_raise_ValueError(self):
@@ -733,7 +733,7 @@ class TestSpiderFootDb(unittest.TestCase):
sfdb = SpiderFootDb(self.default_options, False)
event = ""
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.scanEventStore("", event)
def test_scanEventStore_argument_sfEvent_of_invalid_type_should_raise_TypeError(self):
@@ -746,7 +746,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanEventStore(instance_id, invalid_type)
def test_scanEventStore_argument_sfEvent_with_invalid_eventType_property_type_should_raise_TypeError(self):
@@ -770,7 +770,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.eventType = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -794,7 +794,7 @@ class TestSpiderFootDb(unittest.TestCase):
instance_id = "example instance id"
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
event.eventType = ''
sfdb.scanEventStore(instance_id, event)
@@ -819,7 +819,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.data = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -843,7 +843,7 @@ class TestSpiderFootDb(unittest.TestCase):
instance_id = "example instance id"
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
event.data = ''
sfdb.scanEventStore(instance_id, event)
@@ -868,7 +868,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.module = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -891,7 +891,7 @@ class TestSpiderFootDb(unittest.TestCase):
event = SpiderFootEvent(event_type, event_data, module, source_event)
instance_id = "example instance id"
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
event.module = ''
sfdb.scanEventStore(instance_id, event)
@@ -916,7 +916,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.confidence = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -942,7 +942,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.confidence = invalid_value
sfdb.scanEventStore(instance_id, event)
@@ -968,7 +968,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.visibility = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -994,7 +994,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.visibility = invalid_value
sfdb.scanEventStore(instance_id, event)
@@ -1020,7 +1020,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.risk = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -1046,7 +1046,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.risk = invalid_value
sfdb.scanEventStore(instance_id, event)
@@ -1072,7 +1072,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
event = SpiderFootEvent(event_type, event_data, module, source_event)
event.sourceEvent = invalid_type
sfdb.scanEventStore(instance_id, event)
@@ -1105,7 +1105,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanResultHistory(invalid_type)
def test_scanElementSourcesDirect_should_return_a_list(self):
@@ -1131,7 +1131,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementSourcesDirect(invalid_type, element_id_list)
def test_scanElementSourcesDirect_argument_elementIdList_of_invalid_type_should_raise_TypeError(self):
@@ -1144,7 +1144,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementSourcesDirect(instance_id, invalid_type)
def test_scanElementChildrenDirect_should_return_a_list(self):
@@ -1169,7 +1169,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementChildrenDirect(invalid_type, element_id_list)
def test_scanElementChildrenDirect_argument_elementIdList_of_invalid_type_should_raise_TypeError(self):
@@ -1182,7 +1182,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementChildrenDirect(instance_id, invalid_type)
def test_scanElementSourcesAll_should_return_a_list(self):
@@ -1208,7 +1208,7 @@ class TestSpiderFootDb(unittest.TestCase):
child_data = []
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementSourcesAll(invalid_type, child_data)
def test_scanElementSourcesAll_argument_childData_of_invalid_type_should_raise_TypeError(self):
@@ -1221,7 +1221,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementSourcesAll(instance_id, invalid_type)
def test_scanElementSourcesAll_argument_childData_with_empty_value_should_raise_ValueError(self):
@@ -1233,7 +1233,7 @@ class TestSpiderFootDb(unittest.TestCase):
instance_id = "example instance id"
child_data = []
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
sfdb.scanElementSourcesAll(instance_id, child_data)
def test_scanElementChildrenAll_should_return_a_list(self):
@@ -1258,7 +1258,7 @@ class TestSpiderFootDb(unittest.TestCase):
parent_ids = []
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementChildrenAll(invalid_type, parent_ids)
def test_scanElementChildrenAll_argument_parentIds_of_invalid_type_should_raise_TypeError(self):
@@ -1271,7 +1271,7 @@ class TestSpiderFootDb(unittest.TestCase):
invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfdb.scanElementChildrenAll(instance_id, invalid_type)
diff --git a/test/unit/test_spiderfootevent.py b/test/unit/test_spiderfootevent.py
index a8255a55..afa8f776 100644
--- a/test/unit/test_spiderfootevent.py
+++ b/test/unit/test_spiderfootevent.py
@@ -51,7 +51,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(invalid_type, event_data, module, source_event)
def test_init_argument_eventType_with_empty_value_should_raise_ValueError(self):
@@ -64,7 +64,7 @@ class TestSpiderFootEvent(unittest.TestCase):
event_type = ''
module = 'example module'
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootEvent(event_type, event_data, module, source_event)
def test_init_argument_data_of_invalid_type_should_raise_TypeError(self):
@@ -78,7 +78,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(event_type, invalid_type, module, source_event)
def test_init_argument_data_with_empty_value_should_raise_ValueError(self):
@@ -92,7 +92,7 @@ class TestSpiderFootEvent(unittest.TestCase):
event_data = ''
module = 'example module'
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootEvent(event_type, event_data, module, source_event)
def test_init_argument_module_of_invalid_type_should_raise_TypeError(self):
@@ -108,7 +108,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(event_type, event_data, invalid_type, source_event)
def test_init_argument_module_with_empty_value_should_raise_ValueError(self):
@@ -122,7 +122,7 @@ class TestSpiderFootEvent(unittest.TestCase):
event_data = 'example event data'
module = ''
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootEvent(event_type, event_data, module, source_event)
def test_init_argument_sourceEvent_of_invalid_type_should_raise_TypeError(self):
@@ -138,7 +138,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(event_type, event_data, module, invalid_type)
def test_init_argument_confidence_of_invalid_type_should_raise_TypeError(self):
@@ -150,7 +150,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(event_type, event_data, module, source_event, confidence=invalid_type)
def test_init_argument_confidence_invalid_value_should_raise_ValueError(self):
@@ -162,7 +162,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootEvent(event_type, event_data, module, source_event, confidence=invalid_value)
def test_init_argument_visibility_of_invalid_type_should_raise_TypeError(self):
@@ -174,7 +174,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(event_type, event_data, module, source_event, visibility=invalid_type)
def test_init_argument_visibility_invalid_value_should_raise_ValueError(self):
@@ -186,7 +186,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootEvent(event_type, event_data, module, source_event, visibility=invalid_value)
def test_init_argument_risk_of_invalid_type_should_raise_TypeError(self):
@@ -198,7 +198,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootEvent(event_type, event_data, module, source_event, risk=invalid_type)
def test_init_argument_risk_invalid_value_should_raise_ValueError(self):
@@ -210,7 +210,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_values = [-1, 101]
for invalid_value in invalid_values:
with self.subTest(invalid_value=invalid_value):
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootEvent(event_type, event_data, module, source_event, risk=invalid_value)
def test_confidence_attribute_should_return_confidence_as_integer(self):
@@ -233,7 +233,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
evt.confidence = invalid_type
def test_visibility_attribute_should_return_visibility_as_integer(self):
@@ -256,7 +256,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
evt.visibility = invalid_type
def test_risk_attribute_should_return_risk_as_integer(self):
@@ -279,7 +279,7 @@ class TestSpiderFootEvent(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
evt.risk = invalid_type
def test_asdict_root_event_should_return_event_as_a_dict(self):
diff --git a/test/unit/test_spiderfootplugin.py b/test/unit/test_spiderfootplugin.py
index b57074e2..913b18e5 100644
--- a/test/unit/test_spiderfootplugin.py
+++ b/test/unit/test_spiderfootplugin.py
@@ -103,7 +103,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfp.setTarget(invalid_type)
def test_set_dbh(self):
@@ -148,7 +148,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
"""
sfp = SpiderFootPlugin()
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfp.getScanId()
def test_get_target_should_return_a_string(self):
@@ -170,7 +170,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
"""
sfp = SpiderFootPlugin()
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfp.getTarget()
def test_register_listener(self):
@@ -234,7 +234,7 @@ class TestSpiderFootPlugin(unittest.TestCase):
invalid_types = [None, "", list(), dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfp.notifyListeners(None)
def test_check_for_stop(self):
diff --git a/test/unit/test_spiderfootscanner.py b/test/unit/test_spiderfootscanner.py
index 9e1957f9..badb38a8 100644
--- a/test/unit/test_spiderfootscanner.py
+++ b/test/unit/test_spiderfootscanner.py
@@ -69,7 +69,7 @@ class TestSpiderFootScanner(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootScanner(invalid_type, scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_scanName_as_empty_string_should_raise_ValueError(self):
@@ -79,7 +79,7 @@ class TestSpiderFootScanner(unittest.TestCase):
scan_id = str(uuid.uuid4())
module_list = ['sfp__stor_db']
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootScanner("", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_scanId_of_invalid_type_should_raise_TypeError(self):
@@ -91,7 +91,7 @@ class TestSpiderFootScanner(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootScanner("example scan name", invalid_type, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_scanId_as_empty_string_should_raise_ValueError(self):
@@ -101,7 +101,7 @@ class TestSpiderFootScanner(unittest.TestCase):
scan_id = ""
module_list = ['sfp__stor_db']
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_targetValue_of_invalid_type_should_raise_TypeError(self):
@@ -114,7 +114,7 @@ class TestSpiderFootScanner(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootScanner("example scan name", scan_id, invalid_type, "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_targetValue_as_empty_string_should_raise_ValueError(self):
@@ -124,7 +124,7 @@ class TestSpiderFootScanner(unittest.TestCase):
scan_id = str(uuid.uuid4())
module_list = ['sfp__stor_db']
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootScanner("example scan name", scan_id, "", "IP_ADDRESS", module_list, self.default_options, start=False)
def test_init_argument_targetType_of_invalid_type_should_raise_TypeError(self):
@@ -137,7 +137,7 @@ class TestSpiderFootScanner(unittest.TestCase):
invalid_types = [None, list(), dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", invalid_type, module_list, self.default_options, start=False)
def test_init_argument_targetType_as_empty_string_should_raise_ValueError(self):
@@ -148,7 +148,7 @@ class TestSpiderFootScanner(unittest.TestCase):
module_list = ['sfp__stor_db']
target_type = ""
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", target_type, module_list, self.default_options, start=False)
def test_init_argument_moduleList_of_invalid_type_should_raise_TypeError(self):
@@ -160,7 +160,7 @@ class TestSpiderFootScanner(unittest.TestCase):
invalid_types = [None, "", dict(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", invalid_type, self.default_options, start=False)
def test_init_argument_moduleList_as_empty_list_should_raise_ValueError(self):
@@ -170,7 +170,7 @@ class TestSpiderFootScanner(unittest.TestCase):
scan_id = str(uuid.uuid4())
module_list = list()
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, dict(), start=False)
def test_init_argument_globalOpts_of_invalid_type_should_raise_TypeError(self):
@@ -183,7 +183,7 @@ class TestSpiderFootScanner(unittest.TestCase):
invalid_types = [None, "", list(), int()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, invalid_type, start=False)
def test_init_argument_globalOpts_as_empty_dict_should_raise_ValueError(self):
@@ -193,7 +193,7 @@ class TestSpiderFootScanner(unittest.TestCase):
scan_id = str(uuid.uuid4())
module_list = ['sfp__stor_db']
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootScanner("example scan name", scan_id, "spiderfoot.net", "IP_ADDRESS", module_list, dict(), start=False)
def test_attribute_scanId_should_return_scan_id_as_a_string(self):
diff --git a/test/unit/test_spiderfoottarget.py b/test/unit/test_spiderfoottarget.py
index b2dba459..0897e4a1 100644
--- a/test/unit/test_spiderfoottarget.py
+++ b/test/unit/test_spiderfoottarget.py
@@ -17,14 +17,14 @@ class TestSpiderFootTarget(unittest.TestCase):
"""
Test __init__(self, targetValue, typeName)
"""
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootTarget(None, 'IP_ADDRESS')
def test_init_unsupported_target_type_should_raise(self):
"""
Test __init__(self, targetValue, typeName)
"""
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootTarget('example target value', 'example target type')
def test_init_supported_target_types(self):
diff --git a/test/unit/test_spiderfootwebui.py b/test/unit/test_spiderfootwebui.py
index 089de25b..c1ad7c01 100644
--- a/test/unit/test_spiderfootwebui.py
+++ b/test/unit/test_spiderfootwebui.py
@@ -330,10 +330,10 @@ class TestSpiderFootWebUi(unittest.TestCase):
"""
Test __init__(self, config)
"""
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
SpiderFootWebUi(None)
- with self.assertRaises(ValueError) as cm:
+ with self.assertRaises(ValueError):
SpiderFootWebUi(dict())
@unittest.skip("todo")
@@ -381,7 +381,7 @@ class TestSpiderFootWebUi(unittest.TestCase):
invalid_types = [None, "", dict()]
for invalid_type in invalid_types:
with self.subTest(invalid_type=invalid_type):
- with self.assertRaises(TypeError) as cm:
+ with self.assertRaises(TypeError):
sfwebui.cleanUserInput(invalid_type)
def test_search_base_should_return_a_list(self):