Skip to content

Commit 931a802

Browse files
tests: migrate to pytest
1 parent 1cc5b88 commit 931a802

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

tests/test_compose.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import codecs
22
import hashlib
33

4-
from nose.tools import assert_almost_equal, ok_
4+
import pytest
55

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

16-
ok_(poly.get("id") == "V")
16+
assert poly.get("id") == "V"
1717

18-
ok_(svg.height is None)
19-
ok_(svg.width is None)
18+
assert svg.height is None
19+
assert svg.width is None
2020

2121

2222
def test_embedded_image():
@@ -29,15 +29,15 @@ def test_embedded_image():
2929
base64 = codecs.decode(image_data, "base64")
3030
md5 = hashlib.md5(base64).hexdigest()
3131

32-
ok_(lion_jpg_md5 == md5)
32+
assert lion_jpg_md5 == md5
3333

3434

3535
def test_text():
3636

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

40-
ok_(txt.text == "lion")
40+
assert txt.text == "lion"
4141

4242

4343
def test_no_unit():
@@ -66,8 +66,8 @@ def test_unit_div():
6666
length = Unit("10cm")
6767
shorter_length = length / 2
6868
assert length.unit == "cm"
69-
assert_almost_equal(shorter_length.value, 5)
69+
assert pytest.approx(shorter_length.value) == 5
7070

7171
shorter_length = length / 2.0
7272
assert length.unit == "cm"
73-
assert_almost_equal(shorter_length.value, 5.0)
73+
assert pytest.approx(shorter_length.value) == 5.0

tests/test_transform.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# coding=utf-8
33
from tempfile import NamedTemporaryFile
44

5-
from nose.tools import ok_
6-
75
from svgutils import transform
86
from svgutils.compose import Unit
97

@@ -21,13 +19,13 @@
2119
def test_get_size():
2220
svg_fig = transform.fromstring(circle)
2321
w, h = svg_fig.get_size()
24-
ok_((w == "150") & (h == "50"))
22+
assert w == "150" and h == "50"
2523

2624

2725
def test_group_class():
2826
svg_fig = transform.fromstring(circle)
2927
group = svg_fig.getroot()
30-
ok_((group.root.attrib["class"] == "main"))
28+
assert group.root.attrib["class"] == "main"
3129

3230

3331
def test_skew():
@@ -36,19 +34,19 @@ def test_skew():
3634

3735
# Test skew in y-axis
3836
group.skew(0, 30)
39-
ok_("skewY(30" in group.root.get("transform"))
37+
assert "skewY(30" in group.root.get("transform")
4038

4139
# Test skew in x-axis
4240
group.skew(30, 0)
43-
ok_("skewX(30" in group.root.get("transform"))
41+
assert "skewX(30" in group.root.get("transform")
4442

4543

4644
def test_scale_xy():
4745
svg_fig = transform.fromstring(circle)
4846
group = svg_fig.getroot()
4947

5048
group.scale(0, 30)
51-
ok_("scale(0" in group.root.get("transform"))
49+
assert "scale(0" in group.root.get("transform")
5250

5351

5452
def test_create_svg_figure():

0 commit comments

Comments
 (0)