| 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 11 matching lines...) Expand all Loading... |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 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 unittest # Don't use unittest2 here as the autoinstaller may not have it
yet. | |
| 33 import sys | 32 import sys |
| 33 |
| 34 from StringIO import StringIO | 34 from StringIO import StringIO |
| 35 | 35 |
| 36 from webkitpy.thirdparty import unittest2 as unittest |
| 36 | 37 |
| 37 class OutputCapture(object): | 38 class OutputCapture(object): |
| 38 # 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 |
| 39 # 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 |
| 40 # webkitpy.test.main for an example. | 41 # webkitpy.test.main for an example. |
| 41 @staticmethod | 42 @staticmethod |
| 42 def stream_wrapper(stream): | 43 def stream_wrapper(stream): |
| 43 return StringIO() | 44 return StringIO() |
| 44 | 45 |
| 45 def __init__(self): | 46 def __init__(self): |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 del self.__captured_stdout | 120 del self.__captured_stdout |
| 120 del self.__captured_stderr | 121 del self.__captured_stderr |
| 121 self.output_capture.restore_output() | 122 self.output_capture.restore_output() |
| 122 unittest.TestCase.tearDown(self) | 123 unittest.TestCase.tearDown(self) |
| 123 | 124 |
| 124 def assertStdout(self, expected_stdout): | 125 def assertStdout(self, expected_stdout): |
| 125 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) | 126 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) |
| 126 | 127 |
| 127 def assertStderr(self, expected_stderr): | 128 def assertStderr(self, expected_stderr): |
| 128 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) | 129 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) |
| OLD | NEW |