Skip to content

Instantly share code, notes, and snippets.

@brycepg
Last active August 12, 2016 06:24
Show Gist options
  • Save brycepg/b10de7804c77f547ba3b6a32aad94e24 to your computer and use it in GitHub Desktop.
Save brycepg/b10de7804c77f547ba3b6a32aad94e24 to your computer and use it in GitHub Desktop.
Return Report of Procedural Functions using Decorators in Python
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@brycepg
Copy link
Author

brycepg commented Aug 12, 2016

In the final version I pack the decorated functions return value, along with TestInfo object on return, if the decorated functions return value isn't None.
In this simplified version, I use the repr for readability in iPython. I need the TestInfo object to be returned even if there is a success to affirm that all functions were called without an exception.

I'm not sure how making the decorator a class will help. I need TestInfo to be a value-object returned to the caller to do analysis(this example is a proof of concept). I can define TestInfo class inside the decorator function exc_info however, which I think makes logical sense since nowhere else does it need to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment