tests: stabilize doctest output
authorMads Kiilerich <mads@kiilerich.com>
Tue, 15 Jan 2013 02:59:14 +0100
changeset 18378 404feac78b8a
parent 18377 56b805306955
child 18379 e0c4f4ba624c
tests: stabilize doctest output Avoid dependencies to dict iteration order.
mercurial/changelog.py
mercurial/encoding.py
--- a/mercurial/changelog.py	Tue Jan 15 02:59:14 2013 +0100
+++ b/mercurial/changelog.py	Tue Jan 15 02:59:14 2013 +0100
@@ -27,10 +27,12 @@
 
 def decodeextra(text):
     """
-    >>> decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'}))
-    {'foo': 'bar', 'baz': '\\x002', 'branch': 'default'}
-    >>> decodeextra(encodeextra({'foo': 'bar', 'baz': chr(92) + chr(0) + '2'}))
-    {'foo': 'bar', 'baz': '\\\\\\x002', 'branch': 'default'}
+    >>> from pprint import pprint as pp
+    >>> pp(decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'})))
+    {'baz': '\\x002', 'branch': 'default', 'foo': 'bar'}
+    >>> pp(decodeextra(encodeextra({'foo': 'bar',
+    ...                             'baz': chr(92) + chr(0) + '2'})))
+    {'baz': '\\\\\\x002', 'branch': 'default', 'foo': 'bar'}
     """
     extra = _defaultextra.copy()
     for l in text.split('\0'):
--- a/mercurial/encoding.py	Tue Jan 15 02:59:14 2013 +0100
+++ b/mercurial/encoding.py	Tue Jan 15 02:59:14 2013 +0100
@@ -80,8 +80,8 @@
     'foo: \\xc3\\xa4'
     >>> u2 = 'foo: \\xc3\\xa1'
     >>> d = { l: 1, tolocal(u2): 2 }
-    >>> d # no collision
-    {'foo: ?': 1, 'foo: ?': 2}
+    >>> len(d) # no collision
+    2
     >>> 'foo: ?' in d
     False
     >>> l1 = 'foo: \\xe4' # historical latin1 fallback