本文整理汇总了Python中pyroute2.common.AddrPool.setaddr方法的典型用法代码示例。如果您正苦于以下问题:Python AddrPool.setaddr方法的具体用法?Python AddrPool.setaddr怎么用?Python AddrPool.setaddr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyroute2.common.AddrPool
的用法示例。
在下文中一共展示了AddrPool.setaddr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_setaddr_allocated
# 需要导入模块: from pyroute2.common import AddrPool [as 别名]
# 或者: from pyroute2.common.AddrPool import setaddr [as 别名]
def test_setaddr_allocated(self):
ap = AddrPool()
f = ap.alloc()
base, bit, is_allocated = ap.locate(f + 1)
assert not is_allocated
assert ap.allocated == 1
ap.setaddr(f + 1, 'allocated')
base, bit, is_allocated = ap.locate(f + 1)
assert is_allocated
assert ap.allocated == 2
ap.free(f + 1)
base, bit, is_allocated = ap.locate(f + 1)
assert not is_allocated
assert ap.allocated == 1
示例2: test_setaddr_free
# 需要导入模块: from pyroute2.common import AddrPool [as 别名]
# 或者: from pyroute2.common.AddrPool import setaddr [as 别名]
def test_setaddr_free(self):
ap = AddrPool()
f = ap.alloc()
base, bit, is_allocated = ap.locate(f + 1)
assert not is_allocated
assert ap.allocated == 1
ap.setaddr(f + 1, 'free')
base, bit, is_allocated = ap.locate(f + 1)
assert not is_allocated
assert ap.allocated == 1
ap.setaddr(f, 'free')
base, bit, is_allocated = ap.locate(f)
assert not is_allocated
assert ap.allocated == 0
try:
ap.free(f)
except KeyError:
pass