Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Unified Diff: Lib/test/test_uuid.py

Issue 11508: Virtual Interfaces cause uuid._find_mac to raise a ValueError under Linux
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/uuid.py » ('j') | Lib/uuid.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_uuid.py Mon Mar 14 10:56:33 2011 -0400
+++ b/Lib/test/test_uuid.py Mon Mar 14 17:21:28 2011 -0400
@@ -360,6 +360,39 @@
self.assertEqual(node1, node2)
+ def test__find_mac(self):
+ import os
+
+ original_popen = os.popen
+
+ class MockPopen(object):
storchaka 2013/10/27 14:09:20 I think this can be simpler. def mock_popen(cmd):
kfrazier 2013/10/31 03:36:29 I didn't know about support.swap_attr. That is a m
storchaka 2013/11/09 21:08:31 io.StringIO supports context manager protocol.
+ data = [
+ ('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 __init__(self, cmd):
+ pass
+ def __enter__(self):
+ return self
+ def __exit__(self, exc_type, exc_value, traceback):
+ pass
+ def __iter__(self):
+ return iter(self.data)
+
+ os.popen = MockPopen
+
+ try:
+ mac = uuid._find_mac(
+ command='ifconfig',
+ args='',
+ hw_identifiers=['hwaddr'],
+ get_index=lambda x: x + 1,
+ )
+ self.assertEqual(mac, 0x1234567890ab)
+ finally:
+ os.popen = original_popen
+
def test_uuid1(self):
# uuid1 requires ctypes.
try:
« no previous file with comments | « no previous file | Lib/uuid.py » ('j') | Lib/uuid.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+