1 # Test the cPickle module
34 BINDATA
= ']q\000(K\000L1L\012G@\000\000\000\000\000\000\000c__builtin__\012complex\012q\001(G@\010\000\000\000\000\000\000G\000\000\000\000\000\000\000\000tq\002Rq\003(U\003abcq\004h\004(c__main__\012C\012q\005oq\006}q\007(U\003fooq\010K\001U\003barq\011K\002ubh\006tq\012h\012K\005e.'
39 def __cmp__(self
, other
):
40 return cmp(self
.__dict
__, other
.__dict
__)
49 x
= [0, 1L, 2.0, 3.0+0j
]
50 y
= ('abc', 'abc', c
, c
)
58 if x2
== x
: print "ok"
61 x2
= cPickle
.loads(DATA
)
62 if x2
== x
: print "ok"
64 print "dumps() binary"
65 s
= cPickle
.dumps(x
, 1)
66 print "loads() binary"
68 if x2
== x
: print "ok"
70 print "loads() BINDATA"
71 x2
= cPickle
.loads(BINDATA
)
72 if x2
== x
: print "ok"
75 # Test protection against closed files
77 fn
= tempfile
.mktemp()
85 print "dump to closed file should raise IOError"
93 print "load from closed file should raise IOError"