Ejemplo n.º 1
0
def test_contours_run_fail_invalid_glyphname(capsys):
    args = parser.parse_args([TESTFONT_PATH_1, "bogus"])
    with pytest.raises(SystemExit) as e:
        contours_run(args)

    captured = capsys.readouterr()
    assert e.type == SystemExit
    assert e.value.code == 1
    assert "Failed to open glyph" in captured.err
Ejemplo n.º 2
0
def test_contours_run_error_non_font_path(capsys):
    test_path = os.path.join("tests", "testfiles", "text", "test.txt")
    args = parser.parse_args([test_path])

    with pytest.raises(SystemExit) as e:
        contours_run(args)

    captured = capsys.readouterr()
    assert e.type == SystemExit
    assert e.value.code == 1
    assert "does not appear to be a TTF format font" in captured.err
Ejemplo n.º 3
0
def test_contours_run_error_invalid_path(capsys):
    test_path = os.path.join("bogus", "path.txt")
    args = parser.parse_args([test_path])

    with pytest.raises(SystemExit) as e:
        contours_run(args)

    captured = capsys.readouterr()
    assert e.type == SystemExit
    assert e.value.code == 1
    assert "does not appear to be a file" in captured.err
Ejemplo n.º 4
0
def test_contours_run_single_glyph_noncomposite_nocolor(capsys, monkeypatch):
    def mock_isatty():
        return True

    monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty)

    args = parser.parse_args(["--nocolor", TESTFONT_PATH_1, "A"])
    contours_run(args)

    captured = capsys.readouterr()
    # must be in a tty to get ANSI color output
    # this is mocked above
    assert "[ A ]: 2" in captured.out
Ejemplo n.º 5
0
def test_contours_run_multi_glyph_composite_nocolor(capsys, monkeypatch):
    def mock_isatty():
        return True

    monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty)

    args = parser.parse_args(["--nocolor", TESTFONT_PATH_1])
    contours_run(args)

    captured = capsys.readouterr()
    # must be in a tty to get ANSI color output
    # this is mocked above
    assert "[ .notdef ]: 0" in captured.out
    assert "[ space ]: 0" in captured.out
    assert "[ comma ]: 1" in captured.out
    assert "[ question ]: 2" in captured.out
    assert "[ A ]: 2" in captured.out
    assert "[ uni2E2E ]: 2" in captured.out
Ejemplo n.º 6
0
def test_contours_run_multi_glyph_composite_default(capsys, monkeypatch):
    def mock_isatty():
        return True

    monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty)

    args = parser.parse_args([TESTFONT_PATH_1])
    contours_run(args)

    captured = capsys.readouterr()
    # must be in a tty to get ANSI color output
    # this is mocked above
    assert "[ \x1b[1;96m.notdef\x1b[0m ]: 0" in captured.out
    assert "[ \x1b[1;96mspace\x1b[0m ]: 0" in captured.out
    assert "[ \x1b[1;96mcomma\x1b[0m ]: 1" in captured.out
    assert "[ \x1b[1;96mquestion\x1b[0m ]: 2" in captured.out
    assert "[ \x1b[1;96mA\x1b[0m ]: 2" in captured.out
    assert "[ \x1b[1;96muni2E2E\x1b[0m ]: 2" in captured.out