#NEWLINE# def test_serialization( self ) : #NEWLINE# #INDENT# for ( klass , args ) in [ ( BloomFilter , ( self . SIZE , ) ) , ( ScalableBloomFilter , ( ) ) ] : #NEWLINE# #INDENT# filter = klass ( * args ) #NEWLINE# for item in self . EXPECTED : #NEWLINE# #INDENT# filter . add ( item ) #NEWLINE# #UNINDENT# f = tempfile . TemporaryFile ( ) #NEWLINE# filter . tofile ( f ) #NEWLINE# stringio = StringIO ( ) #NEWLINE# filter . tofile ( stringio ) #NEWLINE# streams_to_test = [ f , stringio ] #NEWLINE# if ( not running_python_3 ) : #NEWLINE# #INDENT# cstringio = cStringIO . StringIO ( ) #NEWLINE# filter . tofile ( cstringio ) #NEWLINE# streams_to_test . append ( cstringio ) #NEWLINE# #UNINDENT# del filter #NEWLINE# for stream in streams_to_test : #NEWLINE# #INDENT# stream . seek ( 0 ) #NEWLINE# filter = klass . fromfile ( stream ) #NEWLINE# for item in self . EXPECTED : #NEWLINE# #INDENT# self . assertTrue ( ( item in filter ) ) #NEWLINE# #UNINDENT# del filter #NEWLINE# stream . close ( )