Add a test for a list subclass with a __dict__ as well as slots.
This commit is contained in:
parent
ac5b5d2e8b
commit
c8d6ef5cd6
|
@ -322,6 +322,20 @@ class AbstractPickleTests(unittest.TestCase):
|
|||
self.assertEqual(x.__dict__, y.__dict__)
|
||||
## import pickletools
|
||||
## print
|
||||
## pickletools.dis(s)
|
||||
|
||||
def test_newobj_list_slots(self):
|
||||
x = SlotList([1, 2, 3])
|
||||
x.foo = 42
|
||||
x.bar = "hello"
|
||||
s = self.dumps(x, 2)
|
||||
y = self.loads(s)
|
||||
self.assertEqual(list(x), list(y))
|
||||
self.assertEqual(x.__dict__, y.__dict__)
|
||||
self.assertEqual(x.foo, y.foo)
|
||||
self.assertEqual(x.bar, y.bar)
|
||||
## import pickletools
|
||||
## print
|
||||
## pickletools.dis(s)
|
||||
|
||||
class MyTuple(tuple):
|
||||
|
@ -330,6 +344,9 @@ class MyTuple(tuple):
|
|||
class MyList(list):
|
||||
pass
|
||||
|
||||
class SlotList(MyList):
|
||||
__slots__ = ["foo"]
|
||||
|
||||
class AbstractPickleModuleTests(unittest.TestCase):
|
||||
|
||||
def test_dump_closed_file(self):
|
||||
|
|
Loading…
Reference in New Issue