You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice for testing to have a way to retrieve the intermediate result of a flow, in a way similar to how assert_flow() works but with the return value.
Thanks for asking! I'm building a library to upload files on a website. The core of it is robobrowser interacting with forms until the upload is finished and unfortunately there is some shared state and function arguments and return values are not simple.
My flow is something like this: validate_file -> upload_file -> fetch_new_metadata -> update_metadata -> finish_upload, exposed through a single method e.g. upload
Individually testing the *_metadata functions is quite hard unless I manually save the returned form from upload_file (which is a complex object) for each test case and provide it as an argument together with a manually initialized state. A solution like the one I proposed would allow for much easier testing without having to manage any other data except for vcrpy to save and replay network requests with the data.
Perhaps if bind didn't just assume the returned value was the correct monadic instance (returning it directly), and instead attempted a map, then join... a subclass of a monad could be used (and propagated) through the flow, which could be used for assertions etc.
Hi!
It would be nice for testing to have a way to retrieve the intermediate result of a flow, in a way similar to how
assert_flow()
works but with the return value.Example:
In principle this can be done with
sys.setprofile
(in the trace function and forreturn
events,arg
contains the return value).Proof of concept example:
What do you think?
Thanks :)
The text was updated successfully, but these errors were encountered: