def test_is_quantified_unit(): assert is_quantified_unit(1) is False assert is_quantified_unit(1.1) is False assert is_quantified_unit(Decimal(1.1)) is False assert is_quantified_unit(Decimal("1.1")) is False assert is_quantified_unit("1.1") is False px, em = Unit.many("px em") assert is_quantified_unit(px(3)) is True assert is_quantified_unit(px(3) * 3) is True assert is_quantified_unit(px(3) * 3 + px(2)) is True assert is_quantified_unit(px(3) * 3 + em(2)) is False
def test_is_number(): assert is_number(1) is True assert is_number(1.1) is True assert is_number(Decimal(1.1)) is True assert is_number(Decimal("1.1")) is True assert is_number("1.1") is False px, em = Unit.many("px em") assert is_number(px(3)) is False assert is_number(px(3) * 3) is False assert is_number(px(3) * 3 + px(2)) is False assert is_number(px(3) * 3 + em(2)) is False
def test_is_addition_part(): assert is_addition_part(1) is False assert is_addition_part(1.1) is False assert is_addition_part(Decimal(1.1)) is False assert is_addition_part(Decimal("1.1")) is False assert is_addition_part("1.1") is False px, em = Unit.many("px em") assert is_addition_part(px(3)) is True assert is_addition_part(px(3) * 3) is True assert is_addition_part(px(3) * 3 + px(2)) is True assert is_addition_part(px(3) * 3 + em(2)) is True
def test_var_many(): aa, bb = Var.many("aa bb") assert aa == "aa" assert isinstance(aa, Var) assert bb == "bb" assert isinstance(bb, Var) cc, dd = Var.many("cc", "dd") assert cc == "cc" assert isinstance(cc, Var) assert dd == "dd" assert isinstance(dd, Var) ee, ff = Unit.many("ee", "ff") assert ee == "ee" assert isinstance(ee, Unit) assert ff == "ff" assert isinstance(ff, Unit)