tests.py 文件源码

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

项目:usres_monitor 作者: pierky 项目源码 文件源码
def test_duplicate(net_str, net2_str=None, dup_found=True):
    usres_monitor.add_net(ipaddr.IPNetwork(net_str))
    try:
        usres_monitor.add_net(
            ipaddr.IPNetwork(net2_str if net2_str else net_str)
        )
    except USRESMonitorException as e:
        if "it was already in the db" in str(e):
            test_outcome("test_duplicate",
                         "{} and {}".format(
                             net_str,
                             net2_str if net2_str else net_str),
                         "OK" if dup_found else "FAIL")
            if not dup_found:
                raise AssertionError("Duplicate found")
            return
    test_outcome("test_duplicate",
                    "{} and {}".format(
                        net_str,
                        net2_str if net2_str else net_str),
                    "FAIL" if dup_found else "OK")
    if dup_found:
        raise AssertionError("Duplicate not found")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号