summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-09-30 17:34:19 (GMT)
committerGeorg Brandl <georg@python.org>2014-09-30 17:34:19 (GMT)
commit51c116223e7698ce3cbbac46e8a6779aea8ec9c6 (patch)
tree1b7a6385c7b3eb931162613acfa527556764151a /Lib/test
parent3bc35672a23a4505ffe5b6eeb822125dce9db770 (diff)
downloadcpython-51c116223e7698ce3cbbac46e8a6779aea8ec9c6.zip
cpython-51c116223e7698ce3cbbac46e8a6779aea8ec9c6.tar.gz
cpython-51c116223e7698ce3cbbac46e8a6779aea8ec9c6.tar.bz2
Issue #19855: uuid.getnode() on Unix now looks on the PATH for the
executables used to find the mac address, with /sbin and /usr/sbin as fallbacks. Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with virtual interface. Original patch by Kent Frazier. Issue #18784: The uuid module no more attempts to load libc via ctypes.CDLL, if all necessary functions are already found in libuuid. Patch by Evgeny Sologubov. Issue #16102: Make uuid._netbios_getnode() work again on Python 3.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_uuid.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index 43fa656..7ba0967 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -1,6 +1,8 @@
from unittest import TestCase
from test import support
import builtins
+import io
+import os
import uuid
def importable(name):
@@ -360,6 +362,25 @@ class TestUUID(TestCase):
self.assertEqual(node1, node2)
+ def test_find_mac(self):
+ data = '''\
+
+fake hwaddr
+cscotun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
+eth0 Link encap:Ethernet HWaddr 12:34:56:78:90:ab
+'''
+ def mock_popen(cmd):
+ return io.StringIO(data)
+
+ with support.swap_attr(os, 'popen', mock_popen):
+ mac = uuid._find_mac(
+ command='ifconfig',
+ args='',
+ hw_identifiers=['hwaddr'],
+ get_index=lambda x: x + 1,
+ )
+ self.assertEqual(mac, 0x1234567890ab)
+
def test_uuid1(self):
# uuid1 requires ctypes.
try: