[pypy-svn] r78895 - in pypy/branch/fast-forward: lib-python/modified-2.7.0/test lib_pypy

afa at codespeak.net afa at codespeak.net
Mon Nov 8 21:55:09 CET 2010


Author: afa
Date: Mon Nov  8 21:55:08 2010
New Revision: 78895

Added:
   pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_deque.py
      - copied, changed from r78894, pypy/branch/fast-forward/lib-python/2.7.0/test/test_deque.py
Modified:
   pypy/branch/fast-forward/lib_pypy/_collections.py
Log:
Fix all tests in test_deque.py


Copied: pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_deque.py (from r78894, pypy/branch/fast-forward/lib-python/2.7.0/test/test_deque.py)
==============================================================================
--- pypy/branch/fast-forward/lib-python/2.7.0/test/test_deque.py	(original)
+++ pypy/branch/fast-forward/lib-python/modified-2.7.0/test/test_deque.py	Mon Nov  8 21:55:08 2010
@@ -505,7 +505,7 @@
                 container = reversed(deque([obj, 1]))
             obj.x = iter(container)
             del obj, container
-            gc.collect()
+            test_support.gc_collect()
             self.assertTrue(ref() is None, "Cycle was not collected")
 
 class TestVariousIteratorArgs(unittest.TestCase):
@@ -621,6 +621,7 @@
         p = weakref.proxy(d)
         self.assertEqual(str(p), str(d))
         d = None
+        test_support.gc_collect()
         self.assertRaises(ReferenceError, str, p)
 
     def test_strange_subclass(self):

Modified: pypy/branch/fast-forward/lib_pypy/_collections.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_collections.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_collections.py	Mon Nov  8 21:55:08 2010
@@ -32,14 +32,19 @@
         return self
 
     def __init__(self, iterable=(), maxlen=None):
+        self.clear()
         if maxlen is not None:
             if maxlen < 0:
                 raise ValueError("maxlen must be non-negative")
-        self.maxlen = maxlen
+        self._maxlen = maxlen
         add = self.append
         for elem in iterable:
             add(elem)
 
+    @property
+    def maxlen(self):
+        return self._maxlen
+
     def clear(self):
         self.right = self.left = [None] * BLOCKSIZ
         self.rightndx = n//2   # points to last written element
@@ -350,6 +355,10 @@
         else:
             return NotImplemented
 
+    def __iadd__(self, other):
+        self.extend(other)
+        return self
+
 class deque_iterator(object):
 
     def __init__(self, deq, itergen):



More information about the Pypy-commit mailing list