devlog 6
I have a habit of testing against the help string output from CLI. It allows to keep the docs up to date and makes me to aware of the undocumented options. When new tests are added, help text will change and the test will fail. I will have to add those options to the docs.
I tried the same when testing Python bindings with Pytest. Like the following:
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 help text is generated by clap and skips usual thread based output handler. All command output and errors in Xvc are returned as string from the command, except help text that’s generated by clap automatically.
There are probably workarounds for this, but I won’t go further as I don’t test the actual functionality in Python bindings anyway.