[Python-checkins] python/dist/src/Lib/test test_xpickle.py,NONE,1.1 pickletester.py,1.49,1.50
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 13 Feb 2003 11:30:59 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv5218
Modified Files:
pickletester.py
Added Files:
test_xpickle.py
Log Message:
We didn't have any tests making pickles with one of {pickle, cPickle},
and loading them via the other, except for the special cases of this
Guido added to test_datetime.py for datetime module objects. The new
test_xpickle.py tries all of pickletester's AbstractPickleTests in
both x-module ways.
--- NEW FILE: test_xpickle.py ---
# test_pickle dumps and loads pickles via pickle.py.
# test_cpickle does the same, but via the cPickle module.
# This test covers the other two cases, making pickles with one module and
# loading them via the other.
import pickle
import cPickle
import unittest
from cStringIO import StringIO
from test import test_support
from test.pickletester import AbstractPickleTests
class DumpCPickle_LoadPickle(AbstractPickleTests):
error = KeyError
def dumps(self, arg, proto=0, fast=0):
# Ignore fast
return cPickle.dumps(arg, proto)
def loads(self, buf):
# Ignore fast
return pickle.loads(buf)
class DumpPickle_LoadCPickle(AbstractPickleTests):
error = cPickle.BadPickleGet
def dumps(self, arg, proto=0, fast=0):
# Ignore fast
return pickle.dumps(arg, proto)
def loads(self, buf):
# Ignore fast
return cPickle.loads(buf)
def test_main():
suite = unittest.TestSuite()
for test in (DumpCPickle_LoadPickle,
DumpPickle_LoadCPickle,
):
suite.addTest(unittest.makeSuite(test))
test_support.run_suite(suite)
if __name__ == "__main__":
test_main()
Index: pickletester.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/pickletester.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** pickletester.py 13 Feb 2003 18:42:00 -0000 1.49
--- pickletester.py 13 Feb 2003 19:30:57 -0000 1.50
***************
*** 807,810 ****
--- 807,815 ----
os.remove(TESTFN)
+ def test_highest_protocol(self):
+ # Of course this needs to be changed when HIGHEST_PROTOCOL changes.
+ self.assertEqual(self.module.HIGHEST_PROTOCOL, 2)
+
+
class AbstractPersistentPicklerTests(unittest.TestCase):