This is a convenient way for tests to assert that some nested dicts (like a parsed json) has a particular key/value somewhere in it. For example: assert_dict_has(config, "toplevel.subitem.key", True)
15 lines
294 B
Python
15 lines
294 B
Python
"""
|
|
Test related utilities
|
|
"""
|
|
import shutil
|
|
|
|
|
|
def has_executable(executable: str) -> bool:
|
|
return shutil.which(executable) is not None
|
|
|
|
|
|
def assert_dict_has(v, keys, expected_value):
|
|
for key in keys.split("."):
|
|
assert key in v
|
|
v = v[key]
|
|
assert v == expected_value
|