Skip to content

Commit dcda9a7

Browse files
committed
add unit tests for new --quiet flag
also updates test without quiet flag to confirm stdout reporting
1 parent 75c8fbc commit dcda9a7

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/test_main.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def font_validator(filepath):
3939
assert (tt["head"].flags & 1 << 4) == 0
4040

4141

42-
def test_default_run_roboto():
42+
def test_default_run_roboto(capsys):
4343
test_dir = os.path.join("tests", "test_files", "fonts", "temp")
4444
notouch_inpath = os.path.join("tests", "test_files", "fonts", "Roboto-Regular.ttf")
4545
test_inpath = os.path.join(
@@ -58,6 +58,8 @@ def test_default_run_roboto():
5858

5959
# execute
6060
run(test_args)
61+
captured = capsys.readouterr()
62+
assert "Saved dehinted font as" in captured.out
6163

6264
# test
6365
font_validator(test_outpath)
@@ -544,6 +546,35 @@ def test_run_with_outfile_path_noto():
544546
shutil.rmtree(test_dir)
545547

546548

549+
def test_default_run_roboto_quiet_flag_stdout_test(capsys):
550+
test_dir = os.path.join("tests", "test_files", "fonts", "temp")
551+
notouch_inpath = os.path.join("tests", "test_files", "fonts", "Roboto-Regular.ttf")
552+
test_inpath = os.path.join(
553+
"tests", "test_files", "fonts", "temp", "Roboto-Regular.ttf"
554+
)
555+
test_outpath = os.path.join(
556+
"tests", "test_files", "fonts", "temp", "Roboto-Regular-dehinted.ttf"
557+
)
558+
test_args = ["--quiet", test_inpath]
559+
560+
# setup
561+
if os.path.isdir(test_dir):
562+
shutil.rmtree(test_dir)
563+
os.mkdir(test_dir)
564+
shutil.copyfile(notouch_inpath, test_inpath)
565+
566+
# execute
567+
run(test_args)
568+
captured = capsys.readouterr()
569+
assert captured.out == ""
570+
571+
# test
572+
font_validator(test_outpath)
573+
574+
# tear down
575+
shutil.rmtree(test_dir)
576+
577+
547578
#
548579
# Validation error testing
549580
#

0 commit comments

Comments
 (0)