Commit 8ae7a5c1 authored by Tres Seaver's avatar Tres Seaver

Suppress protocol 3 pickle tests on Python2.

parent 935be033
...@@ -14,7 +14,12 @@ ...@@ -14,7 +14,12 @@
try: try:
# Python 2.x # Python 2.x
from cPickle import Pickler, Unpickler, dump, dumps, loads from cPickle import Pickler
from cPickle import Unpickler
from cPickle import dump
from cPickle import dumps
from cPickle import loads
from cPickle import HIGHEST_PROTOCOL
IMPORT_MAPPING = {} IMPORT_MAPPING = {}
NAME_MAPPING = {} NAME_MAPPING = {}
_protocol = 1 _protocol = 1
...@@ -22,6 +27,7 @@ except ImportError: ...@@ -22,6 +27,7 @@ except ImportError:
# Python 3.x: can't use stdlib's pickle because # Python 3.x: can't use stdlib's pickle because
# http://bugs.python.org/issue6784 # http://bugs.python.org/issue6784
import zodbpickle.pickle import zodbpickle.pickle
HIGHEST_PROTOCOL = 3
from _compat_pickle import IMPORT_MAPPING, NAME_MAPPING from _compat_pickle import IMPORT_MAPPING, NAME_MAPPING
class Pickler(zodbpickle.pickle.Pickler): class Pickler(zodbpickle.pickle.Pickler):
......
...@@ -122,9 +122,11 @@ class TestUtils(unittest.TestCase): ...@@ -122,9 +122,11 @@ class TestUtils(unittest.TestCase):
def test_get_pickle_metadata_w_protocol_3_class_pickle(self): def test_get_pickle_metadata_w_protocol_3_class_pickle(self):
from ZODB.utils import get_pickle_metadata from ZODB.utils import get_pickle_metadata
from ZODB._compat import dumps from ZODB._compat import dumps
pickle = dumps(ExampleClass, protocol=3) from ZODB._compat import HIGHEST_PROTOCOL
self.assertEqual(get_pickle_metadata(pickle), if HIGHEST_PROTOCOL >= 3:
(__name__, ExampleClass.__name__)) pickle = dumps(ExampleClass, protocol=3)
self.assertEqual(get_pickle_metadata(pickle),
(__name__, ExampleClass.__name__))
class ExampleClass(object): class ExampleClass(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment