From: Jason Kirtland Date: Wed, 18 Jul 2007 22:19:12 +0000 (+0000) Subject: .pop() on association proxies is no longer problematic with 0.4 collections. X-Git-Tag: rel_0_4_6~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25a5468f4f4d16fc7e616c4f14d137448bc6dd06;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git .pop() on association proxies is no longer problematic with 0.4 collections. --- diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index b077a433a7..0330a679f8 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -302,6 +302,9 @@ class _AssociationList(object): def insert(self, index, value): self.col[index:index] = [self._create(value)] + def pop(self, index=-1): + return self.getter(self.col.pop(index)) + def clear(self): del self.col[0:len(self.col)] diff --git a/test/ext/associationproxy.py b/test/ext/associationproxy.py index 9b83830ca5..3156e42923 100644 --- a/test/ext/associationproxy.py +++ b/test/ext/associationproxy.py @@ -138,6 +138,13 @@ class _CollectionOperations(PersistTest): self.assert_(len(p1._children) == 3) self.assert_(len(p1.children) == 3) + popped = p1.children.pop() + self.assert_(len(p1.children) == 2) + self.assert_(popped not in p1.children) + p1 = self.roundtrip(p1) + self.assert_(len(p1.children) == 2) + self.assert_(popped not in p1.children) + p1.children[1] = 'changed-in-place' self.assert_(p1.children[1] == 'changed-in-place') inplace_id = p1._children[1].id @@ -435,14 +442,7 @@ class SetTest(_CollectionOperations): print 'want', repr(control) print 'got', repr(p.children) raise - - # workaround for bug #548 - def test_set_pop(self): - Parent, Child = self.Parent, self.Child - p = Parent('p1') - p.children.add('a') - p.children.pop() - self.assert_(True) + class CustomSetTest(SetTest): def __init__(self, *args, **kw):