當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。