summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-11-24 13:33:37 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-11-24 13:33:37 (GMT)
commit3ab9cfc50101f46ac31e4b85e1779e5b7492d158 (patch)
tree6210cdb891be4b7ad42a18d5e51952c1da0354f7 /Lib
parentdc6aaec9e3698738ede81f4bcc1ee3815dde0231 (diff)
downloadcpython-3ab9cfc50101f46ac31e4b85e1779e5b7492d158.zip
cpython-3ab9cfc50101f46ac31e4b85e1779e5b7492d158.tar.gz
cpython-3ab9cfc50101f46ac31e4b85e1779e5b7492d158.tar.bz2
Selectively re-enable framing tests
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pickletester.py30
-rw-r--r--Lib/test/test_pickletools.py2
2 files changed, 21 insertions, 11 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index c33571b..1542d42 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -438,6 +438,8 @@ def create_data():
class AbstractPickleTests(unittest.TestCase):
# Subclass must define self.dumps, self.loads.
+ optimized = False
+
_testdata = create_data()
def setUp(self):
@@ -1334,13 +1336,16 @@ class AbstractPickleTests(unittest.TestCase):
self.assertEqual(obj, unpickled)
# Test the framing heuristic is sane,
# assuming a given frame size target.
- # XXX Assumptions here are wrong when the pickle are optimized
- # bytes_per_frame = (len(pickled) /
- # count_opcode(pickle.FRAME, pickled))
- # self.assertGreater(bytes_per_frame,
- # self.FRAME_SIZE_TARGET / 2)
- # self.assertLessEqual(bytes_per_frame,
- # self.FRAME_SIZE_TARGET * 1)
+ if self.optimized:
+ # These assumptions are currently invalid for optimized
+ # pickles (see e.g. issue19754).
+ continue
+ bytes_per_frame = (len(pickled) /
+ count_opcode(pickle.FRAME, pickled))
+ self.assertGreater(bytes_per_frame,
+ self.FRAME_SIZE_TARGET / 2)
+ self.assertLessEqual(bytes_per_frame,
+ self.FRAME_SIZE_TARGET * 1)
def test_framing_large_objects(self):
N = 1024 * 1024
@@ -1350,10 +1355,13 @@ class AbstractPickleTests(unittest.TestCase):
pickled = self.dumps(obj, proto)
unpickled = self.loads(pickled)
self.assertEqual(obj, unpickled)
- # At least one frame was emitted per large bytes object.
- # XXX Assumptions here are wrong when the pickle are optimized
- # n_frames = count_opcode(pickle.FRAME, pickled)
- # self.assertGreaterEqual(n_frames, len(obj))
+ n_frames = count_opcode(pickle.FRAME, pickled)
+ if self.optimized:
+ # At least one frame was emitted (see issue19754).
+ self.assertGreaterEqual(n_frames, 1)
+ else:
+ # At least one frame was emitted per large bytes object.
+ self.assertGreaterEqual(n_frames, len(obj))
def test_optional_frames(self):
if pickle.HIGHEST_PROTOCOL < 4:
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
index d37ac26..029b5b1 100644
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -6,6 +6,8 @@ from test.pickletester import AbstractPickleModuleTests
class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
+ optimized = True
+
def dumps(self, arg, proto=None):
return pickletools.optimize(pickle.dumps(arg, proto))