summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2007-04-02 17:29:30 (GMT)
committerRaymond Hettinger <python@rcn.com>2007-04-02 17:29:30 (GMT)
commite6e660bde384b21ee41a5b9f6dbbd2bc1bb2ae6b (patch)
treec5e3fc664ea594af562e90a49537f7e0219e7fa3 /Lib
parent5447850f6fec4445c0a2a84a5364e7c52940e8c9 (diff)
downloadcpython-e6e660bde384b21ee41a5b9f6dbbd2bc1bb2ae6b.zip
cpython-e6e660bde384b21ee41a5b9f6dbbd2bc1bb2ae6b.tar.gz
cpython-e6e660bde384b21ee41a5b9f6dbbd2bc1bb2ae6b.tar.bz2
SF #1693079: Cannot save empty array in shelve
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/test_array.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 63e7f4e..597f3b2 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -111,6 +111,21 @@ class BaseTest(unittest.TestCase):
self.assertEqual(a.x, b.x)
self.assertEqual(type(a), type(b))
+ def test_pickle_for_empty_array(self):
+ for protocol in (0, 1, 2):
+ a = array.array(self.typecode)
+ b = loads(dumps(a, protocol))
+ self.assertNotEqual(id(a), id(b))
+ self.assertEqual(a, b)
+
+ a = ArraySubclass(self.typecode)
+ a.x = 10
+ b = loads(dumps(a, protocol))
+ self.assertNotEqual(id(a), id(b))
+ self.assertEqual(a, b)
+ self.assertEqual(a.x, b.x)
+ self.assertEqual(type(a), type(b))
+
def test_insert(self):
a = array.array(self.typecode, self.example)
a.insert(0, self.example[0])