'Check that a given value is within a tolerance of expected
tolerance_frac: less-than-1.0 value; 0.8 would yield 20% tolerance.'

def assertWithinTolerance(self, measured, expected, tolerance_frac, msg):

    upperBound = (float(expected) + ((1 - tolerance_frac) * float(expected)))
    lowerBound = (float(expected) * tolerance_frac)
    info = ('measured    value    is    out    of    bounds\nexpected    value:    %s\nmeasured    value:    %s\nfailure    tolerance:    %s\nupper    bound:    %s\nlower    bound:    %s\n' % (expected, measured, tolerance_frac, upperBound, lowerBound))
    msg += info
    self.assertGreaterEqual(float(measured), lowerBound, msg=msg)
    self.assertLessEqual(float(measured), upperBound, msg=msg)
