Added extra dict_ methods
This commit is contained in:
parent
7dab8f1f12
commit
6aeb179a41
|
|
@ -101,6 +101,16 @@ def dict_check(dic, *args):
|
|||
return output
|
||||
|
||||
|
||||
def str_dict_check(dic, *args):
|
||||
"""
|
||||
Helper function to test existence within a dictionary and return a string of the values.
|
||||
'arg[0]' : True or False
|
||||
|
||||
"""
|
||||
out = dict_check(dic, *args)
|
||||
return "\n".join([f"{args[i]}: {out[i]}" for i in range(len(out))])
|
||||
|
||||
|
||||
class ParsingError(Exception):
|
||||
"""
|
||||
Exception class for parsing errors
|
||||
|
|
|
|||
|
|
@ -96,5 +96,11 @@ def test_dict_check_2():
|
|||
assert(error_mngr.dict_check({"test": "test"}, "test", "test2", "test3") == [True, False, False])
|
||||
|
||||
|
||||
def test_dict_str():
|
||||
assert error_mngr.str_dict_check({"test": "test"}, "test") == "test: True"
|
||||
assert error_mngr.str_dict_check({"test": "test"}, "test2") == "test2: False"
|
||||
assert error_mngr.str_dict_check({"test": {"test3": "test5"}}, "test", "test3") == "test: True\ntest3: True"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
TestLogging().test_init_logging()
|
||||
|
|
|
|||
Loading…
Reference in New Issue