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
Currently, the support for pre- and post-stage actions is rather limited. The only ones we support right now are delays and clearing cookies. I suggest adding the possibility to call arbitrary functions here. The format could be similar to the $ext function calls currently allowed for validation.
One use case we have for this would be to use freezegun to simulate changes in time for a single request (e.g. for testing session expiry).
Note the context parameter I have added here which allows passing a context object (might just be a dictionary) to the function. This allows a pair of setup- and teardown methods to keep track of created objects. The context may also contain additional info, for example the session is required for clearing the cookies.
The context variable should be injected dynamically, which is controlled either through an attribute in the spec or through a decorator:
This allows us to still use functions without context which is useful when using builtins (e.g. time.sleep as a replacement for delay_after and delay_before).
What are your thoughts on this?
The text was updated successfully, but these errors were encountered:
I have a proof of concept that will handle this kind of thing that will be going into a 2.x release #802 If anyone following this issue wants to give any feedback or examples of what they would actually use this for then I can improve it / add tests for those scenarios.
follow up to this comment: #41 (comment)
Currently, the support for pre- and post-stage actions is rather limited. The only ones we support right now are delays and clearing cookies. I suggest adding the possibility to call arbitrary functions here. The format could be similar to the
$ext
function calls currently allowed for validation.One use case we have for this would be to use freezegun to simulate changes in time for a single request (e.g. for testing session expiry).
Note the
context
parameter I have added here which allows passing a context object (might just be a dictionary) to the function. This allows a pair of setup- and teardown methods to keep track of created objects. The context may also contain additional info, for example the session is required for clearing the cookies.The context variable should be injected dynamically, which is controlled either through an attribute in the spec or through a decorator:
This allows us to still use functions without context which is useful when using builtins (e.g.
time.sleep
as a replacement fordelay_after
anddelay_before
).What are your thoughts on this?
The text was updated successfully, but these errors were encountered: