Skip to content

Commit 56e444f

Browse files
authored
[2.7] bpo-32107 - Backport bitmask check fix (GH-4576) (#4590)
Remove a flakey test and rewrite another one for readability.
1 parent bc19cf5 commit 56e444f

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Lib/test/test_uuid.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,54 +429,52 @@ def mock_popen(cmd):
429429
)
430430
self.assertEqual(mac, 0x1234567890ab)
431431

432-
def check_node(self, node, requires=None, network=False):
432+
def check_node(self, node, requires=None):
433433
if requires and node is None:
434434
self.skipTest('requires ' + requires)
435435
hex = '%012x' % node
436436
if test_support.verbose >= 2:
437437
print hex + ' ',
438-
if network:
439-
# 47 bit will never be set in IEEE 802 addresses obtained
440-
# from network cards.
441-
self.assertFalse(node & 0x010000000000, hex)
442438
self.assertTrue(0 < node < (1L << 48),
443439
"%s is not an RFC 4122 node ID" % hex)
444440

445441
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
446442
def test_ifconfig_getnode(self):
447443
node = uuid._ifconfig_getnode()
448-
self.check_node(node, 'ifconfig', True)
444+
self.check_node(node, 'ifconfig')
449445

450446
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
451447
def test_arp_getnode(self):
452448
node = uuid._arp_getnode()
453-
self.check_node(node, 'arp', True)
449+
self.check_node(node, 'arp')
454450

455451
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
456452
def test_lanscan_getnode(self):
457453
node = uuid._lanscan_getnode()
458-
self.check_node(node, 'lanscan', True)
454+
self.check_node(node, 'lanscan')
459455

460456
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
461457
def test_netstat_getnode(self):
462458
node = uuid._netstat_getnode()
463-
self.check_node(node, 'netstat', True)
459+
self.check_node(node, 'netstat')
464460

465461
@unittest.skipUnless(os.name == 'nt', 'requires Windows')
466462
def test_ipconfig_getnode(self):
467463
node = uuid._ipconfig_getnode()
468-
self.check_node(node, 'ipconfig', True)
464+
self.check_node(node, 'ipconfig')
469465

470466
@unittest.skipUnless(importable('win32wnet'), 'requires win32wnet')
471467
@unittest.skipUnless(importable('netbios'), 'requires netbios')
472468
def test_netbios_getnode(self):
473469
node = uuid._netbios_getnode()
474-
self.check_node(node, network=True)
470+
self.check_node(node)
475471

476472
def test_random_getnode(self):
477473
node = uuid._random_getnode()
478-
# Least significant bit of first octet must be set.
479-
self.assertTrue(node & 0x010000000000, '%012x' % node)
474+
# The multicast bit, i.e. the least significant bit of first octet,
475+
# must be set for randomly generated MAC addresses. See RFC 4122,
476+
# $4.1.6.
477+
self.assertTrue(node & (1 << 40), '%012x' % node)
480478
self.check_node(node)
481479

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

0 commit comments

Comments
 (0)