-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_command_args_printing.py
More file actions
58 lines (44 loc) · 1.36 KB
/
test_command_args_printing.py
File metadata and controls
58 lines (44 loc) · 1.36 KB
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
import ellar_cli.click as click
from ellar_cli.main import app_cli
output_1 = """Usage: args-print <arg1> [<arg2>] [OPTIONS]
ARGUMENTS:
arg1: <arg1> Arg1 description [default: Sentinel.UNSET; required]
arg2: [<arg2>] Arg2 description [default: Sentinel.UNSET]
[OPTIONS]:
--help Show this message and exit.
"""
output_2 = """Usage: args-print-no-description <arg1> [<arg2>] [OPTIONS]
ARGUMENTS:
arg1: <arg1> [default: Sentinel.UNSET; required]
arg2: [<arg2>] [default: Sentinel.UNSET]
[OPTIONS]:
--help Show this message and exit.
"""
@app_cli.command()
@click.argument("arg1", required=True, help="Arg1 description")
@click.argument("arg2", required=False, help="Arg2 description")
def args_print(arg1, arg2):
print(f"ARG1={arg1} ARG2={arg2}")
@app_cli.command()
@click.argument("arg1", required=True)
@click.argument("arg2", required=False)
def args_print_no_description(arg1, arg2):
print(f"ARG1={arg1} ARG2={arg2}")
def test_args_printing_case_1(cli_runner):
res = cli_runner.invoke(
args_print,
[
"--help",
],
)
assert res.exit_code == 0
assert res.output == output_1
def test_args_printing_case_2(cli_runner):
res = cli_runner.invoke(
args_print_no_description,
[
"--help",
],
)
assert res.exit_code == 0
assert res.output == output_2