summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-01-28 22:02:31 (GMT)
committerGuido van Rossum <guido@python.org>2003-01-28 22:02:31 (GMT)
commitc8d6ef5cd621c39434c22123ab4f63e8084c8446 (patch)
tree925d6e833f9308c3efa3f5f6b94ef57e16104758 /Lib/test
parentac5b5d2e8b849c499d323b0263ace22e56b4f0d9 (diff)
downloadcpython-c8d6ef5cd621c39434c22123ab4f63e8084c8446.zip
cpython-c8d6ef5cd621c39434c22123ab4f63e8084c8446.tar.gz
cpython-c8d6ef5cd621c39434c22123ab4f63e8084c8446.tar.bz2
Add a test for a list subclass with a __dict__ as well as slots.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/pickletester.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index cc464a9..36b3702 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -324,12 +324,29 @@ class AbstractPickleTests(unittest.TestCase):
## 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):
pass
class MyList(list):
pass
+class SlotList(MyList):
+ __slots__ = ["foo"]
+
class AbstractPickleModuleTests(unittest.TestCase):
def test_dump_closed_file(self):