Skip to content

Commit b4b6b03

Browse files
committed
add test
1 parent bc7398c commit b4b6b03

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tests/test_shtab.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77
import logging
88
import subprocess
9+
from argparse import ArgumentParser
910

1011
import pytest
1112

@@ -69,6 +70,14 @@ def test_choices():
6970
assert "" not in shtab.Required.FILE
7071

7172

73+
@pytest.mark.parametrize("shell", SUPPORTED_SHELLS)
74+
def test_main(shell, caplog):
75+
with caplog.at_level(logging.INFO):
76+
main(["-s", shell, "shtab.main.get_main_parser"])
77+
78+
assert not caplog.record_tuples
79+
80+
7281
@pytest.mark.parametrize("shell", SUPPORTED_SHELLS)
7382
def test_complete(shell, caplog):
7483
parser = get_main_parser()
@@ -84,8 +93,17 @@ def test_complete(shell, caplog):
8493

8594

8695
@pytest.mark.parametrize("shell", SUPPORTED_SHELLS)
87-
def test_main(shell, caplog):
96+
def test_positional_choices(shell, caplog):
97+
parser = ArgumentParser(prog="test")
98+
parser.add_argument("posA", choices=["one", "two"])
8899
with caplog.at_level(logging.INFO):
89-
main(["-s", shell, "shtab.main.get_main_parser"])
100+
completion = shtab.complete(parser, shell=shell)
101+
print(completion)
102+
103+
if shell == "bash":
104+
shell = Bash(completion)
105+
# ideally should check completion
106+
# https://github.com/iterative/shtab/issues/11
107+
shell.compgen('-W "$_shtab_test_options_"', "", "-h --help")
90108

91109
assert not caplog.record_tuples

0 commit comments

Comments
 (0)