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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/views/printing_unittest.py

Issue 1783073002: Run auto-formatter on files in webkitpy/layout_tests/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ran yapf -i --style '{based_on_style: pep8, column_limit: 132}' then did manual fix-up Created 4 years, 9 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) 2010, 2012 Google Inc. All rights reserved. 1 # Copyright (C) 2010, 2012 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
11 # in the documentation and/or other materials provided with the 11 # in the documentation and/or other materials provided with the
12 # distribution. 12 # distribution.
13 # * Neither the name of Google Inc. nor the names of its 13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from 14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission. 15 # this software without specific prior written permission.
16 # 16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
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
29 """Unit tests for printing.py.""" 28 """Unit tests for printing.py."""
30 29
31 import StringIO 30 import StringIO
32 import optparse 31 import optparse
33 import sys 32 import sys
34 import time 33 import time
35 import unittest 34 import unittest
36 35
37 from webkitpy.common.host_mock import MockHost 36 from webkitpy.common.host_mock import MockHost
38 37
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 total_run_time += result.total_run_time 71 total_run_time += result.total_run_time
73 self.run_time = total_run_time + 1 72 self.run_time = total_run_time + 1
74 73
75 74
76 class FakeShard(object): 75 class FakeShard(object):
77 def __init__(self, shard_name, total_run_time): 76 def __init__(self, shard_name, total_run_time):
78 self.shard_name = shard_name 77 self.shard_name = shard_name
79 self.total_run_time = total_run_time 78 self.total_run_time = total_run_time
80 79
81 80
82 class Testprinter(unittest.TestCase): 81 class Testprinter(unittest.TestCase):
83 def assertEmpty(self, stream): 82 def assertEmpty(self, stream):
84 self.assertFalse(stream.getvalue()) 83 self.assertFalse(stream.getvalue())
85 84
86 def assertNotEmpty(self, stream): 85 def assertNotEmpty(self, stream):
87 self.assertTrue(stream.getvalue()) 86 self.assertTrue(stream.getvalue())
88 87
89 def assertWritten(self, stream, contents): 88 def assertWritten(self, stream, contents):
90 self.assertEqual(stream.buflist, contents) 89 self.assertEqual(stream.buflist, contents)
91 90
92 def reset(self, stream): 91 def reset(self, stream):
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 printer._options.debug_rwt_logging = True 149 printer._options.debug_rwt_logging = True
151 150
152 run_results = FakeRunResults() 151 run_results = FakeRunResults()
153 run_results.results_by_name = { 152 run_results.results_by_name = {
154 "slowShard": FakeShard("slowShard", 16), 153 "slowShard": FakeShard("slowShard", 16),
155 "borderlineShard": FakeShard("borderlineShard", 15), 154 "borderlineShard": FakeShard("borderlineShard", 15),
156 "fastShard": FakeShard("fastShard", 1), 155 "fastShard": FakeShard("fastShard", 1),
157 } 156 }
158 157
159 printer._print_directory_timings(run_results) 158 printer._print_directory_timings(run_results)
160 self.assertWritten(err, ['Time to process slowest subdirectories:\n', ' slowShard took 16.0 seconds to run 1 tests.\n', '\n']) 159 self.assertWritten(err, ['Time to process slowest subdirectories:\n', ' slowShard took 16.0 seconds to run 1 tests.\n',
160 '\n'])
161 161
162 printer, err = self.get_printer() 162 printer, err = self.get_printer()
163 printer._options.debug_rwt_logging = True 163 printer._options.debug_rwt_logging = True
164 164
165 run_results.results_by_name = { 165 run_results.results_by_name = {
166 "borderlineShard": FakeShard("borderlineShard", 15), 166 "borderlineShard": FakeShard("borderlineShard", 15),
167 "fastShard": FakeShard("fastShard", 1), 167 "fastShard": FakeShard("fastShard", 1),
168 } 168 }
169 169
170 printer._print_directory_timings(run_results) 170 printer._print_directory_timings(run_results)
(...skipping 16 matching lines...) Expand all
187 # With times: 187 # With times:
188 fake_shards = [FakeShard("foo", 1), FakeShard("bar", 2)] 188 fake_shards = [FakeShard("foo", 1), FakeShard("bar", 2)]
189 run_test(1, 1, 0, fake_shards, ["The test ran as expected in 5.00s (2.00 s in rwt, 1x).\n", "\n"]) 189 run_test(1, 1, 0, fake_shards, ["The test ran as expected in 5.00s (2.00 s in rwt, 1x).\n", "\n"])
190 run_test(2, 1, 1, fake_shards, ["\n", "1 test ran as expected, 1 didn't in 5.00s (2.00s in rwt, 1x):\n", "\n"]) 190 run_test(2, 1, 1, fake_shards, ["\n", "1 test ran as expected, 1 didn't in 5.00s (2.00s in rwt, 1x):\n", "\n"])
191 run_test(3, 2, 1, fake_shards, ["\n", "2 tests ran as expected, 1 didn't in 5.00s (2.00s in rwt, 1x):\n", "\n"]) 191 run_test(3, 2, 1, fake_shards, ["\n", "2 tests ran as expected, 1 didn't in 5.00s (2.00s in rwt, 1x):\n", "\n"])
192 run_test(3, 2, 0, fake_shards, ["\n", "2 tests ran as expected (1 didn't run) in 5.00s (2.00s in rwt, 1x).\n", "\n"]) 192 run_test(3, 2, 0, fake_shards, ["\n", "2 tests ran as expected (1 didn't run) in 5.00s (2.00s in rwt, 1x).\n", "\n"])
193 193
194 def test_test_status_line(self): 194 def test_test_status_line(self):
195 printer, _ = self.get_printer() 195 printer, _ = self.get_printer()
196 printer._meter.number_of_columns = lambda: 80 196 printer._meter.number_of_columns = lambda: 80
197 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html', ' passed') 197 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html',
198 ' passed')
198 self.assertEqual(80, len(actual)) 199 self.assertEqual(80, len(actual))
199 self.assertEqual(actual, '[0/0] fast/dom/HTMLFormElement/associa...after -index-assertion-fail1.html passed') 200 self.assertEqual(actual, '[0/0] fast/dom/HTMLFormElement/associa...after -index-assertion-fail1.html passed')
200 201
201 printer._meter.number_of_columns = lambda: 89 202 printer._meter.number_of_columns = lambda: 89
202 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html', ' passed') 203 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html',
204 ' passed')
203 self.assertEqual(89, len(actual)) 205 self.assertEqual(89, len(actual))
204 self.assertEqual(actual, '[0/0] fast/dom/HTMLFormElement/associated-...e nts-after-index-assertion-fail1.html passed') 206 self.assertEqual(actual, '[0/0] fast/dom/HTMLFormElement/associated-...e nts-after-index-assertion-fail1.html passed')
205 207
206 printer._meter.number_of_columns = lambda: sys.maxint 208 printer._meter.number_of_columns = lambda: sys.maxint
207 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html', ' passed') 209 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html',
210 ' passed')
208 self.assertEqual(90, len(actual)) 211 self.assertEqual(90, len(actual))
209 self.assertEqual(actual, '[0/0] fast/dom/HTMLFormElement/associated-elem ents-after-index-assertion-fail1.html passed') 212 self.assertEqual(actual, '[0/0] fast/dom/HTMLFormElement/associated-elem ents-after-index-assertion-fail1.html passed')
210 213
211 printer._meter.number_of_columns = lambda: 18 214 printer._meter.number_of_columns = lambda: 18
212 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html', ' passed') 215 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html',
216 ' passed')
213 self.assertEqual(18, len(actual)) 217 self.assertEqual(18, len(actual))
214 self.assertEqual(actual, '[0/0] f...l passed') 218 self.assertEqual(actual, '[0/0] f...l passed')
215 219
216 printer._meter.number_of_columns = lambda: 10 220 printer._meter.number_of_columns = lambda: 10
217 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html', ' passed') 221 actual = printer._test_status_line('fast/dom/HTMLFormElement/associated- elements-after-index-assertion-fail1.html',
222 ' passed')
218 self.assertEqual(actual, '[0/0] associated-elements-after-index-assertio n-fail1.html passed') 223 self.assertEqual(actual, '[0/0] associated-elements-after-index-assertio n-fail1.html passed')
219 224
220 def test_details(self): 225 def test_details(self):
221 printer, err = self.get_printer(['--details']) 226 printer, err = self.get_printer(['--details'])
222 result = self.get_result('passes/image.html') 227 result = self.get_result('passes/image.html')
223 printer.print_started_test('passes/image.html') 228 printer.print_started_test('passes/image.html')
224 printer.print_finished_test(result, expected=False, exp_str='', got_str= '') 229 printer.print_finished_test(result, expected=False, exp_str='', got_str= '')
225 self.assertNotEmpty(err) 230 self.assertNotEmpty(err)
226 231
227 def test_print_found(self): 232 def test_print_found(self):
(...skipping 14 matching lines...) Expand all
242 printer.print_finished_test(result, expected=True, exp_str='', got_str=' ') 247 printer.print_finished_test(result, expected=True, exp_str='', got_str=' ')
243 248
244 printer.print_started_test('passes/text.html') 249 printer.print_started_test('passes/text.html')
245 result = self.get_result('passes/text.html') 250 result = self.get_result('passes/text.html')
246 printer.print_finished_test(result, expected=True, exp_str='', got_str=' ') 251 printer.print_finished_test(result, expected=True, exp_str='', got_str=' ')
247 252
248 # Only the first test's start should be printed. 253 # Only the first test's start should be printed.
249 lines = err.buflist 254 lines = err.buflist
250 self.assertEqual(len(lines), 1) 255 self.assertEqual(len(lines), 1)
251 self.assertTrue(lines[0].endswith('passes/image.html\n')) 256 self.assertTrue(lines[0].endswith('passes/image.html\n'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698