def test_style_invalid(): with pytest.raises( MkDocsClickException, match= "invalid is not a valid option style, which must be either `plain` or `table`." ): list(make_command_docs("hello", hello, style="invalid"))
def test_custom_multicommand(multi): """ Custom `MultiCommand` objects are supported (i.e. not just `Group` multi-commands). """ expected = dedent(""" # multi Multi help **Usage:** ``` multi [OPTIONS] COMMAND [ARGS]... ``` **Options:** ``` --help Show this message and exit. ``` ## hello Hello, world! **Usage:** ``` multi hello [OPTIONS] ``` **Options:** ``` -d, --debug TEXT Include debug output --help Show this message and exit. ``` """).lstrip() output = "\n".join(make_command_docs("multi", multi)) assert output == expected
def test_custom_multicommand(): """ Custom `MultiCommand` objects are supported (i.e. not just `Group` multi-commands). """ multi = MultiCLI("multi", help="Multi help") expected = dedent(""" # multi Multi help Usage: ``` multi [OPTIONS] COMMAND [ARGS]... ``` ## hello Hello, world! Usage: ``` multi hello [OPTIONS] ``` Options: ``` -d, --debug TEXT Include debug output ``` """).lstrip() output = "\n".join(make_command_docs("multi", multi)) assert output == expected
def test_prog_name(): output = "\n".join(make_command_docs("hello-world", hello)).strip() assert output == HELLO_EXPECTED.replace("# hello", "# hello-world")
def test_depth(): output = "\n".join(make_command_docs("hello", hello, level=2)).strip() assert output == HELLO_EXPECTED.replace("# ", "### ")
def test_make_command_docs(): output = "\n".join(make_command_docs("hello", hello)).strip() assert output == HELLO_EXPECTED
def test_custom_multicommand_name(): """Custom multi commands must be given a name.""" multi = MultiCLI() with pytest.raises(MkDocsClickException): list(make_command_docs("multi", multi))
def test_basic(): output = "\n".join(make_command_docs("hello", hello)) assert output == HELLO_EXPECTED
def test_style_table(command, expected): output = "\n".join(make_command_docs("hello", command, style="table")) assert output == expected