#NEWLINE# def test_accumulate_to_ancestor( self ) : #NEWLINE# #INDENT# 'Get the distance from a node to its ancestor' #NEWLINE# t = TreeNode . read ( io . StringIO ( '((a:0.1,b:0.2)c:0.3,(d:0.4,e)f:0.5)root;' ) ) #NEWLINE# a = t . find ( 'a' ) #NEWLINE# b = t . find ( 'b' ) #NEWLINE# exp_to_root = ( 0.1 + 0.3 ) #NEWLINE# obs_to_root = a . accumulate_to_ancestor ( t ) #NEWLINE# self . assertEqual ( obs_to_root , exp_to_root ) #NEWLINE# with self . assertRaises ( NoParentError ) : #NEWLINE# #INDENT# a . accumulate_to_ancestor ( b )