| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import sys |
| 6 import unittest |
| 7 |
| 8 from selenium.common.exceptions import TimeoutException |
| 9 |
| 10 # Local Imports |
| 11 from autofill_task.exceptions import ExpectationFailure |
| 12 from .flow import AutofillTestFlow |
| 13 |
| 14 class AutofillTestCase(unittest.TestCase): |
| 15 """Wraps a single autofill test flow for use with the unittest library. |
| 16 |
| 17 task_class: AutofillTask to use for the test. |
| 18 profile: Dict of profile data that acts as the master source for |
| 19 validating autofill behaviour. |
| 20 debug: Whether debug output should be printed (False if not specified). |
| 21 """ |
| 22 def __init__(self, task_class, user_data_dir, profile, chrome_binary=None, |
| 23 debug=False): |
| 24 super(AutofillTestCase, self).__init__('run') |
| 25 self._flow = AutofillTestFlow(task_class, profile, debug=debug) |
| 26 self._user_data_dir = user_data_dir |
| 27 self._chrome_binary = chrome_binary |
| 28 self._debug = debug |
| 29 |
| 30 def __str__(self): |
| 31 return str(self._flow) |
| 32 |
| 33 def run(self, result): |
| 34 result.startTest(self) |
| 35 |
| 36 try: |
| 37 self._flow.run(self._user_data_dir, chrome_binary=self._chrome_binary) |
| 38 except KeyboardInterrupt: |
| 39 raise |
| 40 except (TimeoutException, ExpectationFailure): |
| 41 result.addFailure(self, sys.exc_info()) |
| 42 except: |
| 43 result.addError(self, sys.exc_info()) |
| 44 else: |
| 45 result.addSuccess(self) |
| 46 finally: |
| 47 result.stopTest(self) |
| OLD | NEW |