diff --git a/testing/marionette/harness/marionette_harness/marionette_test/testcases.py b/testing/marionette/harness/marionette_harness/marionette_test/testcases.py index e94af6d33591..e96e3a05a5c7 100644 --- a/testing/marionette/harness/marionette_harness/marionette_test/testcases.py +++ b/testing/marionette/harness/marionette_harness/marionette_test/testcases.py @@ -14,7 +14,11 @@ import unittest import warnings import weakref -from unittest.case import SkipTest +from unittest.case import ( + _ExpectedFailure, + _UnexpectedSuccess, + SkipTest, +) from marionette_driver.errors import ( TimeoutException, @@ -32,24 +36,6 @@ def _wraps_parameterized(func, func_suffix, args, kwargs): return wrapper -class ExpectedFailure(Exception): - """ - Raise this when a test is expected to fail. - - This is an implementation detail. - """ - - def __init__(self, exc_info): - super(ExpectedFailure, self).__init__() - self.exc_info = exc_info - - -class UnexpectedSuccess(Exception): - """ - The test was supposed to fail, but it didn't! - """ - - class MetaParameterized(type): """ A metaclass that allow a class to use decorators. @@ -149,14 +135,14 @@ class CommonTestCase(unittest.TestCase): try: self.setUp() except Exception: - raise ExpectedFailure(sys.exc_info()) + raise _ExpectedFailure(sys.exc_info()) else: self.setUp() except SkipTest as e: self._addSkip(result, str(e)) except (KeyboardInterrupt, UnresponsiveInstanceException): raise - except ExpectedFailure as e: + except _ExpectedFailure as e: expected_failure(result, e.exc_info) except Exception: self._enter_pm() @@ -167,8 +153,8 @@ class CommonTestCase(unittest.TestCase): try: testMethod() except Exception: - raise ExpectedFailure(sys.exc_info()) - raise UnexpectedSuccess + raise _ExpectedFailure(sys.exc_info()) + raise _UnexpectedSuccess else: testMethod() except self.failureException: @@ -176,9 +162,9 @@ class CommonTestCase(unittest.TestCase): result.addFailure(self, sys.exc_info()) except (KeyboardInterrupt, UnresponsiveInstanceException): raise - except ExpectedFailure as e: + except _ExpectedFailure as e: expected_failure(result, e.exc_info) - except UnexpectedSuccess: + except _UnexpectedSuccess: addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None) if addUnexpectedSuccess is not None: addUnexpectedSuccess(self) @@ -199,12 +185,12 @@ class CommonTestCase(unittest.TestCase): try: self.tearDown() except Exception: - raise ExpectedFailure(sys.exc_info()) + raise _ExpectedFailure(sys.exc_info()) else: self.tearDown() except (KeyboardInterrupt, UnresponsiveInstanceException): raise - except ExpectedFailure as e: + except _ExpectedFailure as e: expected_failure(result, e.exc_info) except Exception: self._enter_pm()