diff options
author | Raymond Hettinger <python@rcn.com> | 2007-04-02 17:03:46 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-04-02 17:03:46 +0000 |
commit | 4bbcb64d5d6560d8adca119f153779d0d18e0482 (patch) | |
tree | 58a0483b84fe97c377db57c5b508d3038307883f /Lib/test/test_array.py | |
parent | 93e938440213c9e032b4c4e1af6bb20a1ce644a1 (diff) | |
download | cpython-git-4bbcb64d5d6560d8adca119f153779d0d18e0482.tar.gz |
SF #1693079 Array module cannot pickle empty arrays
Diffstat (limited to 'Lib/test/test_array.py')
-rwxr-xr-x | Lib/test/test_array.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 63e7f4ebb6..597f3b2421 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]) |