コード例 #1
0
    def test_prepare_exception(self, yellow_mock):
        try:
            raise Exception('FooBarException')
        except Exception as e:
            display = Display()
            display.prepare_exception(e)

            self.assertEqual(display.indentation_level, 0)
            self.assertEqual(display.display_string, "FooBarException\n" + extract_traceback(e))
            display.yellow.assert_called_once_with(("FooBarException\n" + extract_traceback(e)).rstrip())
コード例 #2
0
    def test_prepare_exception_without_str_representation(self, yellow_mock):
        try:
            class FooBarException(Exception):

                def __str__(self):
                    return ''

            raise FooBarException
        except FooBarException as e:
            display = Display()
            display.prepare_exception(e)

            self.assertEqual(display.indentation_level, 0)
            self.assertEqual(display.display_string, "FooBarException\n" + extract_traceback(e))
            display.yellow.assert_called_once_with(("FooBarException\n" + extract_traceback(e)).rstrip())