Skip to content

bpo-31643: test_uuid: allow zero MAC address #4804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions Lib/test/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ def importable(name):
except:
return False


class BaseTestUUID:
class _BaseTestShared:
uuid = None

def check_node(self, node, requires=None):
if requires and node is None:
self.skipTest('requires ' + requires)
hex = '%012x' % node
if support.verbose >= 2:
print(hex, end=' ')
self.assertTrue(0 <= node < (1 << 48),
"%s is not an RFC 4122 node ID" % hex)



class BaseTestUUID(_BaseTestShared):

def test_UUID(self):
equal = self.assertEqual
ascending = []
Expand Down Expand Up @@ -305,7 +317,7 @@ def test_exceptions(self):

def test_getnode(self):
node1 = self.uuid.getnode()
self.assertTrue(0 < node1 < (1 << 48), '%012x' % node1)
self.check_node(node1)

# Test it again to ensure consistency.
node2 = self.uuid.getnode()
Expand Down Expand Up @@ -485,8 +497,7 @@ class TestUUIDWithExtModule(BaseTestUUID, unittest.TestCase):
uuid = c_uuid


class BaseTestInternals:
uuid = None
class BaseTestInternals(_BaseTestShared):

@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_find_mac(self):
Expand All @@ -512,15 +523,6 @@ def test_find_mac(self):

self.assertEqual(mac, 0x1234567890ab)

def check_node(self, node, requires=None):
if requires and node is None:
self.skipTest('requires ' + requires)
hex = '%012x' % node
if support.verbose >= 2:
print(hex, end=' ')
self.assertTrue(0 < node < (1 << 48),
"%s is not an RFC 4122 node ID" % hex)

@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_ifconfig_getnode(self):
node = self.uuid._ifconfig_getnode()
Expand Down