summaryrefslogtreecommitdiffstats
path: root/Lib/test/pickletester.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2013-11-30 21:55:39 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2013-11-30 21:55:39 (GMT)
commita1eedf9ff0c986f99321ffef8a65b153c126b86a (patch)
tree9f0eddfe5fc5721474e244afe38c416c9fde360f /Lib/test/pickletester.py
parent6fe39b76a9b353ad619108ad2877a155680270dc (diff)
parent896414fedf5e882345aca177d63da72bf6d8209a (diff)
downloadcpython-a1eedf9ff0c986f99321ffef8a65b153c126b86a.zip
cpython-a1eedf9ff0c986f99321ffef8a65b153c126b86a.tar.gz
cpython-a1eedf9ff0c986f99321ffef8a65b153c126b86a.tar.bz2
Merge with 3.3.
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r--Lib/test/pickletester.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 1542d42..12b6c8f 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1785,30 +1785,34 @@ class AbstractPersistentPicklerTests(unittest.TestCase):
if isinstance(object, int) and object % 2 == 0:
self.id_count += 1
return str(object)
+ elif object == "test_false_value":
+ self.false_count += 1
+ return ""
else:
return None
def persistent_load(self, oid):
- self.load_count += 1
- object = int(oid)
- assert object % 2 == 0
- return object
+ if not oid:
+ self.load_false_count += 1
+ return "test_false_value"
+ else:
+ self.load_count += 1
+ object = int(oid)
+ assert object % 2 == 0
+ return object
def test_persistence(self):
- self.id_count = 0
- self.load_count = 0
- L = list(range(10))
- self.assertEqual(self.loads(self.dumps(L)), L)
- self.assertEqual(self.id_count, 5)
- self.assertEqual(self.load_count, 5)
-
- def test_bin_persistence(self):
- self.id_count = 0
- self.load_count = 0
- L = list(range(10))
- self.assertEqual(self.loads(self.dumps(L, 1)), L)
- self.assertEqual(self.id_count, 5)
- self.assertEqual(self.load_count, 5)
+ L = list(range(10)) + ["test_false_value"]
+ for proto in protocols:
+ self.id_count = 0
+ self.false_count = 0
+ self.load_false_count = 0
+ self.load_count = 0
+ self.assertEqual(self.loads(self.dumps(L, proto)), L)
+ self.assertEqual(self.id_count, 5)
+ self.assertEqual(self.false_count, 1)
+ self.assertEqual(self.load_count, 5)
+ self.assertEqual(self.load_false_count, 1)
class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):