Add a test for a list subclass with a __dict__ as well as slots.

This commit is contained in:
Guido van Rossum 2003-01-28 22:02:31 +00:00
parent ac5b5d2e8b
commit c8d6ef5cd6
1 changed files with 17 additions and 0 deletions

View File

@ -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):