Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Unified Diff: PRESUBMIT_test.py

Issue 1067023003: Add shell::Tracer object and wire up to --trace-startup on Android (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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):
viettrungluu 2015/04/07 22:05:44 Maybe keep this test (and rename it)?
jamesr 2015/04/07 22:20:07 At this point it's just testing the JSON parser wh
- 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()

Powered by Google App Engine
This is Rietveld 408576698