Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 if key not in self._json: | 42 if key not in self._json: |
| 43 raise FileNotFoundError(key) | 43 raise FileNotFoundError(key) |
| 44 return self._json[key] | 44 return self._json[key] |
| 45 | 45 |
| 46 def GetAllNames(self): | 46 def GetAllNames(self): |
| 47 return self._json.keys() | 47 return self._json.keys() |
| 48 | 48 |
| 49 class APIDataSourceTest(unittest.TestCase): | 49 class APIDataSourceTest(unittest.TestCase): |
| 50 def setUp(self): | 50 def setUp(self): |
| 51 self._base_path = os.path.join(sys.path[0], 'test_data', 'test_json') | 51 self._base_path = os.path.join(sys.path[0], 'test_data', 'test_json') |
| 52 self.maxDiff = None | |
|
cduvall
2013/03/27 23:01:10
take out
epeterson
2013/03/28 00:53:50
Done.
| |
| 52 | 53 |
| 53 def _ReadLocalFile(self, filename): | 54 def _ReadLocalFile(self, filename): |
| 54 with open(os.path.join(self._base_path, filename), 'r') as f: | 55 with open(os.path.join(self._base_path, filename), 'r') as f: |
| 55 return f.read() | 56 return f.read() |
| 56 | 57 |
| 57 def _CreateRefResolver(self, filename): | 58 def _CreateRefResolver(self, filename): |
| 58 data_source = FakeAPIAndListDataSource( | 59 data_source = FakeAPIAndListDataSource( |
| 59 self._LoadJSON(filename)) | 60 self._LoadJSON(filename)) |
| 60 return ReferenceResolver.Factory(data_source, | 61 return ReferenceResolver.Factory(data_source, |
| 61 data_source, | 62 data_source, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 _MakeLink('ref_test.html#type-type2', 'type2')), | 130 _MakeLink('ref_test.html#type-type2', 'type2')), |
| 130 _GetType(dict_, 'type3')['description']) | 131 _GetType(dict_, 'type3')['description']) |
| 131 | 132 |
| 132 def testRemoveNoDocs(self): | 133 def testRemoveNoDocs(self): |
| 133 d = self._LoadJSON('nodoc_test.json') | 134 d = self._LoadJSON('nodoc_test.json') |
| 134 _RemoveNoDocs(d) | 135 _RemoveNoDocs(d) |
| 135 self.assertEqual(self._LoadJSON('expected_nodoc.json'), d) | 136 self.assertEqual(self._LoadJSON('expected_nodoc.json'), d) |
| 136 | 137 |
| 137 if __name__ == '__main__': | 138 if __name__ == '__main__': |
| 138 unittest.main() | 139 unittest.main() |
| OLD | NEW |