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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 testassert = testcase.assertMultiLineEqual | 94 testassert = testcase.assertMultiLineEqual |
95 else: | 95 else: |
96 testassert = testcase.assertEqual | 96 testassert = testcase.assertEqual |
97 | 97 |
98 testassert(stdout_string, expected_stdout) | 98 testassert(stdout_string, expected_stdout) |
99 testassert(stderr_string, expected_stderr) | 99 testassert(stderr_string, expected_stderr) |
100 if expected_logs is not None: | 100 if expected_logs is not None: |
101 testassert(logs_string, expected_logs) | 101 testassert(logs_string, expected_logs) |
102 # This is a little strange, but I don't know where else to return this i
nformation. | 102 # This is a little strange, but I don't know where else to return this i
nformation. |
103 return return_value | 103 return return_value |
104 | |
105 | |
106 class OutputCaptureTestCaseBase(unittest.TestCase): | |
107 maxDiff = None | |
108 | |
109 def setUp(self): | |
110 unittest.TestCase.setUp(self) | |
111 self.output_capture = OutputCapture() | |
112 (self.__captured_stdout, self.__captured_stderr) = self.output_capture.c
apture_output() | |
113 | |
114 def tearDown(self): | |
115 del self.__captured_stdout | |
116 del self.__captured_stderr | |
117 self.output_capture.restore_output() | |
118 unittest.TestCase.tearDown(self) | |
119 | |
120 def assertStdout(self, expected_stdout): | |
121 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) | |
122 | |
123 def assertStderr(self, expected_stderr): | |
124 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) | |
OLD | NEW |