mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Port r71408 to py3k: issue 5665, add more pickling tests.
This commit is contained in:
parent
f4ac1494dc
commit
771d8341cd
2 changed files with 168 additions and 9 deletions
|
@ -6,6 +6,7 @@ from test import support
|
|||
from test.pickletester import AbstractPickleTests
|
||||
from test.pickletester import AbstractPickleModuleTests
|
||||
from test.pickletester import AbstractPersistentPicklerTests
|
||||
from test.pickletester import AbstractPicklerUnpicklerObjectTests
|
||||
|
||||
try:
|
||||
import _pickle
|
||||
|
@ -60,6 +61,12 @@ class PyPersPicklerTests(AbstractPersistentPicklerTests):
|
|||
return u.load()
|
||||
|
||||
|
||||
class PyPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
|
||||
|
||||
pickler_class = pickle._Pickler
|
||||
unpickler_class = pickle._Unpickler
|
||||
|
||||
|
||||
if has_c_implementation:
|
||||
class CPicklerTests(PyPicklerTests):
|
||||
pickler = _pickle.Pickler
|
||||
|
@ -69,11 +76,26 @@ if has_c_implementation:
|
|||
pickler = _pickle.Pickler
|
||||
unpickler = _pickle.Unpickler
|
||||
|
||||
class CDumpPickle_LoadPickle(PyPicklerTests):
|
||||
pickler = _pickle.Pickler
|
||||
unpickler = pickle._Unpickler
|
||||
|
||||
class DumpPickle_CLoadPickle(PyPicklerTests):
|
||||
pickler = pickle._Pickler
|
||||
unpickler = _pickle.Unpickler
|
||||
|
||||
class CPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
|
||||
pickler_class = _pickle.Pickler
|
||||
unpickler_class = _pickle.Unpickler
|
||||
|
||||
|
||||
def test_main():
|
||||
tests = [PickleTests, PyPicklerTests, PyPersPicklerTests]
|
||||
if has_c_implementation:
|
||||
tests.extend([CPicklerTests, CPersPicklerTests])
|
||||
tests.extend([CPicklerTests, CPersPicklerTests,
|
||||
CDumpPickle_LoadPickle, DumpPickle_CLoadPickle,
|
||||
PyPicklerUnpicklerObjectTests,
|
||||
CPicklerUnpicklerObjectTests])
|
||||
support.run_unittest(*tests)
|
||||
support.run_doctest(pickle)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue