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

Side by Side Diff: telemetry/telemetry/benchmark_runner_unittest.py

Issue 2978643002: Removing bad-continuation param and fixing resulting errors. Fixed indentation errors, in telemetry… (Closed)
Patch Set: Created 3 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 from telemetry import benchmark 7 from telemetry import benchmark
8 from telemetry import benchmark_runner 8 from telemetry import benchmark_runner
9 from telemetry.testing import stream 9 from telemetry.testing import stream
10 import mock 10 import mock
(...skipping 27 matching lines...) Expand all
38 self._mock_possible_browser.browser_type = 'TestBrowser' 38 self._mock_possible_browser.browser_type = 'TestBrowser'
39 39
40 def testPrintBenchmarkListWithNoDisabledBenchmark(self): 40 def testPrintBenchmarkListWithNoDisabledBenchmark(self):
41 expected_printed_stream = ( 41 expected_printed_stream = (
42 'Available benchmarks for TestBrowser are:\n' 42 'Available benchmarks for TestBrowser are:\n'
43 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n' 43 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n'
44 ' FooBenchmark Benchmark Foo for testing.\n' 44 ' FooBenchmark Benchmark Foo for testing.\n'
45 'Pass --browser to list benchmarks for another browser.\n\n') 45 'Pass --browser to list benchmarks for another browser.\n\n')
46 with mock.patch('telemetry.benchmark_runner.decorators') as mock_module: 46 with mock.patch('telemetry.benchmark_runner.decorators') as mock_module:
47 mock_module.IsEnabled.return_value = (True, None) 47 mock_module.IsEnabled.return_value = (True, None)
48 benchmark_runner.PrintBenchmarkList( 48 benchmark_runner.PrintBenchmarkList(\
49 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream) 49 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream)
50 self.assertEquals(expected_printed_stream, self._stream.output_data) 50 self.assertEquals(expected_printed_stream, self._stream.output_data)
51 51
52 def testPrintBenchmarkListWithOneDisabledBenchmark(self): 52 def testPrintBenchmarkListWithOneDisabledBenchmark(self):
53 expected_printed_stream = ( 53 expected_printed_stream = (
54 'Available benchmarks for TestBrowser are:\n' 54 'Available benchmarks for TestBrowser are:\n'
55 ' FooBenchmark Benchmark Foo for testing.\n' 55 ' FooBenchmark Benchmark Foo for testing.\n'
56 '\n' 56 '\n'
57 'Disabled benchmarks for TestBrowser are (force run with -d):\n' 57 'Disabled benchmarks for TestBrowser are (force run with -d):\n'
58 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n' 58 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n'
59 'Pass --browser to list benchmarks for another browser.\n\n') 59 'Pass --browser to list benchmarks for another browser.\n\n')
60 with mock.patch('telemetry.benchmark_runner.decorators') as mock_module: 60 with mock.patch('telemetry.benchmark_runner.decorators') as mock_module:
61 def FakeIsEnabled(benchmark_class, _): 61 def FakeIsEnabled(benchmark_class, _):
62 if benchmark_class is BenchmarkFoo: 62 if benchmark_class is BenchmarkFoo:
63 return True 63 return True
64 else: 64 else:
65 return False 65 return False
66 66
67 mock_module.IsBenchmarkEnabled = FakeIsEnabled 67 mock_module.IsBenchmarkEnabled = FakeIsEnabled
68 benchmark_runner.PrintBenchmarkList( 68 benchmark_runner.PrintBenchmarkList(\
69 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream) 69 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream)
70 self.assertEquals(expected_printed_stream, self._stream.output_data) 70 self.assertEquals(expected_printed_stream, self._stream.output_data)
71 71
72 def testShouldDisable(self): 72 def testShouldDisable(self):
73 """Ensure that overridden ShouldDisable class methods are respected.""" 73 """Ensure that overridden ShouldDisable class methods are respected."""
74 expected_printed_stream = ( 74 expected_printed_stream = (
75 'Available benchmarks for TestBrowser are:\n' 75 'Available benchmarks for TestBrowser are:\n'
76 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n' 76 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n'
77 '\n' 77 '\n'
78 'Disabled benchmarks for TestBrowser are (force run with -d):\n' 78 'Disabled benchmarks for TestBrowser are (force run with -d):\n'
79 ' FooBenchmark Benchmark Foo for testing.\n' 79 ' FooBenchmark Benchmark Foo for testing.\n'
80 'Pass --browser to list benchmarks for another browser.\n\n') 80 'Pass --browser to list benchmarks for another browser.\n\n')
81 @classmethod 81 @classmethod
82 def FakeShouldDisable(cls, possible_browser): 82 def FakeShouldDisable(cls, possible_browser):
83 del possible_browser # unused 83 del possible_browser # unused
84 return cls is BenchmarkFoo 84 return cls is BenchmarkFoo
85 BenchmarkFoo.ShouldDisable = FakeShouldDisable 85 BenchmarkFoo.ShouldDisable = FakeShouldDisable
86 BenchmarkBar.ShouldDisable = FakeShouldDisable 86 BenchmarkBar.ShouldDisable = FakeShouldDisable
87 benchmark_runner.PrintBenchmarkList( 87 benchmark_runner.PrintBenchmarkList(\
88 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream) 88 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream)
89 self.assertEquals(expected_printed_stream, self._stream.output_data) 89 self.assertEquals(expected_printed_stream, self._stream.output_data)
90 90
91 def testShouldDisableComplex(self): 91 def testShouldDisableComplex(self):
92 """Ensure that browser-dependent ShouldDisable overrides are respected.""" 92 """Ensure that browser-dependent ShouldDisable overrides are respected."""
93 expected_printed_stream = ( 93 expected_printed_stream = (
94 # Expected output for 'TestBrowser': 94 # Expected output for 'TestBrowser':
95 'Available benchmarks for TestBrowser are:\n' 95 'Available benchmarks for TestBrowser are:\n'
96 ' FooBenchmark Benchmark Foo for testing.\n' 96 ' FooBenchmark Benchmark Foo for testing.\n'
97 '\n' 97 '\n'
98 'Disabled benchmarks for TestBrowser are (force run with -d):\n' 98 'Disabled benchmarks for TestBrowser are (force run with -d):\n'
99 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n' 99 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n'
100 'Pass --browser to list benchmarks for another browser.\n\n' 100 'Pass --browser to list benchmarks for another browser.\n\n'
101 # Expected output for 'MockBrowser': 101 # Expected output for 'MockBrowser':
102 'Available benchmarks for MockBrowser are:\n' 102 'Available benchmarks for MockBrowser are:\n'
103 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n' 103 ' BarBenchmarkkkkk Benchmark Bar for testing long description line.\n'
104 ' FooBenchmark Benchmark Foo for testing.\n' 104 ' FooBenchmark Benchmark Foo for testing.\n'
105 'Pass --browser to list benchmarks for another browser.\n\n') 105 'Pass --browser to list benchmarks for another browser.\n\n')
106 @classmethod 106 @classmethod
107 def FakeShouldDisable(cls, possible_browser): 107 def FakeShouldDisable(cls, possible_browser):
108 return cls is BenchmarkBar and not 'Mock' in possible_browser.browser_type 108 return cls is BenchmarkBar and not 'Mock' in possible_browser.browser_type
109 BenchmarkFoo.ShouldDisable = FakeShouldDisable 109 BenchmarkFoo.ShouldDisable = FakeShouldDisable
110 BenchmarkBar.ShouldDisable = FakeShouldDisable 110 BenchmarkBar.ShouldDisable = FakeShouldDisable
111 benchmark_runner.PrintBenchmarkList( 111 benchmark_runner.PrintBenchmarkList(\
112 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream) 112 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream)
113 self._mock_possible_browser.browser_type = 'MockBrowser' 113 self._mock_possible_browser.browser_type = 'MockBrowser'
114 benchmark_runner.PrintBenchmarkList( 114 benchmark_runner.PrintBenchmarkList(\
115 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream) 115 [BenchmarkFoo, BenchmarkBar], self._mock_possible_browser, self._stream)
116 self.assertEquals(expected_printed_stream, self._stream.output_data) 116 self.assertEquals(expected_printed_stream, self._stream.output_data)
OLDNEW
« no previous file with comments | « telemetry/telemetry/benchmark_runner.py ('k') | telemetry/telemetry/core/android_action_runner_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698