def test_on_file(self, mocker): mock = mocker.patch.object(webbrowser, 'open') reporter = CrashReporter(self.frame) reporter.on_file() assert mock.call_count == 1 url = mock.call_args[0][0] parsed_url = urlparse(url) assert parsed_url.scheme == 'https' assert parsed_url.netloc == 'github.com' assert parsed_url.path == '/suever/dicomsort/issues/new' query_params = parse_qs(parsed_url.query) assert 'body' in query_params assert query_params['body'][0] == reporter.body()
def test_body(self): # Given an exception and a traceback try: raise AttributeError('oh no') except AttributeError: pass t, v, tb = sys.exc_info() # And a CrashReporter corresponding to this exception reporter = CrashReporter(self.frame, type=t, value=v, traceback=tb) # The body generated by the Crash Reporter body = reporter.body() # Has the expected information assert dicomsort.__version__ in body platform = ' '.join(os.uname()) assert platform in body assert reporter.traceback() in body
def except_hook(exc_type, value, tb): dlg = CrashReporter(None, type=exc_type, value=value, traceback=tb) dlg.ShowModal() dlg.Destroy()
def test_constructor(self): reporter = CrashReporter(self.frame) reporter.Destroy()