def test_view_box(): svg = Svg(viewBox=(0, mm(1), 10, 11)) assert svg.viewBox.ox == 0 assert svg.viewBox.oy == mm(1) assert svg.viewBox.width == 10 assert svg.viewBox.height == 11 assert str(svg.viewBox) == '0 1mm 10 11'
def test_path(): p = Path(d=(M(0, 0), l(1, 0), l(0, mm(1)), z)) assert p.d[0].x == 0 assert p.d[0].rel is False assert p.d[2].y == mm(1) assert p.d[2].rel is True assert p.d[3] is z assert str(p.d) == 'M 0 0 l 1 0 l 0 1mm Z'
def test_div(): result = pt(8) / 2 assert result == px(5) assert isinstance(result, pt) result = mm(30) / cm(3) assert result == 1 assert isinstance(result, user) with raises(TypeError): 3 / mm(30)
def test_mul(): for a, b in [(1.5, mm(30)), (mm(30), 1.5)]: result = a * b assert result == mm(45) assert isinstance(result, mm) with raises(TypeError): mm(30) * mm(12) with raises(TypeError): 'hello' * mm(30)
def test_neg(): assert -mm(30) == mm(-30)
def test_str(): assert str(mm(42)) == '42mm' assert str(user(42)) == '42'
def test_add_same_type(): result = mm(23) + mm(19) assert result == mm(42) assert isinstance(result, mm)
def test_neq(): assert mm(10) != px(10)
def test_eq(): assert in_(1) == 90 assert px(42) == user(42) assert mm(10) == cm(1)
def test_text(): t = Text(dx=(1, 2, mm(3), 4)) assert t.dx[0] == 1 assert str(t.dx) == '1 2 3mm 4'