, predefinedVariables=predefinedVariables , messagePrinter=grabMessages , warningPrinter=grabWarnings , backUpStack=True ) try: result, units = calc.evaluate(split(stimulus)) if expectedMessages == True: if messages: messages = True failure = ( expectedResult != None and ( abs(result-expectedResult) > (reltol*abs(expectedResult)+abstol) ) or expectedFormattedResult != None and ( calc.format((result, units)) != expectedFormattedResult ) or expectedUnits != None and (units != expectedUnits) or expectedError or messages != expectedMessages or warnings != expectedWarnings ) if failure: failures += 1 print fail('Failure detected (%s):' % failures) print info(' Given:'), stimulus print info(' Result :'), ', '.join([ str(result), calc.format((result, units)), units ]) print info(' Expected:'), ', '.join([ str(expectedResult)
, predefinedVariables=predefinedVariables , messagePrinter=grabMessages , warningPrinter=grabWarnings , backUpStack=True ) try: result, units = calc.evaluate(calc.split(stimulus)) if expectedMessages == True: if messages: messages = True failure = ( expectedResult != None and ( abs(result-expectedResult) > (reltol*abs(expectedResult)+abstol) ) or expectedFormattedResult != None and ( clean(calc.format((result, units))) != clean(expectedFormattedResult) ) or expectedUnits != None and (clean(units) != clean(expectedUnits)) or expectedError ) if type(messages) == list: if ( [clean(m) for m in messages] != [clean(m) for m in expectedMessages] ): failure = True elif messages != expectedMessages: failure = True if type(warnings) == list: if ( [clean(w) for w in warnings] != [clean(w) for w in expectedWarnings] ):