OLD | NEW |
1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, 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 12 matching lines...) Expand all Loading... |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 # | 28 # |
29 # Class for unittest support. Used for capturing stderr/stdout. | 29 # Class for unittest support. Used for capturing stderr/stdout. |
30 | 30 |
31 import logging | 31 import logging |
32 import sys | 32 import sys |
| 33 import unittest |
| 34 |
33 from StringIO import StringIO | 35 from StringIO import StringIO |
34 | 36 |
35 import webkitpy.thirdparty.unittest2 as unittest | |
36 | |
37 | 37 |
38 class OutputCapture(object): | 38 class OutputCapture(object): |
39 # By default we capture the output to a stream. Other modules may override | 39 # By default we capture the output to a stream. Other modules may override |
40 # this function in order to do things like pass through the output. See | 40 # this function in order to do things like pass through the output. See |
41 # webkitpy.test.main for an example. | 41 # webkitpy.test.main for an example. |
42 @staticmethod | 42 @staticmethod |
43 def stream_wrapper(stream): | 43 def stream_wrapper(stream): |
44 return StringIO() | 44 return StringIO() |
45 | 45 |
46 def __init__(self): | 46 def __init__(self): |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 del self.__captured_stdout | 120 del self.__captured_stdout |
121 del self.__captured_stderr | 121 del self.__captured_stderr |
122 self.output_capture.restore_output() | 122 self.output_capture.restore_output() |
123 unittest.TestCase.tearDown(self) | 123 unittest.TestCase.tearDown(self) |
124 | 124 |
125 def assertStdout(self, expected_stdout): | 125 def assertStdout(self, expected_stdout): |
126 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) | 126 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) |
127 | 127 |
128 def assertStderr(self, expected_stderr): | 128 def assertStderr(self, expected_stderr): |
129 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) | 129 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) |
OLD | NEW |