From 1d6326ea6182036d8c635e6abcdcb3a2e6be305b Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 3 Mar 2023 16:28:22 +0000 Subject: [PATCH] ttx_test: test dumping and compiling from stdin to stdout --- Tests/ttx/ttx_test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Tests/ttx/ttx_test.py b/Tests/ttx/ttx_test.py index e63f1da9a..d4a27f36b 100644 --- a/Tests/ttx/ttx_test.py +++ b/Tests/ttx/ttx_test.py @@ -6,9 +6,11 @@ import getopt import logging import os import shutil +import subprocess import sys import tempfile import unittest +from pathlib import Path import pytest @@ -996,6 +998,24 @@ def test_main_base_exception(tmpdir, monkeypatch, caplog): 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 # ---------------------------