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

Side by Side Diff: build/android/pylib/base/test_dispatcher_unittest.py

Issue 132463007: Enable presubmit pylint in build/android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 """Unittests for test_dispatcher.py.""" 5 """Unittests for test_dispatcher.py."""
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import unittest 9 import unittest
10 10
11 sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 11 sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)),
12 os.pardir, os.pardir)) 12 os.pardir, os.pardir))
13 13
14 # Mock out android_commands.GetAttachedDevices(). 14 # Mock out android_commands.GetAttachedDevices().
15 from pylib import android_commands 15 from pylib import android_commands
16 android_commands.GetAttachedDevices = lambda: ['0', '1'] 16 android_commands.GetAttachedDevices = lambda: ['0', '1']
17 from pylib import constants 17 from pylib import constants
18 from pylib.utils import watchdog_timer 18 from pylib.utils import watchdog_timer
19 19
20 import base_test_result 20 from . import base_test_result
21 import test_dispatcher 21 from . import test_dispatcher
22 22
23 23
24 class TestException(Exception): 24 class TestException(Exception):
25 pass 25 pass
26 26
27 27
28 class MockRunner(object): 28 class MockRunner(object):
29 """A mock TestRunner.""" 29 """A mock TestRunner."""
30 def __init__(self, device='0', shard_index=0): 30 def __init__(self, device='0', shard_index=0):
31 self.device = device 31 self.device = device
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 results, exit_code = test_dispatcher.RunTests( 184 results, exit_code = test_dispatcher.RunTests(
185 [], MockRunner, ['0', '1'], shard=True) 185 [], MockRunner, ['0', '1'], shard=True)
186 self.assertEqual(len(results.GetAll()), 0) 186 self.assertEqual(len(results.GetAll()), 0)
187 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) 187 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE)
188 188
189 def testTestsRemainWithAllDevicesOffline(self): 189 def testTestsRemainWithAllDevicesOffline(self):
190 attached_devices = android_commands.GetAttachedDevices 190 attached_devices = android_commands.GetAttachedDevices
191 android_commands.GetAttachedDevices = lambda: [] 191 android_commands.GetAttachedDevices = lambda: []
192 try: 192 try:
193 with self.assertRaises(AssertionError): 193 with self.assertRaises(AssertionError):
194 results, exit_code = TestShard._RunShard(MockRunner) 194 _results, _exit_code = TestShard._RunShard(MockRunner)
195 finally: 195 finally:
196 android_commands.GetAttachedDevices = attached_devices 196 android_commands.GetAttachedDevices = attached_devices
197 197
198 198
199 class TestReplicate(unittest.TestCase): 199 class TestReplicate(unittest.TestCase):
200 """Tests test_dispatcher.RunTests with replication.""" 200 """Tests test_dispatcher.RunTests with replication."""
201 @staticmethod 201 @staticmethod
202 def _RunReplicate(runner_factory): 202 def _RunReplicate(runner_factory):
203 return test_dispatcher.RunTests( 203 return test_dispatcher.RunTests(
204 ['a', 'b', 'c'], runner_factory, ['0', '1'], shard=False) 204 ['a', 'b', 'c'], runner_factory, ['0', '1'], shard=False)
(...skipping 12 matching lines...) Expand all
217 217
218 def testNoTests(self): 218 def testNoTests(self):
219 results, exit_code = test_dispatcher.RunTests( 219 results, exit_code = test_dispatcher.RunTests(
220 [], MockRunner, ['0', '1'], shard=False) 220 [], MockRunner, ['0', '1'], shard=False)
221 self.assertEqual(len(results.GetAll()), 0) 221 self.assertEqual(len(results.GetAll()), 0)
222 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE) 222 self.assertEqual(exit_code, constants.ERROR_EXIT_CODE)
223 223
224 224
225 if __name__ == '__main__': 225 if __name__ == '__main__':
226 unittest.main() 226 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698