Closed elizaaverywilson closed 1 year ago
You can view a fork of the repository with the added test here.
Hi @elizaaverywilson, thank you for your interest in this project!
I took a look at the problem: The code behaves alright, the function name of the test might be confusing, though. The CLI parameter isn't a "command", but really an arbitrary text argument.
Hence, "nonexistant-command" is actually a valid argument, and your test proves it. You can convince yourself by running the code for real and playing with the CLI, e.g.
$ pipenv shell
...
$ pip install .
...
$ foobar nonexistant-command --help
Usage: foobar [OPTIONS] ENVVAR
Click CLI Example
Options:
--version Show the version and exit.
--help Show this message and exit.
$ foobar nonexistant-command
Environment value nonexistant-command not set.
I agree that the CLI example can be improved. The code made more sense in its original context where I took it from. After reducing the code example what's left is confusion. I apologize! :roll_eyes:
The Docopt example is more obvious, I believe. I had planned to align the 3 CLI framework examples. If you have an immediate idea of how to improve the Click example feel free to create a pull request.
Thanks again for letting me know about the issue! :100: :medal_sports:
Closing this issue as clarified. Feel free to comment or reopen! :rocket:
In the example CLI for Click, there is the following test:
My understanding of the purpose of this test is to show that the command 'example' is accessible. So, I would expect it to be falsified by having a command that is not part of
foobar
's CLI. I've made this test to demonstrate:However, when I run this test,
result.exit_code
is0
. The test fails. Am I understanding the purpose oftest_example_command()
correctly? I am trying to use it in my application's tests, but it passes when I don't expect it to.