Skip to content

Commit

Permalink
Merge pull request #77 from felix-seifert/felix-seifert/add-test-painter
Browse files Browse the repository at this point in the history
Add tests in `test_painter.py` to Pytest marker `unit`
  • Loading branch information
csgoh authored Nov 19, 2023
2 parents 947b9e2 + 366ac95 commit c50af02
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/tests/test_painter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest

from src.roadmapper.painter import PNGPainter


@pytest.mark.unit
class TestPainter:
def test_init(self):
painter = PNGPainter(800, 600)
Expand Down Expand Up @@ -50,16 +53,20 @@ def test_set_colour_theme(self):
def test_get_text_dimension(self):
painter = PNGPainter(100, 100)
text = "Hello World"
font = "Arial"
font = "../fonts/SourceHanSerifTC-Regular.otf"
font_size = 12
width, height = painter.get_text_dimension(text, font, font_size)
assert width > 0
assert height > 0

def test_get_text_dimension2(self):
painter = PNGPainter(800, 600)
text_width, text_height = painter.get_text_dimension("Hello World", "Arial", 12)
text_width, text_height = painter.get_text_dimension(
"Hello World",
"../fonts/SourceHanSerifTC-Regular.otf",
12,
)
print(f"text_width: {text_width}, text_height: {text_height}")
# Linux returns different text width
assert text_width in [62, 64]
assert text_height == 11
assert text_width in [71, 73]
assert text_height == 14

0 comments on commit c50af02

Please sign in to comment.