File: test_dependencies.py

package info (click to toggle)
gftools 0.9.99%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 12,580 kB
  • sloc: python: 15,991; sh: 33; makefile: 6
file content (29 lines) | stat: -rw-r--r-- 976 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pytest
import tempfile
import subprocess
import os
from fontTools.ttLib import TTFont
from gftools.builder.dependencies import GFTOOLS_DEPENDENCIES_KEY


TEST_FONT = os.path.join("data", "test", "Lora-Regular.ttf")


@pytest.mark.parametrize("fp", [TEST_FONT])
def test_write_and_read_dependencies(fp):
    with tempfile.TemporaryDirectory() as tmp:
        font_out = os.path.join(tmp, "font.ttf")
        requirements_out = os.path.join(tmp, "requirements.txt")
        subprocess.run(
            ["gftools", "font-dependencies", "write", TEST_FONT, "-o", font_out]
        )
        ttfont = TTFont(font_out)
        assert "Debg" in ttfont
        assert GFTOOLS_DEPENDENCIES_KEY in ttfont["Debg"].data

        subprocess.run(
            ["gftools", "font-dependencies", "read", font_out, "-o", requirements_out]
        )
        with open(requirements_out, encoding="utf-8") as doc:
            doc_text = doc.read()
            assert "fonttools" in doc_text