cli main help test
This commit is contained in:
63
tests/test_cli_help.py
Normal file
63
tests/test_cli_help.py
Normal file
@@ -0,0 +1,63 @@
|
||||
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
|
Reference in New Issue
Block a user