def test_units_mismatch(method, data):
    t, y, dy = data
    dy = dy.mean()  # scipy only supports constant errors

    t = t * units.second
    y = y * units.mag
    frequency = np.linspace(0.5, 1.5, 10)

    # this should fail because frequency and 1/t unitsdo not match
    with pytest.raises(ValueError) as err:
        lombscargle(t, y, frequency=frequency,
                    method=method, fit_bias=False)
    assert str(err.value).startswith('Units of frequency not equivalent')

    # this should fail because dy and y units do not match
    with pytest.raises(ValueError) as err:
        lombscargle(t, y, dy, frequency / t.unit,
                    method=method, fit_bias=False)
    assert str(err.value).startswith('Units of y not equivalent')