| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Unit tests for top-level Chromium presubmit script. | 6 """Unit tests for top-level Chromium presubmit script. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 | 9 |
| 10 import os | 10 import os |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 def __init__(self, path, action='A'): | 33 def __init__(self, path, action='A'): |
| 34 self.path = path | 34 self.path = path |
| 35 self.action = action | 35 self.action = action |
| 36 | 36 |
| 37 def Action(self): | 37 def Action(self): |
| 38 return self.action | 38 return self.action |
| 39 | 39 |
| 40 def LocalPath(self): | 40 def LocalPath(self): |
| 41 return self.path | 41 return self.path |
| 42 | 42 |
| 43 def AbsoluteLocalPath(self): |
| 44 return self.path |
| 45 |
| 43 | 46 |
| 44 class MockOutputApi(object): | 47 class MockOutputApi(object): |
| 45 class PresubmitError(object): | 48 class PresubmitError(object): |
| 46 def __init__(self, msg, items=[], long_text=''): | 49 def __init__(self, msg, items=[], long_text=''): |
| 47 self.msg = msg | 50 self.msg = msg |
| 48 self.items = items | 51 self.items = items |
| 49 | 52 |
| 50 | 53 |
| 51 class PresubmitUnittest(unittest.TestCase): | 54 class PresubmitUnittest(unittest.TestCase): |
| 52 def setUp(self): | 55 def setUp(self): |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 api = MockInputApi() | 97 api = MockInputApi() |
| 95 api.affected_files = [ | 98 api.affected_files = [ |
| 96 MockAffectedFile('foo/blat/source.py', 'D'), | 99 MockAffectedFile('foo/blat/source.py', 'D'), |
| 97 ] | 100 ] |
| 98 self.file_contents = 'file with \n\terror\nhere\r\nyes there' | 101 self.file_contents = 'file with \n\terror\nhere\r\nyes there' |
| 99 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 0) | 102 self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 0) |
| 100 | 103 |
| 101 | 104 |
| 102 if __name__ == '__main__': | 105 if __name__ == '__main__': |
| 103 unittest.main() | 106 unittest.main() |
| OLD | NEW |