[Python-checkins] r50876 - python/trunk/Lib/test/test_uuid.py
tim.peters
python-checkins at python.org
Thu Jul 27 22:47:25 CEST 2006
Author: tim.peters
Date: Thu Jul 27 22:47:24 2006
New Revision: 50876
Modified:
python/trunk/Lib/test/test_uuid.py
Log:
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.,
C:\Code\python\PCbuild>getmac
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.
Modified: python/trunk/Lib/test/test_uuid.py
==============================================================================
--- python/trunk/Lib/test/test_uuid.py (original)
+++ python/trunk/Lib/test/test_uuid.py Thu Jul 27 22:47:24 2006
@@ -11,6 +11,7 @@
class TestUUID(TestCase):
last_node = None
+ source2node = {}
def test_UUID(self):
equal = self.assertEqual
@@ -266,7 +267,7 @@
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
@@ -275,13 +276,15 @@
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)
else:
TestUUID.last_node = node
@@ -319,10 +322,10 @@
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
More information about the Python-checkins
mailing list