#NEWLINE# def parse_mtestfile( fname ) : #NEWLINE# #INDENT# 'Parse a file with test values\n\n    -- starts a comment\n    blank lines, or lines containing only a comment, are ignored\n    other lines are expected to have the form\n      id fn arg -> expected [flag]*\n\n    ' #NEWLINE# with open ( fname ) as fp : #NEWLINE# #INDENT# for line in fp : #NEWLINE# #INDENT# if ( '--' in line ) : #NEWLINE# #INDENT# line = line [ : line . index ( '--' ) ] #NEWLINE# #UNINDENT# if ( not line . strip ( ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( lhs , rhs ) = line . split ( '->' ) #NEWLINE# ( id , fn , arg ) = lhs . split ( ) #NEWLINE# rhs_pieces = rhs . split ( ) #NEWLINE# exp = rhs_pieces [ 0 ] #NEWLINE# flags = rhs_pieces [ 1 : ] #NEWLINE# ( yield ( id , fn , float ( arg ) , float ( flags ) , flags ) )