summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_uuid.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-11-26 20:47:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-11-26 20:47:16 (GMT)
commit56507c7862b6e2de189b6a942f394efb676cdb0b (patch)
tree5f81a187f15ef5c7c7f8810cbf8328b98cce432f /Lib/test/test_uuid.py
parenta04f4e0374256adddbb84ece0b30c9bcaa66d144 (diff)
downloadcpython-56507c7862b6e2de189b6a942f394efb676cdb0b.zip
cpython-56507c7862b6e2de189b6a942f394efb676cdb0b.tar.gz
cpython-56507c7862b6e2de189b6a942f394efb676cdb0b.tar.bz2
Issue #11508: Fixed uuid.getnode() and uuid.uuid1() on environment with
virtual interface. Original patch by Kent Frazier.
Diffstat (limited to 'Lib/test/test_uuid.py')
-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 97ad6d0..0a47a91 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -1,5 +1,7 @@
import unittest
+from test import support
import builtins
+import io
import os
import uuid
@@ -356,6 +358,25 @@ class TestUUID(unittest.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)
+
@unittest.skipUnless(importable('ctypes'), 'requires ctypes')
def test_uuid1(self):
equal = self.assertEqual