<s> import os <EOL> from lxml import etree <EOL> from cPickle import dumps , loads <EOL> from nose . tools import eq_ <EOL> import helpers <EOL> HERE = os . path . dirname ( __file__ ) <EOL> lw = zf = None <EOL> def setup ( ) : <EOL> global lw , zf <EOL> lwclient , zfclient , bzclient = helpers . generate_static_clients ( ) <EOL> lw = lwclient . Client ( ) <EOL> zf = zfclient . Client ( ) <EOL> def test_pickle_and_unpickle_single_type ( ) : <EOL> album = lw . type . AlbumResult ( <EOL> artist = '<STR_LIT>' , <EOL> album = '<STR_LIT>' , <EOL> year = <NUM_LIT> ) <EOL> eq_ ( album . year , <NUM_LIT> ) <EOL> eq_ ( album . artist , '<STR_LIT>' ) <EOL> eq_ ( album . album , '<STR_LIT>' ) <EOL> pickled_album = dumps ( album ) <EOL> unpickled_album = loads ( pickled_album ) <EOL> eq_ ( unpickled_album . year , <NUM_LIT> ) <EOL> eq_ ( unpickled_album . artist , '<STR_LIT>' ) <EOL> eq_ ( unpickled_album . album , '<STR_LIT>' ) <EOL> repickled = dumps ( unpickled_album ) <EOL> reunpickled_album = loads ( repickled ) <EOL> eq_ ( reunpickled_album . year , <NUM_LIT> ) <EOL> eq_ ( reunpickled_album . artist , '<STR_LIT>' ) <EOL> eq_ ( reunpickled_album . album , '<STR_LIT>' ) <EOL> repickled_same = dumps ( album ) <EOL> reunpickled_same = loads ( repickled_same ) <EOL> def test_pickle_unpickle_deep_type ( ) : <EOL> v = etree . fromstring ( <EOL> '<STR_LIT>' ) <EOL> ifn = zf . type . Address ( v ) . FirstName <EOL> eq_ ( str ( ifn ) , '<STR_LIT>' ) <EOL> pickled_ifn = dumps ( ifn ) <EOL> unpickled_ifn = loads ( pickled_ifn ) <EOL> eq_ ( str ( unpickled_ifn ) , str ( ifn ) ) <EOL> def test_pickle_simple_enum ( ) : <EOL> g = zf . type . PhotoSetType ( '<STR_LIT>' ) <EOL> r = dumps ( g ) <EOL> un_g = loads ( r ) <EOL> eq_ ( str ( g ) , str ( un_g ) ) <EOL> def test_pickle_unpickle_array ( ) : <EOL> rsp = etree . fromstring ( helpers . support ( '<STR_LIT>' , '<STR_LIT:r>' ) . read ( ) ) [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> print rsp <EOL> artist , albums = lw . service . getArtist . method . output ( rsp ) <EOL> boy = albums [ <NUM_LIT:0> ] <EOL> pickled_boy = dumps ( boy ) <EOL> unpickled_boy = loads ( pickled_boy ) <EOL> eq_ ( unpickled_boy . album , u'<STR_LIT>' ) ; <EOL> eq_ ( unpickled_boy . year , <NUM_LIT> ) <EOL> eq_ ( len ( unpickled_boy . songs ) , <NUM_LIT:11> ) <EOL> eq_ ( unpickled_boy . songs [ <NUM_LIT:0> ] , u'<STR_LIT>' ) <EOL> eq_ ( unpickled_boy . songs [ <NUM_LIT:10> ] , u'<STR_LIT>' ) </s>
