[Checkins] SVN: Acquisition/trunk/src/Acquisition/tests.py first add [https://bugs.launchpad.net/zope2/+bug/360761/comments/7 the tests] kindly provided by Tres

Andreas Zeidler az at zitc.de
Thu Oct 29 05:18:40 EDT 2009


Log message for revision 105349:
  first add [https://bugs.launchpad.net/zope2/+bug/360761/comments/7 the tests] kindly provided by Tres

Changed:
  U   Acquisition/trunk/src/Acquisition/tests.py

-=-
Modified: Acquisition/trunk/src/Acquisition/tests.py
===================================================================
--- Acquisition/trunk/src/Acquisition/tests.py	2009-10-29 08:14:25 UTC (rev 105348)
+++ Acquisition/trunk/src/Acquisition/tests.py	2009-10-29 09:18:40 UTC (rev 105349)
@@ -1834,9 +1834,37 @@
     >>> list(c2)
     [1, 2, 3]
 
+    The __iter__proxy should also pass the wrapped object as self to
+    the __iter__ of objects defining __iter__::
+
+    >>> class C(Acquisition.Implicit):
+    ...     def __iter__(self):
+    ...         print 'iterating...'
+    ...         for i in range(5):
+    ...             yield i, self.aq_parent.name
+    >>> c = C()
+    >>> i = Impl()
+    >>> i.c = c
+    >>> i.name = 'i'
+    >>> list(i.c)
+    iterating...
+    [(0, 'i'), (1, 'i'), (2, 'i'), (3, 'i'), (4, 'i')]
+
+    And it should pass the wrapped object as self to
+    the __getitem__ of objects without an __iter__::
+
+    >>> class C(Acquisition.Implicit):
+    ...     def __getitem__(self, i):
+    ...         return self.aq_parent.l[i]
+    >>> c = C()
+    >>> i = Impl()
+    >>> i.c = c
+    >>> i.l = range(5)
+    >>> list(i.c)
+    [0, 1, 2, 3, 4]
+
     """
 
-
 class Location(object):
     __parent__ = None
  



More information about the checkins mailing list