| 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 | |
| 62 | 59 |
| 63 class MockExecutive(object): | 60 class MockExecutive(object): |
| 64 PIPE = 'MOCK PIPE' | 61 PIPE = 'MOCK PIPE' |
| 65 STDOUT = 'MOCK STDOUT' | 62 STDOUT = 'MOCK STDOUT' |
| 66 DEVNULL = 'MOCK_DEVNULL' | 63 DEVNULL = 'MOCK_DEVNULL' |
| 67 | 64 |
| 68 @staticmethod | 65 @staticmethod |
| 69 def ignore_error(error): | 66 def ignore_error(error): |
| 70 pass | 67 pass |
| 71 | 68 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 197 |
| 201 | 198 |
| 202 def mock_git_commands(vals, strict=False): | 199 def mock_git_commands(vals, strict=False): |
| 203 def run_fn(args): | 200 def run_fn(args): |
| 204 sub_command = args[1] | 201 sub_command = args[1] |
| 205 if strict and sub_command not in vals: | 202 if strict and sub_command not in vals: |
| 206 raise AssertionError('{} not found in sub-command list {}'.format( | 203 raise AssertionError('{} not found in sub-command list {}'.format( |
| 207 sub_command, vals)) | 204 sub_command, vals)) |
| 208 return vals.get(sub_command, '') | 205 return vals.get(sub_command, '') |
| 209 return MockExecutive(run_command_fn=run_fn) | 206 return MockExecutive(run_command_fn=run_fn) |
| OLD | NEW |