1. python_mirrors
  2. sandbox/antoine


Tim Peters  committed ac01b63

check_node(): stop spraying mystery output to stderr.

When a node number disagrees, keep track of all sources & the
node numbers they reported, and stick all that in the error message.

Changed all callers to supply a non-empty "source" argument; made
the "source" argument non-optional.

On my box, test_uuid still fails, but with the less confusing output:

AssertionError: different sources disagree on node:
from source 'getnode1', node was 00038a000015
from source 'getnode2', node was 00038a000015
from source 'ipconfig', node was 001111b2b7bf

Only the last one appears to be correct; e.g.,


Physical Address Transport Name
=================== ==========================================================
00-11-11-B2-B7-BF \Device\Tcpip_{190FB163-5AFD-4483-86A1-2FE16AC61FF1}
62-A1-AC-6C-FD-BE \Device\Tcpip_{8F77DF5A-EA3D-4F1D-975E-D472CEE6438A}
E2-1F-01-C6-5D-88 \Device\Tcpip_{CD18F76B-2EF3-409F-9B8A-6481EE70A1E4}

I can't find anything on my box with MAC 00-03-8a-00-00-15, and am
not clear on where that comes from.

  • Participants
  • Parent commits c6d4c0a
  • Branches legacy-trunk

Comments (0)

Files changed (1)

File Lib/test/test_uuid.py

View file
 class TestUUID(TestCase):
     last_node = None
+    source2node = {}
     def test_UUID(self):
         equal = self.assertEqual
         badtype(lambda: setattr(u, 'fields', f))
         badtype(lambda: setattr(u, 'int', i))
-    def check_node(self, node, source=''):
+    def check_node(self, node, source):
         individual_group_bit = (node >> 40L) & 1
         universal_local_bit = (node >> 40L) & 2
         message = "%012x doesn't look like a real MAC address" % node
         self.assertNotEqual(node, 0, message)
         self.assertNotEqual(node, 0xffffffffffffL, message)
         self.assert_(0 <= node, message)
-        self.assert_(node < 1<<48L, message)
+        self.assert_(node < (1L << 48), message)
-        import sys
-        if source:
-            sys.stderr.write('(%s: %012x)' % (source, node))
+        TestUUID.source2node[source] = node
         if TestUUID.last_node:
-            self.assertEqual(TestUUID.last_node, node, 'inconsistent node IDs')
+            if TestUUID.last_node != node:
+                msg = "different sources disagree on node:\n"
+                for s, n in TestUUID.source2node.iteritems():
+                    msg += "    from source %r, node was %012x\n" % (s, n)
+                self.fail(msg)
             TestUUID.last_node = node
             self.check_node(uuid._windll_getnode(), 'windll')
     def test_getnode(self):
-        self.check_node(uuid.getnode())
+        self.check_node(uuid.getnode(), "getnode1")
         # Test it again to ensure consistency.
-        self.check_node(uuid.getnode())
+        self.check_node(uuid.getnode(), "getnode2")
     def test_uuid1(self):
         equal = self.assertEqual