当前位置: 首页>>代码示例>>Python>>正文


Python uuid._random_getnode方法代码示例

本文整理汇总了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') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:32,代码来源:test_uuid.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_uuid.py

示例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)) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:7,代码来源:test_uuid.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_uuid.py

示例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)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:6,代码来源:test_uuid.py


注:本文中的uuid._random_getnode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。