本文整理汇总了Python中uuid._random_getnode方法的典型用法代码示例。如果您正苦于以下问题:Python uuid._random_getnode方法的具体用法?Python uuid._random_getnode怎么用?Python uuid._random_getnode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uuid
的用法示例。
在下文中一共展示了uuid._random_getnode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_uuid1_eui64
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import _random_getnode [as 别名]
def test_uuid1_eui64(self):
# Confirm that uuid.getnode ignores hardware addresses larger than 48
# bits. Mock out each platform's *_getnode helper functions to return
# something just larger than 48 bits to test. This will cause
# uuid.getnode to fall back on uuid._random_getnode, which will
# generate a valid value.
too_large_getter = lambda: 1 << 48
uuid_real__node = uuid._node
uuid_real__NODE_GETTERS_WIN32 = uuid._NODE_GETTERS_WIN32
uuid_real__NODE_GETTERS_UNIX = uuid._NODE_GETTERS_UNIX
uuid._node = None
uuid._NODE_GETTERS_WIN32 = [too_large_getter]
uuid._NODE_GETTERS_UNIX = [too_large_getter]
try:
node = uuid.getnode()
finally:
uuid._node = uuid_real__node
uuid._NODE_GETTERS_WIN32 = uuid_real__NODE_GETTERS_WIN32
uuid._NODE_GETTERS_UNIX = uuid_real__NODE_GETTERS_UNIX
self.assertTrue(0 < node < (1 << 48), '%012x' % node)
# Confirm that uuid1 can use the generated node, i.e., the that
# uuid.getnode fell back on uuid._random_getnode() rather than using
# the value from too_large_getter above.
try:
uuid.uuid1(node=node)
except ValueError as e:
self.fail('uuid1 was given an invalid node ID')
示例2: test_random_getnode
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import _random_getnode [as 别名]
def test_random_getnode(self):
node = uuid._random_getnode()
# The multicast bit, i.e. the least significant bit of first octet,
# must be set for randomly generated MAC addresses. See RFC 4122,
# $4.1.6.
self.assertTrue(node & (1 << 40), '%012x' % node)
self.check_node(node)
示例3: test_random_getnode
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import _random_getnode [as 别名]
def test_random_getnode(self):
node = uuid._random_getnode()
# Least significant bit of first octet must be set.
self.assertTrue(node & 0x010000000000)
self.assertTrue(node < (1L << 48))
示例4: test_random_getnode
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import _random_getnode [as 别名]
def test_random_getnode(self):
node = uuid._random_getnode()
# Least significant bit of first octet must be set.
self.assertTrue(node & 0x010000000000, '%012x' % node)
self.check_node(node)
示例5: test_random_getnode
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import _random_getnode [as 别名]
def test_random_getnode(self):
node = uuid._random_getnode()
self.assert_(0 <= node)
self.assert_(node < (1L <<48))