Skip to content

Commit

Permalink
Make JSON validity presubmit test less stringent.
Browse files Browse the repository at this point in the history
On Mac, Python 2.7 gives different results (line 1 column 3 char 2) than
Python 2.6 (line 1 column 2 char 2).

Review URL: https://codereview.chromium.org/335263002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277728 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
yoz@chromium.org committed Jun 17, 2014
1 parent 07861dc commit a334327
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions PRESUBMIT_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,25 +470,26 @@ def testFailure(self):
test_data = [
('invalid_json_1.json',
['{ x }'],
'Expecting property name: line 1 column 2 (char 2)'),
'Expecting property name:'),
('invalid_json_2.json',
['// Hello world!',
'{ "hello": "world }'],
'Unterminated string starting at: line 2 column 12 (char 12)'),
'Unterminated string starting at:'),
('invalid_json_3.json',
['{ "a": "b", "c": "d", }'],
'Expecting property name: line 1 column 22 (char 22)'),
'Expecting property name:'),
('invalid_json_4.json',
['{ "a": "b" "c": "d" }'],
'Expecting , delimiter: line 1 column 11 (char 11)'),
'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.assertEqual(expected_error, str(actual_error))
self.assertTrue(expected_error in str(actual_error),
"'%s' not found in '%s'" % (expected_error, actual_error))

def testNoEatComments(self):
input_api = MockInputApi()
Expand Down

0 comments on commit a334327

Please sign in to comment.