| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 def ReadFile(self, filename, mode='rU'): | 34 def ReadFile(self, filename, mode='rU'): |
| 35 for file_ in self.files: | 35 for file_ in self.files: |
| 36 if file_.LocalPath() == filename: | 36 if file_.LocalPath() == filename: |
| 37 return '\n'.join(file_.NewContents()) | 37 return '\n'.join(file_.NewContents()) |
| 38 # Otherwise, file is not in our mock API. | 38 # Otherwise, file is not in our mock API. |
| 39 raise IOError, "No such file or directory: '%s'" % filename | 39 raise IOError, "No such file or directory: '%s'" % filename |
| 40 | 40 |
| 41 | 41 |
| 42 class MockOutputApi(object): | 42 class MockOutputApi(object): |
| 43 ""Mock class for the OutputApi class. | 43 """Mock class for the OutputApi class. |
| 44 | 44 |
| 45 An instance of this class can be passed to presubmit unittests for outputing | 45 An instance of this class can be passed to presubmit unittests for outputing |
| 46 various types of results. | 46 various types of results. |
| 47 """ | 47 """ |
| 48 | 48 |
| 49 class PresubmitResult(object): | 49 class PresubmitResult(object): |
| 50 def __init__(self, message, items=None, long_text=''): | 50 def __init__(self, message, items=None, long_text=''): |
| 51 self.message = message | 51 self.message = message |
| 52 self.items = items | 52 self.items = items |
| 53 self.long_text = long_text | 53 self.long_text = long_text |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 100 |
| 101 This class can be used in presubmit unittests to mock the query of the | 101 This class can be used in presubmit unittests to mock the query of the |
| 102 current change. | 102 current change. |
| 103 """ | 103 """ |
| 104 | 104 |
| 105 def __init__(self, changed_files): | 105 def __init__(self, changed_files): |
| 106 self._changed_files = changed_files | 106 self._changed_files = changed_files |
| 107 | 107 |
| 108 def LocalPaths(self): | 108 def LocalPaths(self): |
| 109 return self._changed_files | 109 return self._changed_files |
| OLD | NEW |