Skip to content

Commit

Permalink
tests: migrate to nose
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Jul 27, 2024
1 parent 1cc5b88 commit 9853f37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 8 additions & 8 deletions tests/test_compose.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import codecs
import hashlib

from nose.tools import assert_almost_equal, ok_
import pytest

import svgutils.compose as sc
from svgutils.compose import *
Expand All @@ -13,10 +13,10 @@ def test_embedded_svg():
fig = sc.Figure("5cm", "5cm", svg)
poly = fig.root.find(".//{}polygon".format(SVG))

ok_(poly.get("id") == "V")
assert poly.get("id") == "V"

ok_(svg.height is None)
ok_(svg.width is None)
assert svg.height is None
assert svg.width is None


def test_embedded_image():
Expand All @@ -29,15 +29,15 @@ def test_embedded_image():
base64 = codecs.decode(image_data, "base64")
md5 = hashlib.md5(base64).hexdigest()

ok_(lion_jpg_md5 == md5)
assert lion_jpg_md5 == md5


def test_text():

fig = Figure("5cm", "5cm", Text("lion"))
txt = fig.root.find(SVG + "text")

ok_(txt.text == "lion")
assert txt.text == "lion"


def test_no_unit():
Expand Down Expand Up @@ -66,8 +66,8 @@ def test_unit_div():
length = Unit("10cm")
shorter_length = length / 2
assert length.unit == "cm"
assert_almost_equal(shorter_length.value, 5)
assert pytest.approx(shorter_length.value) == 5

shorter_length = length / 2.0
assert length.unit == "cm"
assert_almost_equal(shorter_length.value, 5.0)
assert pytest.approx(shorter_length.value) == 5.0
12 changes: 5 additions & 7 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# coding=utf-8
from tempfile import NamedTemporaryFile

from nose.tools import ok_

from svgutils import transform
from svgutils.compose import Unit

Expand All @@ -21,13 +19,13 @@
def test_get_size():
svg_fig = transform.fromstring(circle)
w, h = svg_fig.get_size()
ok_((w == "150") & (h == "50"))
assert w == "150" and h == "50"


def test_group_class():
svg_fig = transform.fromstring(circle)
group = svg_fig.getroot()
ok_((group.root.attrib["class"] == "main"))
assert group.root.attrib["class"] == "main"


def test_skew():
Expand All @@ -36,19 +34,19 @@ def test_skew():

# Test skew in y-axis
group.skew(0, 30)
ok_("skewY(30" in group.root.get("transform"))
assert "skewY(30" in group.root.get("transform")

# Test skew in x-axis
group.skew(30, 0)
ok_("skewX(30" in group.root.get("transform"))
assert "skewX(30" in group.root.get("transform")


def test_scale_xy():
svg_fig = transform.fromstring(circle)
group = svg_fig.getroot()

group.scale(0, 30)
ok_("scale(0" in group.root.get("transform"))
assert "scale(0" in group.root.get("transform")


def test_create_svg_figure():
Expand Down

0 comments on commit 9853f37

Please sign in to comment.