I have a habit of testing against the CLI’s help string output. It allows me to keep the documentation up to date and makes me aware of any undocumented options. When new features are added, the help text changes and the test fails, which prompts me to add those options to the documentation.
I tried the same approach when testing Python bindings with Pytest:
def test_pipeline_step_dependency(empty_xvc_repo):
dep_help = empty_xvc_repo.pipeline().step().dependency(help=True)
expected = """
Usage: xvc pipeline step dependency [OPTIONS] --step-name <STEP_NAME>
Options:
-s, --step-name <STEP_NAME>
Name of the step to add the dependency to
"""
assert dep_help == expected
This doesn’t work because the help text is generated by clap and skips the usual thread-based output handler. All command output and errors in Xvc are returned as strings from the command, except for the help text that’s generated by clap automatically.
There are probably workarounds for this, but I won’t pursue them further as I don’t test the actual functionality in the Python bindings anyway.