changeset 28717:c5f212c8ad78

pypy: 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
author Maciej Fijalkowski <fijall@gmail.com>
date Thu, 31 Mar 2016 18:38:08 +0200
parents 5c14af475f61
children f103f985ac00
files mercurial/revset.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Sat Mar 19 15:31:13 2016 +0100
+++ b/mercurial/revset.py	Thu Mar 31 18:38:08 2016 +0200
@@ -3060,7 +3060,8 @@
 
     iterate unsorted:
     >>> rs = addset(xs, ys)
-    >>> [x for x in rs]  # without _genlist
+    >>> # (use generator because pypy could call len())
+    >>> list(x for x in rs)  # without _genlist
     [0, 3, 2, 5, 4]
     >>> assert not rs._genlist
     >>> len(rs)
@@ -3071,7 +3072,8 @@
 
     iterate ascending:
     >>> rs = addset(xs, ys, ascending=True)
-    >>> [x for x in rs], [x for x in rs.fastasc()]  # without _asclist
+    >>> # (use generator because pypy could call len())
+    >>> 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)
@@ -3082,7 +3084,8 @@
 
     iterate descending:
     >>> rs = addset(xs, ys, ascending=False)
-    >>> [x for x in rs], [x for x in rs.fastdesc()]  # without _asclist
+    >>> # (use generator because pypy could call len())
+    >>> 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)