<s> from nose . tools import assert_equal <EOL> import networkx as nx <EOL> import os , tempfile <EOL> class TestGpickle ( object ) : <EOL> def setUp ( self ) : <EOL> G = nx . Graph ( name = "<STR_LIT:test>" ) <EOL> e = [ ( '<STR_LIT:a>' , '<STR_LIT:b>' ) , ( '<STR_LIT:b>' , '<STR_LIT:c>' ) , ( '<STR_LIT:c>' , '<STR_LIT:d>' ) , ( '<STR_LIT:d>' , '<STR_LIT:e>' ) , ( '<STR_LIT:e>' , '<STR_LIT:f>' ) , ( '<STR_LIT:a>' , '<STR_LIT:f>' ) ] <EOL> G . add_edges_from ( e , width = <NUM_LIT:10> ) <EOL> G . add_node ( '<STR_LIT:g>' , color = '<STR_LIT>' ) <EOL> G . graph [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> self . G = G <EOL> def test_gpickle ( self ) : <EOL> G = self . G <EOL> ( fd , fname ) = tempfile . mkstemp ( ) <EOL> nx . write_gpickle ( G , fname ) ; <EOL> Gin = nx . read_gpickle ( fname ) ; <EOL> assert_equal ( sorted ( G . nodes ( data = True ) ) , <EOL> sorted ( Gin . nodes ( data = True ) ) ) <EOL> assert_equal ( sorted ( G . edges ( data = True ) ) , <EOL> sorted ( Gin . edges ( data = True ) ) ) <EOL> assert_equal ( G . graph , Gin . graph ) <EOL> os . close ( fd ) <EOL> os . unlink ( fname ) </s>
