#NEWLINE# def test_prune( self ) : #NEWLINE# #INDENT# 'Collapse single descendent nodes' #NEWLINE# cp = self . simple_t . copy ( ) #NEWLINE# self . simple_t . prune ( ) #NEWLINE# gen = zip ( cp . traverse ( include_self = True ) , self . simple_t . traverse ( include_self = True ) ) #NEWLINE# for ( a , b ) in gen : #NEWLINE# #INDENT# self . assertIsNot ( a , b ) #NEWLINE# self . assertEqual ( a . name , b . name ) #NEWLINE# self . assertEqual ( a . length , b . length ) #NEWLINE# #UNINDENT# n = self . simple_t . children [ 0 ] #NEWLINE# n . remove ( n . children [ 0 ] ) #NEWLINE# self . simple_t . prune ( ) #NEWLINE# self . assertEqual ( len ( cp . simple_t . children ) , 2 ) #NEWLINE# self . assertEqual ( self . simple_t . children [ 0 ] . name , 'i2' ) #NEWLINE# self . assertEqual ( self . simple_t . children [ 1 ] . name , 'b' )