summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_uuid.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-27 23:30:21 (GMT)
committerGitHub <noreply@github.com>2017-11-27 23:30:21 (GMT)
commitc9409f7c4533f75b11a4c44e839d95a1403f8a0a (patch)
tree768036656c294a2fec12c9480066abba70729f1c /Lib/test/test_uuid.py
parent39f0bb5ad0715dbfc0a2d5dd6d0ddea9e4c65ae2 (diff)
downloadcpython-c9409f7c4533f75b11a4c44e839d95a1403f8a0a.zip
cpython-c9409f7c4533f75b11a4c44e839d95a1403f8a0a.tar.gz
cpython-c9409f7c4533f75b11a4c44e839d95a1403f8a0a.tar.bz2
Revert "bpo-32107 - Better merge of #4494 (#4576)" (#4593)
This reverts commit 9522a218f7dff95c490ff359cc60e8c2af35f5c8.
Diffstat (limited to 'Lib/test/test_uuid.py')
-rw-r--r--Lib/test/test_uuid.py47
1 files changed, 17 insertions, 30 deletions
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index 54d73f7..083c2aa 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -512,69 +512,60 @@ eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab
self.assertEqual(mac, 0x1234567890ab)
- def check_node(self, node, requires=None, *, check_bit=True):
+ def check_node(self, node, requires=None, network=False):
if requires and node is None:
self.skipTest('requires ' + requires)
hex = '%012x' % node
if support.verbose >= 2:
print(hex, end=' ')
- # The MAC address will be universally administered (i.e. the second
- # least significant bit of the first octet must be unset) for any
- # physical interface, such as an ethernet port or wireless adapter.
- # There are some cases where this won't be the case. Randomly
- # generated MACs may not be universally administered, but they must
- # have their multicast bit set, though this is tested in the
- # `test_random_getnode()` method specifically. Another case is the
- # Travis-CI case, which apparently only has locally administered MAC
- # addresses.
- if check_bit and not os.getenv('TRAVIS'):
- self.assertFalse(node & (1 << 41), '%012x' % node)
+ if network:
+ # 47 bit will never be set in IEEE 802 addresses obtained
+ # from network cards.
+ self.assertFalse(node & 0x010000000000, hex)
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()
- self.check_node(node, 'ifconfig')
+ self.check_node(node, 'ifconfig', True)
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_ip_getnode(self):
node = self.uuid._ip_getnode()
- self.check_node(node, 'ip')
+ self.check_node(node, 'ip', True)
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_arp_getnode(self):
node = self.uuid._arp_getnode()
- self.check_node(node, 'arp')
+ self.check_node(node, 'arp', True)
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_lanscan_getnode(self):
node = self.uuid._lanscan_getnode()
- self.check_node(node, 'lanscan')
+ self.check_node(node, 'lanscan', True)
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_netstat_getnode(self):
node = self.uuid._netstat_getnode()
- self.check_node(node, 'netstat')
+ self.check_node(node, 'netstat', True)
@unittest.skipUnless(os.name == 'nt', 'requires Windows')
def test_ipconfig_getnode(self):
node = self.uuid._ipconfig_getnode()
- self.check_node(node, 'ipconfig')
+ self.check_node(node, 'ipconfig', True)
@unittest.skipUnless(importable('win32wnet'), 'requires win32wnet')
@unittest.skipUnless(importable('netbios'), 'requires netbios')
def test_netbios_getnode(self):
node = self.uuid._netbios_getnode()
- self.check_node(node)
+ self.check_node(node, network=True)
def test_random_getnode(self):
node = self.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, check_bit=False)
+ # Least significant bit of first octet must be set.
+ self.assertTrue(node & 0x010000000000, '%012x' % node)
+ self.check_node(node)
@unittest.skipUnless(os.name == 'posix', 'requires Posix')
def test_unix_getnode(self):
@@ -584,17 +575,13 @@ eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab
node = self.uuid._unix_getnode()
except TypeError:
self.skipTest('requires uuid_generate_time')
- # Since we don't know the provenance of the MAC address, don't check
- # whether it is locally or universally administered.
- self.check_node(node, 'unix', check_bit=False)
+ self.check_node(node, 'unix')
@unittest.skipUnless(os.name == 'nt', 'requires Windows')
@unittest.skipUnless(importable('ctypes'), 'requires ctypes')
def test_windll_getnode(self):
node = self.uuid._windll_getnode()
- # Since we don't know the provenance of the MAC address, don't check
- # whether it is locally or universally administered.
- self.check_node(node, check_bit=False)
+ self.check_node(node)
class TestInternalsWithoutExtModule(BaseTestInternals, unittest.TestCase):