'Check that multiplication/division with other units is only
possible when the physical unit is dimensionless, and that this
turns the unit into a normal one.'

def test_multiplication_division(self):

    lu1 = u.mag(u.Jy)
    with pytest.raises(u.UnitsError):
        (lu1 * u.m)
    with pytest.raises(u.UnitsError):
        (u.m * lu1)
    with pytest.raises(u.UnitsError):
        (lu1 / lu1)
    for unit in (u.dimensionless_unscaled, u.m, u.mag, u.dex):
        with pytest.raises(u.UnitsError):
            (lu1 / unit)
    lu2 = u.mag(u.dimensionless_unscaled)
    with pytest.raises(u.UnitsError):
        (lu2 * lu1)
    with pytest.raises(u.UnitsError):
        (lu2 / lu1)
    assert ((lu2 / lu2) == u.dimensionless_unscaled)
    tf = (lu2 * u.m)
    tr = (u.m * lu2)
    for t in (tf, tr):
        assert (not isinstance(t, type(lu2)))
        assert (t == (lu2.function_unit * u.m))
        with u.set_enabled_equivalencies(u.logarithmic()):
            with pytest.raises(u.UnitsError):
                t.to(lu2.physical_unit)
    t = (tf / u.cm)
    with u.set_enabled_equivalencies(u.logarithmic()):
        assert t.is_equivalent(lu2.function_unit)
        assert_allclose(t.to(u.dimensionless_unscaled, (np.arange(3.0) / 100.0)), lu2.to(lu2.physical_unit, np.arange(3.0)))
    t2 = (tf / lu2)
    assert (not isinstance(t2, type(lu2)))
    assert (t2 == u.m)
    t3 = (tf / lu2.function_unit)
    assert (not isinstance(t3, type(lu2)))
    assert (t3 == u.m)
    with pytest.raises(TypeError):
        (lu1 * object())
    with pytest.raises(TypeError):
        (slice(None) * lu1)
    with pytest.raises(TypeError):
        (lu1 / [])
    with pytest.raises(TypeError):
        (1 / lu1)
