def accept(self): """Automatic slot executed when the ok button is pressed. It will write out the keywords for the layer that is active. Args: None Returns: None. Raises: no exceptions explicitly raised.""" myKeywords = self.getKeywords() try: self.keywordIO.writeKeywords(self.layer, myKeywords) except Exception, e: QtGui.QMessageBox.warning( self, self.tr("InaSAFE"), ( ( self.tr( "An error was encountered when saving the keywords:\n" "%s" % str(getExceptionWithStacktrace(e)) ) ) ), )
def test_issue157(self): """Verify that we get the error class name back - issue #157 .. seealso:: https://github.com/AIFDR/inasafe/issues/121 """ try: bbox_intersection('aoeu', 'oaeu', []) except Exception, e: myMessage = getExceptionWithStacktrace(e, html=False) assert 'VerificationError : Western' in myMessage, myMessage
def test_stacktrace_html(self): """Stack traces can be caught and rendered as html """ try: bbox_intersection('aoeu', 'oaeu', []) except Exception, e: # Display message and traceback myMessage = getExceptionWithStacktrace(e, html=False) #print myMessage assert str(e) in myMessage assert 'line' in myMessage assert 'File' in myMessage myMessage = getExceptionWithStacktrace(e, html=True) assert str(e) in myMessage assert '<pre id="traceback"' in myMessage assert 'line' in myMessage assert 'File' in myMessage