From 9853f374d1e43ae0364f99c65d8419ba6e442d94 Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Sat, 27 Jul 2024 12:33:13 +0200 Subject: [PATCH] tests: migrate to nose --- tests/test_compose.py | 16 ++++++++-------- tests/test_transform.py | 12 +++++------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/test_compose.py b/tests/test_compose.py index 6b52403..5d7a796 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -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 * @@ -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(): @@ -29,7 +29,7 @@ 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(): @@ -37,7 +37,7 @@ 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(): @@ -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 diff --git a/tests/test_transform.py b/tests/test_transform.py index 5c3a66c..2c0dbde 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -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 @@ -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(): @@ -36,11 +34,11 @@ 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(): @@ -48,7 +46,7 @@ def test_scale_xy(): 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():