<filename>cmdliner/tests/test_optional_posargs.py
"""
A test utility
"""
from cmdliner import cli
from unittest.mock import patch


@cli("0.0.1")
def main(*args):
    print(f"Hello {'+'.join(args)}")


def test_zero_parameters(capsys):
    with patch("sys.argv", ["program_name"]):
        main()
        assert capsys.readouterr().out == "Hello \n"


def test_one_parameter(capsys):
    with patch("sys.argv", ["program_name", "abc"]):
        main()
        assert capsys.readouterr().out == "Hello abc\n"


def test_two_parameters(capsys):
    with patch("sys.argv", ["program_name", "abc", "123"]):
        main()
        assert capsys.readouterr().out == "Hello abc+123\n"


if __name__ == "__main__":
    cli()

<filename>cmdliner/tests/test_optional_posargs.py
"""
A test utility
"""
from cmdliner import cli
from unittest.mock import patch


@cli("0.0.1")
def main(*args):
    print(f"Hello {'+'.join(args)}")


def test_zero_parameters(capsys):
    with patch("sys.argv", ["program_name"]):
        main()
        assert capsys.readouterr().out == "Hello \n"


def test_one_parameter(capsys):
    with patch("sys.argv", ["program_name", "abc"]):
        main()
        assert capsys.readouterr().out == "Hello abc\n"


def test_two_parameters(capsys):
    with patch("sys.argv", ["program_name", "abc", "123"]):
        main()
        assert capsys.readouterr().out == "Hello abc+123\n"


if __name__ == "__main__":
    cli()

A test utility