Python uuid._random_getnode() Examples

The following are 11 code examples of uuid._random_getnode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module uuid , or try the search function .
Example #1
Source File: test_uuid.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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') 
Example #2
Source File: test_uuid.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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) 
Example #3
Source File: test_uuid.py    From BinderFilter with MIT License 5 votes vote down vote up
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)) 
Example #4
Source File: test_uuid.py    From oss-ftp with MIT License 5 votes vote down vote up
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)) 
Example #5
Source File: test_uuid.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #6
Source File: test_uuid.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
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) 
Example #7
Source File: test_uuid.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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)) 
Example #8
Source File: test_uuid.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #9
Source File: test_uuid.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_random_getnode(self):
        node = uuid._random_getnode()
        self.assert_(0 <= node)
        self.assert_(node < (1L <<48)) 
Example #10
Source File: test_uuid.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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)) 
Example #11
Source File: test_uuid.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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))