Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/system/outputcapture.py

Issue 2014063002: Run format-webkit on webkitpy code (without string conversion). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 def restore_output(self): 72 def restore_output(self):
73 self._logger.removeHandler(self._logs_handler) 73 self._logger.removeHandler(self._logs_handler)
74 self._logger.setLevel(self._orig_log_level) 74 self._logger.setLevel(self._orig_log_level)
75 self._logs_handler.flush() 75 self._logs_handler.flush()
76 self._logs.flush() 76 self._logs.flush()
77 logs_string = self._logs.getvalue() 77 logs_string = self._logs.getvalue()
78 delattr(self, '_logs_handler') 78 delattr(self, '_logs_handler')
79 delattr(self, '_logs') 79 delattr(self, '_logs')
80 return (self._restore_output_with_name("stdout"), self._restore_output_w ith_name("stderr"), logs_string) 80 return (self._restore_output_with_name("stdout"), self._restore_output_w ith_name("stderr"), logs_string)
81 81
82 def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_st dout="", expected_stderr="", expected_exception=None, expected_logs=None): 82 def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_st dout="",
83 expected_stderr="", expected_exception=None, expected_log s=None):
83 self.capture_output() 84 self.capture_output()
84 try: 85 try:
85 if expected_exception: 86 if expected_exception:
86 return_value = testcase.assertRaises(expected_exception, functio n, *args, **kwargs) 87 return_value = testcase.assertRaises(expected_exception, functio n, *args, **kwargs)
87 else: 88 else:
88 return_value = function(*args, **kwargs) 89 return_value = function(*args, **kwargs)
89 finally: 90 finally:
90 (stdout_string, stderr_string, logs_string) = self.restore_output() 91 (stdout_string, stderr_string, logs_string) = self.restore_output()
91 92
92 if hasattr(testcase, 'assertMultiLineEqual'): 93 if hasattr(testcase, 'assertMultiLineEqual'):
(...skipping 21 matching lines...) Expand all
114 del self.__captured_stdout 115 del self.__captured_stdout
115 del self.__captured_stderr 116 del self.__captured_stderr
116 self.output_capture.restore_output() 117 self.output_capture.restore_output()
117 unittest.TestCase.tearDown(self) 118 unittest.TestCase.tearDown(self)
118 119
119 def assertStdout(self, expected_stdout): 120 def assertStdout(self, expected_stdout):
120 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) 121 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue())
121 122
122 def assertStderr(self, expected_stderr): 123 def assertStderr(self, expected_stderr):
123 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) 124 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698