def test_run_with_output_path():
    ttf_path = _get_test_ttf_path()
    save_path = get_temp_file_path()
    ttfdecomp.main(['-o', save_path, ttf_path])
    font = TTFont(save_path)
    gtable = font['glyf']
    composites = [gtable[gl].isComposite() for gl in font.glyphOrder]
    assert not any(composites)
def test_options_dir():
    input_dir = get_temp_dir_path()
    output_dir = get_temp_dir_path()
    font_path = _get_test_ttf_path()
    in_font_path = copy2(font_path, input_dir)
    ttfdecomp.main(['-d', input_dir, '-o', output_dir, '-v'])
    out_file = in_font_path.replace(input_dir, output_dir)
    font = TTFont(out_file)
    assert font['maxp'].maxComponentElements == 0
def test_run_without_output_path():
    ttf_path = _get_test_ttf_path()
    temp_dir = get_temp_dir_path()
    save_path = get_temp_file_path(directory=temp_dir)
    copy2(ttf_path, save_path)
    ttfdecomp.main([save_path])
    font = TTFont(save_path)
    gtable = font['glyf']

    composites = [gtable[gl].isComposite() for gl in font.glyphOrder]
    assert not any(composites)
def test_run_invalid_font_file():
    with pytest.raises(SystemExit) as exc_info:
        ttfdecomp.main(['not_a_font.ttf'])
    assert exc_info.value.code == 2
def test_run_no_args():
    with pytest.raises(SystemExit) as exc_info:
        ttfdecomp.main()
    assert exc_info.value.code == 2
def test_options_bad_dir_output():
    with pytest.raises(SystemExit) as exc_info:
        input_dir = get_temp_dir_path()
        output_dir = _get_test_ttf_path()
        ttfdecomp.main(['-d', input_dir, '-o', output_dir])
    assert exc_info.value.code == 2
def test_options_bogus_option():
    with pytest.raises(SystemExit) as exc_info:
        ttfdecomp.main(['--bogus'])
    assert exc_info.value.code == 2
def test_options_help():
    with pytest.raises(SystemExit) as exc_info:
        ttfdecomp.main(['-h'])
    assert exc_info.value.code == 0