本文整理匯總了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))