dict.update(self, *a, **kw)
self.changed()
+ def pop(self, key):
+ result = dict.pop(self, key)
+ self.changed()
+ return result
+
+ def popitem(self):
+ result = dict.popitem(self)
+ self.changed()
+ return result
+
def clear(self):
dict.clear(self)
self.changed()
eq_(f1.data, {'a': 'z'})
+ def test_pop(self):
+ sess = Session()
+
+ f1 = Foo(data={'a': 'b', 'c': 'd'})
+ sess.add(f1)
+ sess.commit()
+
+ eq_(f1.data.pop('a'), 'b')
+ sess.commit()
+
+ eq_(f1.data, {'c': 'd'})
+
+ def test_popitem(self):
+ sess = Session()
+
+ orig = {'a': 'b', 'c': 'd'}
+
+ # the orig dict remains unchanged when we assign,
+ # but just making this future-proof
+ data = dict(orig)
+ f1 = Foo(data=data)
+ sess.add(f1)
+ sess.commit()
+
+ k, v = f1.data.popitem()
+ assert k in ('a', 'c')
+ orig.pop(k)
+
+ sess.commit()
+
+ eq_(f1.data, orig)
+
def test_setdefault(self):
sess = Session()