New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing arguments that contain spaces with docopt #129
Comments
docopt takes
So in order for your test to work, you should pass a list instead of joining it into a string This confusion is probably due to the fact that passing string to argv is undocumented. In fact it is not part of API, just an implementation detail. You should not rely on the fact that docopt |
If this answers you question I will copy this answer to StackOverflow. You are always welcome create new issues in order to ask a question, or link StackOverflow questions. |
@halst Passing a list worked! Thanks a lot for answering. I thought it would be troublesome for anyone if I simply linked my SO question here and provided a short description, so I copied it whole. Feel free to copy the answer so I can mark it accepted. |
@halst: I've made a note on my StackOverflow post re: your answer here. If you have time, please copy your response there so I can mark it accepted. Thanks! 👍 |
(I had originally posted this on StackOverflow, but since I was not getting any responses, I thought I'd try here.)
I am having issues getting docopt to parse arguments that contain spaces into a proper dictionary object for use with my unit tests. Here is the code I'm currently using to construct the argument list for docopt to parse:
The code I am writing unit tests for has 2 tests that are separately given the following arguments:
To add, for example, the
-t <title>
argument, I would do:If I run the script I'm testing by itself with the said arguments, they are accepted without any problems and the output is as expected.
However, if I run the unit tests which use arguments containing spaces, I get the following:
Other unit tests that require the same dict object (containing the same arguments) work fine.
What should I change in my code to make docopt parse the arguments as it normally does?
The text was updated successfully, but these errors were encountered: