def get_run_failure_rate_by_key_value_metadata(key, value, start_date=None,
                                               stop_date=None, session=None):
    session = session or get_session()
    base_query = db_utils.model_query(models.Run, session).join(
        models.RunMetadata,
        models.Run.id == models.RunMetadata.run_id).filter(
            models.RunMetadata.key == key,
            models.RunMetadata.value == value)
    base_query = _filter_runs_by_date(base_query, start_date, stop_date)
    fails = base_query.filter(models.Run.fails >= 1).count()
    successes = base_query.filter(models.Run.passes > 0,
                                  models.Run.fails == 0).count()
    if fails == 0 and successes == 0:
        return None
    return (float(fails) / float(successes + fails)) * 100
Perform syntax highlighting on the given doctest string, and
dataset/ETHPy150Open openstack-infra/subunit2sql/subunit2sql/db/api.py/get_run_failure_rate_by_key_value_metadata--crossover with--dataset/ETHPy150Open QuantSoftware/QuantSoftwareToolkit/Legacy/epydoc-3.0.1/epydoc/markup/doctest.py/doctest_to_html