ttx_test: test dumping and compiling from stdin to stdout

This commit is contained in:
Cosimo Lupo 2023-03-03 16:28:22 +00:00
parent 15b450e4a6
commit 1d6326ea61
No known key found for this signature in database
GPG Key ID: DF65A8A5A119C9A8

View File

@ -6,9 +6,11 @@ import getopt
import logging import logging
import os import os
import shutil import shutil
import subprocess
import sys import sys
import tempfile import tempfile
import unittest import unittest
from pathlib import Path
import pytest import pytest
@ -996,6 +998,24 @@ def test_main_base_exception(tmpdir, monkeypatch, caplog):
assert "Unhandled exception has occurred" in caplog.text assert "Unhandled exception has occurred" in caplog.text
def test_main_ttf_dump_stdin_to_stdout(tmp_path):
inpath = Path("Tests").joinpath("ttx", "data", "TestTTF.ttf")
outpath = tmp_path / "TestTTF.ttx"
args = [sys.executable, "-m", "fontTools.ttx", "-q", "-o", "-", "-"]
with inpath.open("rb") as infile, outpath.open("w", encoding="utf-8") as outfile:
subprocess.run(args, check=True, stdin=infile, stdout=outfile)
assert outpath.is_file()
def test_main_ttx_compile_stdin_to_stdout(tmp_path):
inpath = Path("Tests").joinpath("ttx", "data", "TestTTF.ttx")
outpath = tmp_path / "TestTTF.ttf"
args = [sys.executable, "-m", "fontTools.ttx", "-q", "-o", "-", "-"]
with inpath.open("r", encoding="utf-8") as infile, outpath.open("wb") as outfile:
subprocess.run(args, check=True, stdin=infile, stdout=outfile)
assert outpath.is_file()
# --------------------------- # ---------------------------
# support functions for tests # support functions for tests
# --------------------------- # ---------------------------