File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,32 @@ def cli(method):
382382 assert "--method [foo|bar|baz]" in result .output
383383
384384
385+ def test_choice_option_normalization (runner ):
386+ @click .command ()
387+ @click .option (
388+ "--method" ,
389+ type = click .Choice (
390+ ["SCREAMING_SNAKE_CASE" , "snake_case" , "PascalCase" , "kebab-case" ]
391+ ),
392+ )
393+ def cli (method ):
394+ click .echo (method )
395+
396+ result = runner .invoke (cli , ["--method=foo" ])
397+ assert not result .exception
398+ assert result .output == "foo\n "
399+
400+ result = runner .invoke (cli , ["--method=meh" ])
401+ assert result .exit_code == 2
402+ assert (
403+ "Invalid value for '--method': 'meh' is not one of "
404+ "'screaming-snake-case', 'snake-case', 'pascalcase', 'kebab-case'."
405+ ) in result .output
406+
407+ result = runner .invoke (cli , ["--help" ])
408+ assert "--method [foo|bar|baz]" in result .output
409+
410+
385411def test_choice_argument (runner ):
386412 @click .command ()
387413 @click .argument ("method" , type = click .Choice (["foo" , "bar" , "baz" ]))
You can’t perform that action at this time.
0 commit comments