Commit e3d4f56a authored by Tres Seaver's avatar Tres Seaver

Merge branch 'setstate' of https://github.com/NextThought/persistent into NextThought-setstate

parents ffa62bf2 dfc9823e
......@@ -288,9 +288,9 @@ class Persistent(object):
def __setstate__(self, state):
""" See IPersistent.
"""
try:
if isinstance(state,tuple):
inst_dict, slots = state
except:
else:
inst_dict, slots = state, ()
idict = getattr(self, '__dict__', None)
if inst_dict is not None:
......
......@@ -789,6 +789,14 @@ class _Persistent_Base(object):
inst.__setstate__({'baz': 'bam'})
self.assertEqual(inst.__dict__, {'baz': 'bam'})
def test___setstate___nonempty_derived_w_dict_w_two_keys(self):
class Derived(self._getTargetClass()):
pass
inst = Derived()
inst.foo = 'bar'
inst.__setstate__({'baz': 'bam', 'biz': 'boz'})
self.assertEqual(inst.__dict__, {'baz': 'bam', 'biz': 'boz'})
def test___setstate___derived_w_slots(self):
class Derived(self._getTargetClass()):
__slots__ = ('foo', '_p_baz', '_v_qux')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment