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

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

Issue 2248653002: Revert of Fix pylint warnings in webkitpy/common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual Revert (Patch Set 1 causes patch failure in read_checksum_from_png_unittest.py) 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=None, kwargs=None, expecte d_stdout="", 82 def assert_outputs(self, testcase, function, args=[], kwargs={}, expected_st dout="",
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 {}
86 self.capture_output() 84 self.capture_output()
87 try: 85 try:
88 if expected_exception: 86 if expected_exception:
89 return_value = testcase.assertRaises(expected_exception, functio n, *args, **kwargs) 87 return_value = testcase.assertRaises(expected_exception, functio n, *args, **kwargs)
90 else: 88 else:
91 return_value = function(*args, **kwargs) 89 return_value = function(*args, **kwargs)
92 finally: 90 finally:
93 (stdout_string, stderr_string, logs_string) = self.restore_output() 91 (stdout_string, stderr_string, logs_string) = self.restore_output()
94 92
95 if hasattr(testcase, 'assertMultiLineEqual'): 93 if hasattr(testcase, 'assertMultiLineEqual'):
96 testassert = testcase.assertMultiLineEqual 94 testassert = testcase.assertMultiLineEqual
97 else: 95 else:
98 testassert = testcase.assertEqual 96 testassert = testcase.assertEqual
99 97
100 testassert(stdout_string, expected_stdout) 98 testassert(stdout_string, expected_stdout)
101 testassert(stderr_string, expected_stderr) 99 testassert(stderr_string, expected_stderr)
102 if expected_logs is not None: 100 if expected_logs is not None:
103 testassert(logs_string, expected_logs) 101 testassert(logs_string, expected_logs)
104 # 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.
105 return return_value 103 return return_value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698