clifinance/tests/test_cli_help.py

64 lines
1.1 KiB
Python

import sys
from contextlib import nullcontext
import pytest
from clifinance.main.app import main
app = "src/clifinance/main/app.py"
main_help_out = [
"usage:",
"app.py",
"[-h]",
"{balance,select,add}",
"...",
"Cli",
"finance",
"app",
"options:",
"-h,",
"--help",
"show",
"this",
"help",
"message",
"and",
"exit",
"Availeble",
"commands:",
"{balance,select,add}",
"balance",
"Get",
"balance",
"select",
"Get",
"expenses",
"by",
"filter",
"add",
"Add",
"new",
"expense",
]
main_help_testdata = [
(app, "-h", nullcontext(main_help_out)),
(app, "--help", nullcontext(main_help_out)),
]
@pytest.mark.parametrize("app, arg, expectation", main_help_testdata)
def test_main_help(capsys, app, arg, expectation):
with expectation as e:
sys.argv = [app, arg]
with pytest.raises(SystemExit) as excinfo:
main()
out, err = capsys.readouterr()
assert excinfo.value.code == 0
assert err == ""
assert out.split() == e