diff options
Diffstat (limited to 'test/ext/test_mutable.py')
-rw-r--r-- | test/ext/test_mutable.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/test/ext/test_mutable.py b/test/ext/test_mutable.py index 129a460b0..60576f007 100644 --- a/test/ext/test_mutable.py +++ b/test/ext/test_mutable.py @@ -17,6 +17,13 @@ class Foo(fixtures.BasicEntity): class SubFoo(Foo): pass +class FooWithEq(object): + def __init__(self, **kw): + for k in kw: + setattr(self, k, kw[k]) + def __eq__(self, other): + return self.id == other.id + class _MutableDictTestBase(object): run_define_tables = 'each' @@ -317,12 +324,10 @@ class _CompositeTestBase(object): return self.x, self.y def __getstate__(self): - d = dict(self.__dict__) - d.pop('_parents', None) - return d + return self.x, self.y - #def __setstate__(self, state): - # self.x, self.y = state + def __setstate__(self, state): + self.x, self.y = state def __eq__(self, other): return isinstance(other, Point) and \ @@ -330,6 +335,23 @@ class _CompositeTestBase(object): other.y == self.y return Point +class MutableCompositesUnpickleTest(_CompositeTestBase, fixtures.MappedTest): + + @classmethod + def setup_mappers(cls): + foo = cls.tables.foo + + cls.Point = cls._type_fixture() + + mapper(FooWithEq, foo, properties={ + 'data':composite(cls.Point, foo.c.x, foo.c.y) + }) + + def test_unpickle_modified_eq(self): + u1 = FooWithEq(data=self.Point(3, 5)) + for loads, dumps in picklers(): + loads(dumps(u1)) + class MutableCompositesTest(_CompositeTestBase, fixtures.MappedTest): @classmethod |