コード例 #1
0
    def test_copy_box_raises(self, mock_critical, mock_show_copy_details_box):
        "Exception is reported using a plain message box"
        try:
            raise ValueError('Something went wrong')
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            report_exception_to_user(exc_type, exc_value, exc_traceback)

        self.assertIn('An error occurred:\nSomething went wrong',
                      mock_critical.call_args[0])
コード例 #2
0
    def test_copy_box_raises(self, mock_critical, mock_show_copy_details_box):
        "Exception is reported using a plain message box"
        try:
            raise ValueError('Something went wrong')
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            report_exception_to_user(exc_type, exc_value, exc_traceback)

        self.assertIn(
            'An error occurred:\nSomething went wrong',
            mock_critical.call_args[0]
        )
コード例 #3
0
    def test_exception_reported(self, mock_set_text, mock_exec_):
        "Exception is reported with details"
        try:
            raise ValueError('Something went wrong')
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            report_exception_to_user(exc_type, exc_value, exc_traceback)

        self.assertTrue(mock_exec_.called)
        expected = """in test_exception_reported
    raise ValueError('Something went wrong')
"""
        self.assertIn(expected, mock_set_text.call_args[0][0])
コード例 #4
0
    def test_exception_reported(self, mock_set_text, mock_exec_):
        "Exception is reported with details"
        try:
            raise ValueError('Something went wrong')
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
            report_exception_to_user(exc_type, exc_value, exc_traceback)

        self.assertTrue(mock_exec_.called)
        expected = """in test_exception_reported
    raise ValueError('Something went wrong')
"""
        self.assertIn(expected, mock_set_text.call_args[0][0])