Skip to content

Commit 1540d47

Browse files
committed
Update: test case.
1 parent 902bcd0 commit 1540d47

File tree

2 files changed

+104
-38
lines changed

2 files changed

+104
-38
lines changed

samples/v2/config.cmdcomp.toml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[cmdcomp]
2+
version = "2"
3+
4+
[app]
5+
name = "cliname"
6+
alias = "cliname2"
7+
8+
[root]
9+
[root.arguments.--verbose]
10+
type = "flag"
11+
description = "verbose output."
12+
13+
[root.arguments.--no-verbose]
14+
type = "flag"
15+
description = "no verbose output."
16+
17+
[root.arguments.--version]
18+
type = "flag"
19+
alias = "-V"
20+
description = "print version."
21+
22+
[root.arguments.--config]
23+
type = "file"
24+
description = "config file."
25+
26+
[root.arguments.--help]
27+
type = "flag"
28+
description = "print help."
29+
30+
[root.subcommands.list]
31+
alias = "ls"
32+
description = "list project files."
33+
34+
[root.subcommands.list.arguments.--all]
35+
type = "flag"
36+
alias = "-a"
37+
description = "list all files."
38+
39+
[root.subcommands.list.arguments."*"]
40+
type = "file"
41+
description = "list files."
42+
43+
[root.subcommands.cd]
44+
description = "cd project directory."
45+
46+
[root.subcommands.cd.arguments.-P]
47+
type = "flag"
48+
description = "physical directory."
49+
50+
[root.subcommands.cd.arguments.1]
51+
type = "file"
52+
base_path = "$HOME"
53+
description = "change project directory."
54+
55+
[root.subcommands.test]
56+
description = "test command."
57+
58+
[root.subcommands.test.subcommands.rubocop]
59+
description = "run rubocop."
60+
61+
[root.subcommands.test.subcommands.rubocop.arguments.--auto-correct]
62+
type = "flag"
63+
alias = "-A"
64+
description = "auto correct."
65+
66+
[root.subcommands.test.subcommands.pytest]
67+
description = "run pytest."

tests/test_cmdcomp.py

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,43 @@
77

88

99
@pytest.mark.parametrize("version", ["v1", "v2"])
10-
@pytest.mark.parametrize("config_format", ["yaml"])
10+
@pytest.mark.parametrize("config_format", ["yaml", "toml"])
1111
@pytest.mark.parametrize("shell", ShellType)
12-
def test_output_file_to_samples(
13-
version: str,
14-
config_format: str,
15-
shell: ShellType,
16-
) -> None:
17-
App.run(
18-
[
19-
"--file",
20-
str(SAMPLES_DIR / version / f"config.cmdcomp.{config_format}"),
21-
"--shell-type",
22-
shell.value,
23-
"--output",
24-
str(SAMPLES_DIR / version / f"output.{shell.value}"),
25-
]
26-
)
12+
class TestApplication:
13+
def test_application(
14+
self,
15+
capsys: CaptureFixture,
16+
version: str,
17+
config_format: str,
18+
shell: ShellType,
19+
) -> None:
20+
App.run(
21+
[
22+
"--file",
23+
str(SAMPLES_DIR / version / f"config.cmdcomp.{config_format}"),
24+
"--shell-type",
25+
shell.value,
26+
]
27+
)
2728

29+
assert (
30+
capsys.readouterr().out
31+
== open(SAMPLES_DIR / version / f"output.{str(shell.value)}").read()
32+
)
2833

29-
@pytest.mark.parametrize("version", ["v1", "v2"])
30-
@pytest.mark.parametrize("config_format", ["yaml"])
31-
@pytest.mark.parametrize("shell", ShellType)
32-
def test_application(
33-
capsys: CaptureFixture,
34-
version: str,
35-
config_format: str,
36-
shell: ShellType,
37-
) -> None:
38-
App.run(
39-
[
40-
"--file",
41-
str(SAMPLES_DIR / version / f"config.cmdcomp.{config_format}"),
42-
"--shell-type",
43-
shell.value,
44-
]
45-
)
46-
47-
assert (
48-
capsys.readouterr().out
49-
== open(SAMPLES_DIR / version / f"output.{str(shell.value)}").read()
50-
)
34+
def test_output_file_to_samples(
35+
self,
36+
version: str,
37+
config_format: str,
38+
shell: ShellType,
39+
) -> None:
40+
App.run(
41+
[
42+
"--file",
43+
str(SAMPLES_DIR / version / f"config.cmdcomp.{config_format}"),
44+
"--shell-type",
45+
shell.value,
46+
"--output",
47+
str(SAMPLES_DIR / version / f"output.{shell.value}"),
48+
]
49+
)

0 commit comments

Comments
 (0)