summaryrefslogtreecommitdiff
path: root/test/ext/test_mutable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-12-11 11:21:46 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-12-11 11:21:46 -0500
commit5710a1e88bf669227959ca950b56d1072520b255 (patch)
tree6950c347704c1e0620904ddabedde9ce4160a924 /test/ext/test_mutable.py
parent741b8af31bb436356b9e8950c045761a0e054fe0 (diff)
downloadsqlalchemy-5710a1e88bf669227959ca950b56d1072520b255.tar.gz
- Added support for the ``dict.pop()`` and ``dict.popitem()`` methods
to the :class:`.mutable.MutableDict` class. fixes #3605
Diffstat (limited to 'test/ext/test_mutable.py')
-rw-r--r--test/ext/test_mutable.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ext/test_mutable.py b/test/ext/test_mutable.py
index a6bcdc47f..ed97a0d92 100644
--- a/test/ext/test_mutable.py
+++ b/test/ext/test_mutable.py
@@ -136,6 +136,38 @@ class _MutableDictTestBase(_MutableDictTestFixture):
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()