def assert_no_error(self, json_data): def handle_style_error(mock_error_handler, line_number, category, confidence, message): self.fail('Unexpected error: %d %s %d %s' % (line_number, category, confidence, message)) error_handler = MockErrorHandler(handle_style_error) checker = jsonchecker.JSONChecker('foo.json', error_handler) checker.check(json_data.split('\n')) self.assertTrue(error_handler.turned_off_filtering)
def assert_error(self, expected_line_number, expected_category, json_data): def handle_style_error(mock_error_handler, line_number, category, confidence, message): mock_error_handler.had_error = True self.assertEqual(expected_line_number, line_number) self.assertEqual(expected_category, category) self.assertIn(category, jsonchecker.JSONChecker.categories) error_handler = MockErrorHandler(handle_style_error) error_handler.had_error = False checker = jsonchecker.JSONChecker('foo.json', error_handler) checker.check(json_data.split('\n')) self.assertTrue(error_handler.had_error) self.assertTrue(error_handler.turned_off_filtering)
def test_init(self): error_handler = MockErrorHandler(self.mock_handle_style_error) checker = jsonchecker.JSONChecker('foo.json', error_handler) self.assertEqual(checker._handle_style_error, error_handler)