Skip to content

Commit 23cc8c0

Browse files
authored
[3.6] bpo-32107 - Backport bitmask check fix (GH-4576) (#4591)
Remove a flakey test and rewrite another one for readability.
1 parent b0df786 commit 23cc8c0

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Lib/test/test_uuid.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -438,59 +438,57 @@ def test_find_mac(self):
438438

439439
self.assertEqual(mac, 0x1234567890ab)
440440

441-
def check_node(self, node, requires=None, network=False):
441+
def check_node(self, node, requires=None):
442442
if requires and node is None:
443443
self.skipTest('requires ' + requires)
444444
hex = '%012x' % node
445445
if support.verbose >= 2:
446446
print(hex, end=' ')
447-
if network:
448-
# 47 bit will never be set in IEEE 802 addresses obtained
449-
# from network cards.
450-
self.assertFalse(node & 0x010000000000, hex)
451447
self.assertTrue(0 < node < (1 << 48),
452448
"%s is not an RFC 4122 node ID" % hex)
453449

454450
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
455451
def test_ifconfig_getnode(self):
456452
node = uuid._ifconfig_getnode()
457-
self.check_node(node, 'ifconfig', True)
453+
self.check_node(node, 'ifconfig')
458454

459455
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
460456
def test_ip_getnode(self):
461457
node = uuid._ip_getnode()
462-
self.check_node(node, 'ip', True)
458+
self.check_node(node, 'ip')
463459

464460
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
465461
def test_arp_getnode(self):
466462
node = uuid._arp_getnode()
467-
self.check_node(node, 'arp', True)
463+
self.check_node(node, 'arp')
468464

469465
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
470466
def test_lanscan_getnode(self):
471467
node = uuid._lanscan_getnode()
472-
self.check_node(node, 'lanscan', True)
468+
self.check_node(node, 'lanscan')
473469

474470
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
475471
def test_netstat_getnode(self):
476472
node = uuid._netstat_getnode()
477-
self.check_node(node, 'netstat', True)
473+
self.check_node(node, 'netstat')
478474

479475
@unittest.skipUnless(os.name == 'nt', 'requires Windows')
480476
def test_ipconfig_getnode(self):
481477
node = uuid._ipconfig_getnode()
482-
self.check_node(node, 'ipconfig', True)
478+
self.check_node(node, 'ipconfig')
483479

484480
@unittest.skipUnless(importable('win32wnet'), 'requires win32wnet')
485481
@unittest.skipUnless(importable('netbios'), 'requires netbios')
486482
def test_netbios_getnode(self):
487483
node = uuid._netbios_getnode()
488-
self.check_node(node, network=True)
484+
self.check_node(node)
489485

490486
def test_random_getnode(self):
491487
node = uuid._random_getnode()
492-
# Least significant bit of first octet must be set.
493-
self.assertTrue(node & 0x010000000000, '%012x' % node)
488+
# The multicast bit, i.e. the least significant bit of first octet,
489+
# must be set for randomly generated MAC addresses. See RFC 4122,
490+
# $4.1.6.
491+
self.assertTrue(node & (1 << 40), '%012x' % node)
494492
self.check_node(node)
495493

496494
@unittest.skipUnless(os.name == 'posix', 'requires Posix')

0 commit comments

Comments
 (0)