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

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

Issue 2130093003: Fix pylint warnings in webkitpy/common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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="", 82 def assert_outputs(self, testcase, function, args=None, kwargs=None, expecte d_stdout="",
83 expected_stderr="", expected_exception=None, expected_log s=None): 83 expected_stderr="", expected_exception=None, expected_log s=None):
84 args = args or []
85 kwargs = kwargs or {}
84 self.capture_output() 86 self.capture_output()
85 try: 87 try:
86 if expected_exception: 88 if expected_exception:
87 return_value = testcase.assertRaises(expected_exception, functio n, *args, **kwargs) 89 return_value = testcase.assertRaises(expected_exception, functio n, *args, **kwargs)
88 else: 90 else:
89 return_value = function(*args, **kwargs) 91 return_value = function(*args, **kwargs)
90 finally: 92 finally:
91 (stdout_string, stderr_string, logs_string) = self.restore_output() 93 (stdout_string, stderr_string, logs_string) = self.restore_output()
92 94
93 if hasattr(testcase, 'assertMultiLineEqual'): 95 if hasattr(testcase, 'assertMultiLineEqual'):
(...skipping 21 matching lines...) Expand all
115 del self.__captured_stdout 117 del self.__captured_stdout
116 del self.__captured_stderr 118 del self.__captured_stderr
117 self.output_capture.restore_output() 119 self.output_capture.restore_output()
118 unittest.TestCase.tearDown(self) 120 unittest.TestCase.tearDown(self)
119 121
120 def assertStdout(self, expected_stdout): 122 def assertStdout(self, expected_stdout):
121 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue()) 123 self.assertEqual(expected_stdout, self.__captured_stdout.getvalue())
122 124
123 def assertStderr(self, expected_stderr): 125 def assertStderr(self, expected_stderr):
124 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue()) 126 self.assertEqual(expected_stderr, self.__captured_stderr.getvalue())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698