OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 import json |
| 7 import os |
| 8 import unittest |
| 9 |
| 10 def _ReadTestFile(filename): |
| 11 with open(os.path.join('test', filename)) as f: |
| 12 return f.read() |
| 13 |
| 14 class JSONParseTest(unittest.TestCase): |
| 15 def testParse(self): |
| 16 json_str = _ReadTestFile('tabs.json') |
| 17 json0 = json.loads(json_str) |
| 18 |
| 19 import json_parse as jp1 |
| 20 json1 = jp1.Parse(json_str) |
| 21 |
| 22 # Force use of simplejson, even in Python 2.7. |
| 23 json.loads = None |
| 24 import json_parse as jp2 |
| 25 json2 = jp2.Parse(json_str) |
| 26 |
| 27 self.assertEqual(json0, json1) |
| 28 self.assertEqual(json0, json2) |
| 29 self.assertEqual(json1, json2) |
| 30 |
| 31 if __name__ == '__main__': |
| 32 unittest.main() |
OLD | NEW |