assertionchecker.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:gremlinsdk-python 作者: ResilienceTesting 项目源码 文件源码
def _check_value_recursively(key, val, haystack):
    """
    Check if there is key _key_ with value _val_ in the given dictionary.
    ..warning:
        This is geared at JSON dictionaries, so some corner cases are ignored,
        we assume all iterables are either arrays or dicts
    """
    if isinstance(haystack, list):
        return any([_check_value_recursively(key, val, l) for l in haystack])
    elif isinstance(haystack, dict):
        if not key in haystack:
            return any([_check_value_recursively(key, val, d) for k, d in haystack.items()
                        if isinstance(d, list) or isinstance(d, dict)])
        else:
            return haystack[key] == val
    else:
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号