[PATCH 09 of 11] doctest: coerce dict.keys() to list

Yuya Nishihara yuya at tcha.org
Mon Sep 4 11:08:28 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1504427590 -32400
#      Sun Sep 03 17:33:10 2017 +0900
# Node ID 5fad368006e59fa11da06cc92c181e2f399041c7
# Parent  7c2661eb481b2c4110a071a26e20e07ab831a175
doctest: coerce dict.keys() to list

Otherwise it would be printed as odict_keys([...]) on Python 3.

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -489,10 +489,10 @@ def _buildfuncargs(exp, context, curmeth
     ...     x = _parseexpr(expr)
     ...     n = getsymbol(x[1])
     ...     return _buildfuncargs(x[2], context, exprmethods, n, argspec)
-    >>> fargs(b'a(l=1, k=2)', b'k l m').keys()
+    >>> list(fargs(b'a(l=1, k=2)', b'k l m').keys())
     ['l', 'k']
     >>> args = fargs(b'a(opts=1, k=2)', b'**opts')
-    >>> args.keys(), args[b'opts'].keys()
+    >>> list(args.keys()), list(args[b'opts'].keys())
     (['opts'], ['opts', 'k'])
     """
     def compiledict(xs):
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -584,7 +584,7 @@ class sortdict(collections.OrderedDict):
     >>> d2
     sortdict([('a', 0), ('b', 1)])
     >>> d2.update([(b'a', 2)])
-    >>> d2.keys() # should still be in last-set order
+    >>> list(d2.keys()) # should still be in last-set order
     ['b', 'a']
     '''
 


More information about the Mercurial-devel mailing list