| 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 11 matching lines...) Expand all Loading... |
| 22 self.os_path = os.path | 22 self.os_path = os.path |
| 23 self.python_executable = sys.executable | 23 self.python_executable = sys.executable |
| 24 self.subprocess = subprocess | 24 self.subprocess = subprocess |
| 25 self.files = [] | 25 self.files = [] |
| 26 self.is_committing = False | 26 self.is_committing = False |
| 27 self.change = MockChange([]) | 27 self.change = MockChange([]) |
| 28 | 28 |
| 29 def AffectedFiles(self, file_filter=None): | 29 def AffectedFiles(self, file_filter=None): |
| 30 return self.files | 30 return self.files |
| 31 | 31 |
| 32 def AffectedSourceFiles(self, file_filter=None): | |
| 33 return self.files | |
| 34 | |
| 35 def PresubmitLocalPath(self): | 32 def PresubmitLocalPath(self): |
| 36 return os.path.dirname(__file__) | 33 return os.path.dirname(__file__) |
| 37 | 34 |
| 38 def ReadFile(self, filename, mode='rU'): | 35 def ReadFile(self, filename, mode='rU'): |
| 39 for file_ in self.files: | 36 for file_ in self.files: |
| 40 if file_.LocalPath() == filename: | 37 if file_.LocalPath() == filename: |
| 41 return '\n'.join(file_.NewContents()) | 38 return '\n'.join(file_.NewContents()) |
| 42 # Otherwise, file is not in our mock API. | 39 # Otherwise, file is not in our mock API. |
| 43 raise IOError, "No such file or directory: '%s'" % filename | 40 raise IOError, "No such file or directory: '%s'" % filename |
| 44 | 41 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 101 |
| 105 This class can be used in presubmit unittests to mock the query of the | 102 This class can be used in presubmit unittests to mock the query of the |
| 106 current change. | 103 current change. |
| 107 """ | 104 """ |
| 108 | 105 |
| 109 def __init__(self, changed_files): | 106 def __init__(self, changed_files): |
| 110 self._changed_files = changed_files | 107 self._changed_files = changed_files |
| 111 | 108 |
| 112 def LocalPaths(self): | 109 def LocalPaths(self): |
| 113 return self._changed_files | 110 return self._changed_files |
| OLD | NEW |