summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-07-20 00:22:32 (GMT)
committerGuido van Rossum <guido@python.org>2007-07-20 00:22:32 (GMT)
commit99603b0c1edb4b8ca2a30fa90470170b959321ee (patch)
treef0fef33a9c03529354c01f5fd374fd36ebc024d7 /Lib/test/test_descr.py
parentbe6fe5476cc3233ac20e02c0063355a5884663f7 (diff)
downloadcpython-99603b0c1edb4b8ca2a30fa90470170b959321ee.zip
cpython-99603b0c1edb4b8ca2a30fa90470170b959321ee.tar.gz
cpython-99603b0c1edb4b8ca2a30fa90470170b959321ee.tar.bz2
Getting rid of cPickle. Mmm, feels good!
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py31
1 files changed, 2 insertions, 29 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 110e3a8..8e57b90 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -2807,10 +2807,6 @@ def pickles():
if verbose:
print("Testing pickling and copying new-style classes and objects...")
import pickle
- try:
- import cPickle
- except ImportError:
- cPickle = None
def sorteditems(d):
return sorted(d.items())
@@ -2863,9 +2859,7 @@ def pickles():
class C4(C4classic, object): # mixed inheritance
pass
- for p in pickle, cPickle:
- if p is None:
- continue # cPickle not found -- skip it
+ for p in [pickle]:
for bin in 0, 1:
if verbose:
print(p.__name__, ["text", "binary"][bin])
@@ -2925,7 +2919,7 @@ def pickles():
def pickleslots():
if verbose: print("Testing pickling of classes with __slots__ ...")
- import pickle, pickle as cPickle
+ import pickle
# Pickling of classes with __slots__ but without __getstate__ should fail
# (when using protocols 0 or 1)
global B, C, D, E
@@ -2943,23 +2937,11 @@ def pickleslots():
else:
raise TestFailed, "should fail: pickle C instance - %s" % base
try:
- cPickle.dumps(C(), 0)
- except TypeError:
- pass
- else:
- raise TestFailed, "should fail: cPickle C instance - %s" % base
- try:
pickle.dumps(C(), 0)
except TypeError:
pass
else:
raise TestFailed, "should fail: pickle D instance - %s" % base
- try:
- cPickle.dumps(D(), 0)
- except TypeError:
- pass
- else:
- raise TestFailed, "should fail: cPickle D instance - %s" % base
# Give C a nice generic __getstate__ and __setstate__
class C(base):
__slots__ = ['a']
@@ -2984,20 +2966,14 @@ def pickleslots():
x = C()
y = pickle.loads(pickle.dumps(x))
vereq(hasattr(y, 'a'), 0)
- y = cPickle.loads(cPickle.dumps(x))
- vereq(hasattr(y, 'a'), 0)
x.a = 42
y = pickle.loads(pickle.dumps(x))
vereq(y.a, 42)
- y = cPickle.loads(cPickle.dumps(x))
- vereq(y.a, 42)
x = D()
x.a = 42
x.b = 100
y = pickle.loads(pickle.dumps(x))
vereq(y.a + y.b, 142)
- y = cPickle.loads(cPickle.dumps(x))
- vereq(y.a + y.b, 142)
# A subclass that adds a slot should also work
class E(C):
__slots__ = ['b']
@@ -3007,9 +2983,6 @@ def pickleslots():
y = pickle.loads(pickle.dumps(x))
vereq(y.a, x.a)
vereq(y.b, x.b)
- y = cPickle.loads(cPickle.dumps(x))
- vereq(y.a, x.a)
- vereq(y.b, x.b)
def copies():
if verbose: print("Testing copy.copy() and copy.deepcopy()...")