-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Mechanism for testing long-running processes #2171
Comments
I think what I'm really looking for here is a way to start a Click command running from a test in a way that lets me send to its stdin and read from its stdout. |
I figured out a pattern that solved my problem using |
|
Never mind, that already does the right thing, the issue is that |
I can't think of a clean way to do this. I wrote a little Reading a stream is a blocking operation, so even if we were able to make the stream writeable, you'd need to set up a thread so that Another possibility is implementing some API that handles I/O as a generator of events. You would call Unless you have a better suggestion, I'm going to close this and say your solution with |
I'm not blocked on this since I found a good enough workaround, but I'd be delighted to see Click come up with an official solution that's as pleasant to use as the rest of the existing Click testing utilities! It's likely not worth it if it requires major rearchitecting though. So I won't be at all disappointed if you close this as wontfix. |
The
runner.invoke(...)
mechanism has a limitation at the moment: it runs the command to completion before allowing you to run assertions against the returnedResult
object.I'm working on a tool that streams from standard input - and I'd like to run some assertions on various pieces of state in the middle of the stream. So I'd like to be able to do this:
I can't see a way to do this using
CliRunner
at the moment. Is there a known pattern for this already?The text was updated successfully, but these errors were encountered: