| Index: PRESUBMIT_test.py
|
| diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
|
| index 0135f9ad7ac51d52374df6f26b4dc95f3650a0b3..98e44eb37589347b4e2dbccaf7e623194b29ad24 100755
|
| --- a/PRESUBMIT_test.py
|
| +++ b/PRESUBMIT_test.py
|
| @@ -394,73 +394,5 @@ class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
|
| self.assertEqual(expected, files_to_check);
|
|
|
|
|
| -class JSONParsingTest(unittest.TestCase):
|
| - def testSuccess(self):
|
| - input_api = MockInputApi()
|
| - filename = 'valid_json.json'
|
| - contents = ['// This is a comment.',
|
| - '{',
|
| - ' "key1": ["value1", "value2"],',
|
| - ' "key2": 3 // This is an inline comment.',
|
| - '}'
|
| - ]
|
| - input_api.files = [MockFile(filename, contents)]
|
| - self.assertEqual(None,
|
| - PRESUBMIT._GetJSONParseError(input_api, filename))
|
| -
|
| - def testFailure(self):
|
| - input_api = MockInputApi()
|
| - test_data = [
|
| - ('invalid_json_1.json',
|
| - ['{ x }'],
|
| - 'Expecting property name:'),
|
| - ('invalid_json_2.json',
|
| - ['// Hello world!',
|
| - '{ "hello": "world }'],
|
| - 'Unterminated string starting at:'),
|
| - ('invalid_json_3.json',
|
| - ['{ "a": "b", "c": "d", }'],
|
| - 'Expecting property name:'),
|
| - ('invalid_json_4.json',
|
| - ['{ "a": "b" "c": "d" }'],
|
| - 'Expecting , delimiter:'),
|
| - ]
|
| -
|
| - input_api.files = [MockFile(filename, contents)
|
| - for (filename, contents, _) in test_data]
|
| -
|
| - for (filename, _, expected_error) in test_data:
|
| - actual_error = PRESUBMIT._GetJSONParseError(input_api, filename)
|
| - self.assertTrue(expected_error in str(actual_error),
|
| - "'%s' not found in '%s'" % (expected_error, actual_error))
|
| -
|
| - def testNoEatComments(self):
|
| - input_api = MockInputApi()
|
| - file_with_comments = 'file_with_comments.json'
|
| - contents_with_comments = ['// This is a comment.',
|
| - '{',
|
| - ' "key1": ["value1", "value2"],',
|
| - ' "key2": 3 // This is an inline comment.',
|
| - '}'
|
| - ]
|
| - file_without_comments = 'file_without_comments.json'
|
| - contents_without_comments = ['{',
|
| - ' "key1": ["value1", "value2"],',
|
| - ' "key2": 3',
|
| - '}'
|
| - ]
|
| - input_api.files = [MockFile(file_with_comments, contents_with_comments),
|
| - MockFile(file_without_comments,
|
| - contents_without_comments)]
|
| -
|
| - self.assertEqual('No JSON object could be decoded',
|
| - str(PRESUBMIT._GetJSONParseError(input_api,
|
| - file_with_comments,
|
| - eat_comments=False)))
|
| - self.assertEqual(None,
|
| - PRESUBMIT._GetJSONParseError(input_api,
|
| - file_without_comments,
|
| - eat_comments=False))
|
| -
|
| if __name__ == '__main__':
|
| unittest.main()
|
|
|