| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 sys | 5 import sys |
| 6 | 6 |
| 7 from telemetry.testing import serially_executed_browser_test_case | 7 from telemetry.testing import serially_executed_browser_test_case |
| 8 | 8 |
| 9 | 9 |
| 10 class SetUpClassFailedTest( | 10 class FailIfSetUpProcessCalledTwice( |
| 11 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): | 11 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): |
| 12 count = 0 |
| 12 | 13 |
| 13 @classmethod | 14 @classmethod |
| 14 def setUpClass(cls): | 15 def SetUpProcess(cls): |
| 15 raise Exception | 16 cls.count += 1 |
| 17 if cls.count >= 2: |
| 18 assert False, 'This should not be called more than once' |
| 16 | 19 |
| 17 @classmethod | 20 @classmethod |
| 18 def GenerateTestCases_DummyTest(cls, options): | 21 def GenerateTestCases_DummyTest(cls, options): |
| 19 del options # Unused. | 22 del options # Unused. |
| 20 for i in xrange(0, 100): | 23 for i in xrange(0, 3): |
| 21 yield 'dummy_test_%i' % i, () | 24 yield 'Dummy_%i' % i, () |
| 22 | 25 |
| 23 def DummyTest(self): | 26 def DummyTest(self): |
| 24 pass | 27 pass |
| 25 | 28 |
| 26 | 29 |
| 27 class TearDownClassFailedTest( | 30 class FailIfTearDownProcessCalledTwice( |
| 28 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): | 31 serially_executed_browser_test_case.SeriallyExecutedBrowserTestCase): |
| 32 count = 0 |
| 29 | 33 |
| 30 @classmethod | 34 @classmethod |
| 31 def tearDownClass(cls): | 35 def TearDownProcess(cls): |
| 32 raise Exception | 36 cls.count += 1 |
| 37 if cls.count >= 2: |
| 38 assert False, 'This should not be called more than once' |
| 33 | 39 |
| 34 @classmethod | 40 @classmethod |
| 35 def GenerateTestCases_DummyTest(cls, options): | 41 def GenerateTestCases_DummyTest(cls, options): |
| 36 del options # Unused. | 42 del options # Unused. |
| 37 for i in xrange(0, 100): | 43 for i in xrange(0, 3): |
| 38 yield 'dummy_test_%i' % i, () | 44 yield 'Dummy_%i' % i, () |
| 39 | 45 |
| 40 def DummyTest(self): | 46 def DummyTest(self): |
| 41 pass | 47 pass |
| 42 | 48 |
| 43 | 49 |
| 44 def load_tests(loader, tests, pattern): | 50 def load_tests(loader, tests, pattern): |
| 45 del loader, tests, pattern # Unused. | 51 del loader, tests, pattern # Unused. |
| 46 return serially_executed_browser_test_case.LoadAllTestsInModule( | 52 return serially_executed_browser_test_case.LoadAllTestsInModule( |
| 47 sys.modules[__name__]) | 53 sys.modules[__name__]) |
| OLD | NEW |