-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_fmp.py
99 lines (71 loc) · 3.01 KB
/
test_fmp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import shutil
import fmp
from fmp import main
import pytest
def test_default_process_constant():
assert fmp.PROCESSES == 0
def test_default_build_types():
assert 'ttf' in fmp.BUILD_FILE_TYPE
assert 'otf' in fmp.BUILD_FILE_TYPE
def test_missing_args(capsys):
with pytest.raises(SystemExit) as pytest_wrapped_e:
main([])
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 1
def test_missing_file_name_badpath(capsys):
with pytest.raises(SystemExit) as pytest_wrapped_e:
main([".ufo"])
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 1
def test_not_ufo_path_badpath(capsys):
with pytest.raises(SystemExit) as pytest_wrapped_e:
main(["bogus.dir"])
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 1
def test_not_existing_ufopath_badpath(capsys):
with pytest.raises(SystemExit) as pytest_wrapped_e:
main(["bogus.ufo"])
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 1
def test_single_font_build(capsys):
with pytest.raises(SystemExit) as pytest_wrapped_e:
main(["tests/Hack-Regular.ufo"])
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 0
assert os.path.exists("master_ttf") and os.path.isdir("master_ttf")
assert os.path.exists("master_otf") and os.path.isdir("master_otf")
assert os.path.exists("master_ttf/Hack-Regular.ttf")
assert os.path.exists("master_otf/Hack-Regular.otf")
if os.path.exists("master_ttf"):
shutil.rmtree("master_ttf")
if os.path.exists("master_otf"):
shutil.rmtree("master_otf")
def test_multiple_font_build(capsys):
ufo_paths = ["tests/Hack-Regular.ufo", "tests/Hack-Italic.ufo", "tests/Hack-Bold.ufo", "tests/Hack-BoldItalic.ufo"]
with pytest.raises(SystemExit) as pytest_wrapped_e:
main(ufo_paths)
out, err = capsys.readouterr()
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == 0
assert os.path.exists("master_ttf") and os.path.isdir("master_ttf")
assert os.path.exists("master_otf") and os.path.isdir("master_otf")
assert os.path.exists("master_ttf/Hack-Regular.ttf")
assert os.path.exists("master_otf/Hack-Regular.otf")
assert os.path.exists("master_ttf/Hack-Italic.ttf")
assert os.path.exists("master_otf/Hack-Italic.otf")
assert os.path.exists("master_ttf/Hack-Bold.ttf")
assert os.path.exists("master_otf/Hack-Bold.otf")
assert os.path.exists("master_ttf/Hack-BoldItalic.ttf")
assert os.path.exists("master_otf/Hack-BoldItalic.otf")
if os.path.exists("master_ttf"):
shutil.rmtree("master_ttf")
if os.path.exists("master_otf"):
shutil.rmtree("master_otf")