[PATCH] tests: fix doctests for pypy optimizations

Maciej Fijalkowski fijall at gmail.com
Thu Mar 31 12:38:21 EDT 2016


# HG changeset patch
# User Maciej Fijalkowski <fijall at gmail.com>
# Date 1459442288 -7200
#      Thu Mar 31 18:38:08 2016 +0200
# Node ID 9ca7854b963295b8b56d276b903623ac8277f18d
# Parent  eaaeff1b98571b90ec71614c75126e64e98c004b
tests: fix doctests for pypy optimizations

PyPy would sometime call __len__ at points where it things preallocating
the container makes sense. Change the doctests so they're using generator
expressions and not list comprehensions

diff -r eaaeff1b9857 -r 9ca7854b9632 mercurial/revset.py
--- a/mercurial/revset.py	Thu Mar 31 16:44:25 2016 +0200
+++ b/mercurial/revset.py	Thu Mar 31 18:38:08 2016 +0200
@@ -3124,7 +3124,7 @@
 
     iterate unsorted:
     >>> rs = addset(xs, ys)
-    >>> [x for x in rs]  # without _genlist
+    >>> list(x for x in rs)  # without _genlist
     [0, 3, 2, 5, 4]
     >>> assert not rs._genlist
     >>> len(rs)
@@ -3135,7 +3135,7 @@
 
     iterate ascending:
     >>> rs = addset(xs, ys, ascending=True)
-    >>> [x for x in rs], [x for x in rs.fastasc()]  # without _asclist
+    >>> list(x for x in rs), list(x for x in rs.fastasc())  # without _asclist
     ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
     >>> assert not rs._asclist
     >>> len(rs)
@@ -3146,7 +3146,7 @@
 
     iterate descending:
     >>> rs = addset(xs, ys, ascending=False)
-    >>> [x for x in rs], [x for x in rs.fastdesc()]  # without _asclist
+    >>> list(x for x in rs), list(x for x in rs.fastdesc())  # without _asclist
     ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
     >>> assert not rs._asclist
     >>> len(rs)


More information about the Mercurial-devel mailing list