All pastes #749750 Raw Edit

Miscellany

public text v1 · immutable
#749750 ·published 2007-10-25 22:03 UTC
rendered paste body
Index: test/orm/collection.py
===================================================================
--- test/orm/collection.py      (revision 3659)
+++ test/orm/collection.py      (working copy)
@@ -274,10 +274,35 @@
             self.assert_(e4 not in canary.data)
             self.assert_(e3 in canary.data)
 
+    def _test_list_slice(self, typecallable, creator=entity_maker):
+        class Foo(object):
+            pass
+        canary = Canary()
+        manager.register_class(Foo)
+        manager.register_attribute(Foo, 'attr', True, extension=canary,
+                                   typecallable=typecallable)
+        
+        obj = Foo()
+        e1 = creator()
+        e2 = creator()
+        e3 = creator()
+        obj.attr = [e1, e2, e3]
+        assert e1 in canary.added
+        assert e2 in canary.added
+        assert e3 in canary.added
+
+        obj.attr = obj.attr[1:]
+        assert e1 in canary.removed
+        assert e2 in canary.added
+        assert e3 in canary.added
+        assert e2 not in canary.removed
+        assert e3 not in canary.removed
+
     def test_list(self):
         self._test_adapter(list)
         self._test_list(list)
         self._test_list_bulk(list)
+        self._test_list_slice(list)
 
     def test_list_subclass(self):
         class MyList(list):