def test_run_with_output_path(): ttf_path = _get_test_ttf_path() save_path = get_temp_file_path() ttfcomp.main(['-o', save_path, ttf_path]) gtable = TTFont(save_path)['glyf'] composites = [gname for gname in gtable.glyphs if ( gtable[gname].isComposite())] assert sorted(composites) == ['aa', 'aacute', 'uni01CE']
def test_run_without_output_path(): ttf_path = _get_test_ttf_path() ufo_path = _get_test_ufo_path() temp_dir = tempfile.mkdtemp() tmp_ufo_path = os.path.join(temp_dir, os.path.basename(ufo_path)) save_path = get_temp_file_path(directory=temp_dir) copy2(ttf_path, save_path) copytree(ufo_path, tmp_ufo_path) ttfcomp.main([save_path]) gtable = TTFont(save_path)['glyf'] assert gtable['agrave'].isComposite() is False assert gtable['aacute'].isComposite() is True
def test_run_invalid_ufo(): ttf_path = _get_test_ttf_path() temp_dir = tempfile.mkdtemp() save_path = get_temp_file_path(directory=temp_dir) ufo_path = save_path + '.ufo' copy2(ttf_path, save_path) copy2(ttf_path, ufo_path) assert ttfcomp.main([save_path]) == 1
def test_run_ufo_not_found(): ttf_path = _get_test_ttf_path() temp_dir = tempfile.mkdtemp() save_path = get_temp_file_path(directory=temp_dir) copy2(ttf_path, save_path) assert ttfcomp.main([save_path]) == 1
def test_run_invalid_font(): assert ttfcomp.main(['not_a_file']) == 1
def test_run_no_args(): with pytest.raises(SystemExit) as exc_info: ttfcomp.main() assert exc_info.value.code == 2
def test_options_bogus_option(): with pytest.raises(SystemExit) as exc_info: ttfcomp.main(['--bogus']) assert exc_info.value.code == 2
def test_options_help(): with pytest.raises(SystemExit) as exc_info: ttfcomp.main(['-h']) assert exc_info.value.code == 0
def test_run_invalid_font_file(): with pytest.raises(SystemExit) as exc_info: ttfcomp.main(['not_a_font.ttf']) assert exc_info.value.code == 2
def test_run_ufo_not_found(): 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) assert ttfcomp.main([save_path]) == 1