def testPickle(exception_configuration): try: exception_configuration.RaiseExceptionUsingReraise() except exception_configuration.exception_type as reraised_exception: from six.moves.cPickle import dumps, loads dumped_exception = dumps(reraised_exception) pickled_exception = loads(dumped_exception) assert exception_to_unicode(pickled_exception) == exception_to_unicode( reraised_exception ) assert exception_to_unicode(pickled_exception) != '' assert exception_to_unicode(reraised_exception) != ''
def testReraiseAddsMessagesCorrectly(exception_configuration): with pytest.raises(exception_configuration.exception_type) as e: exception_configuration.RaiseExceptionUsingReraise() assert isinstance(e.value, exception_configuration.exception_type) assert ( exception_to_unicode(e.value) == exception_configuration.get_expected_exception_message() ) traceback_message = traceback.format_exception_only(type(e.value), e.value) traceback_message = ''.join(traceback_message) assert ( traceback_message == exception_configuration.get_expected_traceback_message(e.value) )