def test_transform_data_leakage_handling_param_raise_warning():
    ds = load_dataset(incl_test=True)
    te = H2OTargetEncoderEstimator(data_leakage_handling="leave_one_out", seed=42)
    te.train(y=ds.target, training_frame=ds.train)
    encoded = te.predict(ds.test)
    encoded_as_training = te.transform(ds.test, as_training=True)

    transformed_1 = te.transform(ds.test)
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        transformed_2 = te.transform(ds.test, data_leakage_handling="none")
        assert len(w) == 1
        assert issubclass(w[0].category, H2ODeprecationWarning)
        assert "`data_leakage_handling` is deprecated in `transform` method and will be ignored" in str(w[0].message)

    # if data_leakage_handling is specified and not "none", this is interpreted as `as_training=True`
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter("always")
        transformed_3 = te.transform(ds.test, data_leakage_handling="leave_one_out")
        assert len(w) == 2
        assert issubclass(w[1].category, H2ODeprecationWarning)
        assert "as_training=True" in str(w[1].message)