66"""
77import logging
88import subprocess
9+ from argparse import ArgumentParser
910
1011import 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 )
7382def test_complete (shell , caplog ):
7483 parser = get_main_parser ()
@@ -84,8 +93,15 @@ 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+ shell .compgen ('-W "$_shtab_test_commands_"' , "o" , "one" )
90106
91107 assert not caplog .record_tuples
0 commit comments