| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 def poll(self): | 50 def poll(self): |
| 51 # Consider the process completed when all the stdout and stderr has been
read. | 51 # Consider the process completed when all the stdout and stderr has been
read. |
| 52 if self.stdout.len != self.stdout.tell() or self.stderr.len != self.stde
rr.tell(): | 52 if self.stdout.len != self.stdout.tell() or self.stderr.len != self.stde
rr.tell(): |
| 53 return None | 53 return None |
| 54 return self.returncode | 54 return self.returncode |
| 55 | 55 |
| 56 def communicate(self, *_): | 56 def communicate(self, *_): |
| 57 return (self.stdout.getvalue(), self.stderr.getvalue()) | 57 return (self.stdout.getvalue(), self.stderr.getvalue()) |
| 58 | 58 |
| 59 def kill(self): |
| 60 return |
| 61 |
| 59 | 62 |
| 60 class MockExecutive(object): | 63 class MockExecutive(object): |
| 61 PIPE = 'MOCK PIPE' | 64 PIPE = 'MOCK PIPE' |
| 62 STDOUT = 'MOCK STDOUT' | 65 STDOUT = 'MOCK STDOUT' |
| 63 DEVNULL = 'MOCK_DEVNULL' | 66 DEVNULL = 'MOCK_DEVNULL' |
| 64 | 67 |
| 65 @staticmethod | 68 @staticmethod |
| 66 def ignore_error(error): | 69 def ignore_error(error): |
| 67 pass | 70 pass |
| 68 | 71 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 200 |
| 198 | 201 |
| 199 def mock_git_commands(vals, strict=False): | 202 def mock_git_commands(vals, strict=False): |
| 200 def run_fn(args): | 203 def run_fn(args): |
| 201 sub_command = args[1] | 204 sub_command = args[1] |
| 202 if strict and sub_command not in vals: | 205 if strict and sub_command not in vals: |
| 203 raise AssertionError('{} not found in sub-command list {}'.format( | 206 raise AssertionError('{} not found in sub-command list {}'.format( |
| 204 sub_command, vals)) | 207 sub_command, vals)) |
| 205 return vals.get(sub_command, '') | 208 return vals.get(sub_command, '') |
| 206 return MockExecutive(run_command_fn=run_fn) | 209 return MockExecutive(run_command_fn=run_fn) |
| OLD | NEW |