Closed sarthakpati closed 4 days ago
Assign to me 😁
@sarthakpati I think that we can use the sys.excepthook and create a customized function that handles the exceptions.
For example
def gandlf_excepthook(exctype, value, tb):
if exctype is AssertionError:
logging.exception(value)
else:
sys.__excepthook__(exctype, value, tb)
sys.excepthook = gandlf_excepthook
I am not sure if it is a good approach. Any thoughts ??
In this case, do all the assertions need to be of the type AssertionError
? What would happen with other types of assertions and the simple assert
message?
Any thoughts, @VukW?
Is your feature request related to a problem? Please describe.
Currently, all messages from the
assert
conditions flush to the console, which is fine but it does not present a unified logging interface.Describe the solution you'd like
It would be great if those messages could get flushed to the log file (perhaps in addition to the console).
Describe alternatives you've considered
N.A.
Additional context
Perhaps this could be a solution: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertLogs