#NEWLINE# def test_collected_objects( self ) : #NEWLINE# #INDENT# g = CollectedObjects ( ) #NEWLINE# self . assertFalse ( g . add ( 'key1' , 1 , 'item1' , None ) ) #NEWLINE# self . assertEqual ( self [ 'key1' ] , { #NEWLINE# #INDENT# 1 : 'item1' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertFalse ( g . add ( 'key2' , 1 , 'item1' , 'key1' ) ) #NEWLINE# self . assertFalse ( g . add ( 'key2' , 2 , 'item2' , 'key1' ) ) #NEWLINE# self . assertEqual ( g [ 'key2' ] , { #NEWLINE# #INDENT# 1 : 'item1' , #NEWLINE# 2 : 'item2' , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertFalse ( g . add ( 'key3' , 1 , 'item1' , 'key1' ) ) #NEWLINE# self . assertTrue ( g . add ( 'key3' , 1 , 'item1' , 'key2' ) ) #NEWLINE# self . assertEqual ( g . ordered_keys ( ) , [ 'key3' , 'key2' , 'key1' ] ) #NEWLINE# self . assertTrue ( g . add ( 'key2' , 1 , 'item1' , 'key3' ) ) #NEWLINE# self . assertRaises ( CyclicDependency , g . ordered_keys )