def ab_test(experiment_name, *alternatives):
    redis = _get_redis_connection()
    try:
        experiment = Experiment.find_or_create(
            redis, experiment_name, *alternatives)
        if experiment.winner:
            return experiment.winner.name
        else:
            forced_alternative = _override(
                experiment.name, experiment.alternative_names)
            if forced_alternative:
                return forced_alternative
            _clean_old_versions(experiment)
            if (_exclude_visitor() or
                    _not_allowed_to_test(experiment.key)):
                _begin_experiment(experiment)

            alternative_name = _get_session().get(experiment.key)
            if alternative_name:
                return alternative_name
            alternative = experiment.next_alternative()
            alternative.increment_participation()
            _begin_experiment(experiment, alternative.name)
            return alternative.name
    except ConnectionError:
        if not current_app.config['SPLIT_DB_FAILOVER']:
            raise
        control = alternatives[0]
        return control[0] if isinstance(control, tuple) else control
Start a new A/B test.
dataset/ETHPy150Open jpvanhal/flask-split/flask_split/core.py/ab_test