Usage: myapp [OPTIONS] COMMAND
""")
assert output == expected
def test_html_formatter_render_description():
"""Test description rendering."""
formatter = HtmlFormatter()
description = "This is a CLI application for doing awesome things."
formatter.render_description(None, None, description)
output = formatter.get_output()
expected = 'This is a CLI application for doing awesome things.
\n'
assert output == expected
def test_html_formatter_reset():
"""Test that reset clears the output buffer."""
formatter = HtmlFormatter()
# Add some content
formatter.render_description(None, None, "Test description")
assert formatter.get_output() != ""
# Reset and check it's empty
formatter.reset()
assert formatter.get_output() == ""
def testescape_html():
"""Test HTML escaping function."""
# Basic escaping
assert escape_html("") == "<script>alert('XSS')</script>"
assert escape_html("foo & bar") == "foo & bar"
assert escape_html('"quoted"') == ""quoted""
# Handle None
assert escape_html(None) == ""
assert escape_html("") == ""
def test_extract_text():
"""Test text extraction from various objects."""
# Test None
assert extract_text(None) == ""
# Test string
assert extract_text("hello world") == "hello world"
# Test object with __str__
class TestObj:
def __str__(self):
return "test object"
assert extract_text(TestObj()) == "test object"
def test_parameter_table_with_all_metadata():
"""Test parameter table with all possible metadata fields."""
formatter = HtmlFormatter()
panel = HelpPanel(
format="parameter",
title="Parameters",
entries=[
HelpEntry(
positive_names=("--config",),
positive_shorts=("-c",),
description="Configuration file path",
required=True,
type="Path",
choices=("/etc/app.conf", "~/.app.conf", "./app.conf"),
env_var=("APP_CONFIG", "CONFIG_PATH"),
default="/etc/app.conf",
),
],
)
formatter(None, None, panel)
output = formatter.get_output()
# Check all metadata is present
assert "Configuration file path" in output
assert "