test_font.py
1.0 kB · python · 37 lines
1import hashlib2import json34from mrlypy import font567def test_glyph(row):8 r = row("font::glyph")9 assert font.glyph(r["in"]["c"]).rows == r["out"]101112def test_raster(row):13 r = row("font::raster::raster")14 assert [list(line) for line in font.raster(r["in"]["text"])] == r["out"]151617def test_path(row):18 r = row("font::path")19 assert [list(step) for step in font.path(r["in"]["c"])] == r["out"]202122def test_animate(row):23 r = row("font::animate::animate")24 anim = font.animate(r["in"]["text"], r["in"]["pad"])25 assert anim["rows"] == r["out"]["rows"]26 assert anim["cols"] == r["out"]["cols"]27 assert anim["fps"] == r["out"]["fps"]28 assert len(anim["frames"]) == r["out"]["frames"]29 assert anim["frames"][-1] == r["out"]["last"]303132def test_map(row):33 r = row("font::map")34 book = font.map()35 text = json.dumps(book, separators=(",", ":"), sort_keys=True, ensure_ascii=False)36 assert hashlib.sha256(text.encode()).hexdigest() == r["out"]["sha256"]37 assert len(book) == r["out"]["len"]