<s> import cPickle <EOL> import unittest <EOL> from cStringIO import StringIO <EOL> from test . pickletester import AbstractPickleTests , AbstractPickleModuleTests <EOL> from test import test_support <EOL> class cPickleTests ( AbstractPickleTests , AbstractPickleModuleTests ) : <EOL> def setUp ( self ) : <EOL> self . dumps = cPickle . dumps <EOL> self . loads = cPickle . loads <EOL> error = cPickle . BadPickleGet <EOL> module = cPickle <EOL> class cPicklePicklerTests ( AbstractPickleTests ) : <EOL> def dumps ( self , arg , proto = <NUM_LIT:0> ) : <EOL> f = StringIO ( ) <EOL> p = cPickle . Pickler ( f , proto ) <EOL> p . dump ( arg ) <EOL> f . seek ( <NUM_LIT:0> ) <EOL> return f . read ( ) <EOL> def loads ( self , buf ) : <EOL> f = StringIO ( buf ) <EOL> p = cPickle . Unpickler ( f ) <EOL> return p . load ( ) <EOL> error = cPickle . BadPickleGet <EOL> class cPickleListPicklerTests ( AbstractPickleTests ) : <EOL> def dumps ( self , arg , proto = <NUM_LIT:0> ) : <EOL> p = cPickle . Pickler ( proto ) <EOL> p . dump ( arg ) <EOL> return p . getvalue ( ) <EOL> def loads ( self , * args ) : <EOL> f = StringIO ( args [ <NUM_LIT:0> ] ) <EOL> p = cPickle . Unpickler ( f ) <EOL> return p . load ( ) <EOL> error = cPickle . BadPickleGet <EOL> class cPickleFastPicklerTests ( AbstractPickleTests ) : <EOL> def dumps ( self , arg , proto = <NUM_LIT:0> ) : <EOL> f = StringIO ( ) <EOL> p = cPickle . Pickler ( f , proto ) <EOL> p . fast = <NUM_LIT:1> <EOL> p . dump ( arg ) <EOL> f . seek ( <NUM_LIT:0> ) <EOL> return f . read ( ) <EOL> def loads ( self , * args ) : <EOL> f = StringIO ( args [ <NUM_LIT:0> ] ) <EOL> p = cPickle . Unpickler ( f ) <EOL> return p . load ( ) <EOL> error = cPickle . BadPickleGet <EOL> def test_recursive_list ( self ) : <EOL> self . assertRaises ( ValueError , <EOL> AbstractPickleTests . test_recursive_list , <EOL> self ) <EOL> def test_recursive_inst ( self ) : <EOL> self . assertRaises ( ValueError , <EOL> AbstractPickleTests . test_recursive_inst , <EOL> self ) <EOL> def test_recursive_dict ( self ) : <EOL> self . assertRaises ( ValueError , <EOL> AbstractPickleTests . test_recursive_dict , <EOL> self ) <EOL> def test_recursive_multi ( self ) : <EOL> self . assertRaises ( ValueError , <EOL> AbstractPickleTests . test_recursive_multi , <EOL> self ) <EOL> def test_nonrecursive_deep ( self ) : <EOL> a = [ ] <EOL> for i in range ( <NUM_LIT> ) : <EOL> a = [ a ] <EOL> b = self . loads ( self . dumps ( a ) ) <EOL> self . assertEqual ( a , b ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( <EOL> cPickleTests , <EOL> cPicklePicklerTests , <EOL> cPickleListPicklerTests , <EOL> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
