Calculates how long it took to execute the testcase.

def _calculate_duration(start_time, finish_time):
    """Calculates how long it took to execute the testcase."""
    if not (start_time and finish_time):
        return 0
    start = datetime.datetime.fromtimestamp(start_time)
    finish = datetime.datetime.fromtimestamp(finish_time)
    duration = finish - start

    decimals = float(("0." + str(duration.microseconds)))
    return duration.seconds + decimals