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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 self.user = MockUser() | 44 self.user = MockUser() |
45 self.platform = MockPlatformInfo() | 45 self.platform = MockPlatformInfo() |
46 if os_name: | 46 if os_name: |
47 self.platform.os_name = os_name | 47 self.platform.os_name = os_name |
48 if os_version: | 48 if os_version: |
49 self.platform.os_version = os_version | 49 self.platform.os_version = os_version |
50 | 50 |
51 # FIXME: Should this take pointers to the filesystem and the executive? | 51 # FIXME: Should this take pointers to the filesystem and the executive? |
52 self.workspace = MockWorkspace() | 52 self.workspace = MockWorkspace() |
53 | 53 |
| 54 self.stdin = StringIO() |
54 self.stdout = StringIO() | 55 self.stdout = StringIO() |
55 self.stderr = StringIO() | 56 self.stderr = StringIO() |
56 | 57 |
57 def copy_current_environment(self): | 58 def copy_current_environment(self): |
58 return Environment({"MOCK_ENVIRON_COPY": '1'}) | 59 return Environment({"MOCK_ENVIRON_COPY": '1'}) |
59 | 60 |
60 def print_(self, *args, **kwargs): | 61 def print_(self, *args, **kwargs): |
61 sep = kwargs.get('sep', ' ') | 62 sep = kwargs.get('sep', ' ') |
62 end = kwargs.get('end', '\n') | 63 end = kwargs.get('end', '\n') |
63 file = kwargs.get('file', None) | 64 stream = kwargs.get('stream', self.stdout) |
64 stderr = kwargs.get('stderr', False) | 65 stream.write(sep.join([str(arg) for arg in args]) + end) |
65 | |
66 file = file or (self.stderr if stderr else self.stdout) | |
67 file.write(sep.join([str(arg) for arg in args]) + end) | |
OLD | NEW |