Backed out changeset a246bbc0c61c (bug 941158) for marionette bustage
authorWes Kocher <wkocher@mozilla.com>
Wed, 05 Feb 2014 15:17:52 -0800
changeset 178115 54c21f290a8d0e7bb5fccd4a4f0c4d555db95273
parent 178114 3515cd83e2aa0296ccfbc3e24b562626458fc33e
child 178116 fbc2aa4d5f78834818d6bdf358f8322ddcff73ec
push id5439
push userffxbld
push dateMon, 17 Mar 2014 23:08:15 +0000
treeherdermozilla-aurora@c0befb3c8038 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs941158
milestone30.0a1
backs outa246bbc0c61cfb3531a8df8c68da13d4bc1012c2
Backed out changeset a246bbc0c61c (bug 941158) for marionette bustage
testing/marionette/client/marionette/marionette_test.py
--- a/testing/marionette/client/marionette/marionette_test.py
+++ b/testing/marionette/client/marionette/marionette_test.py
@@ -94,28 +94,16 @@ class CommonTestCase(unittest.TestCase):
         if addSkip is not None:
             addSkip(self, reason)
         else:
             warnings.warn("TestResult has no addSkip method, skips not reported",
                           RuntimeWarning, 2)
             result.addSuccess(self)
 
     def run(self, result=None):
-        # Bug 967566 suggests refactoring run, which would hopefully
-        # mean getting rid of this inner function, which only sits
-        # here to reduce code duplication:
-        def expected_failure(result):
-            addExpectedFailure = getattr(result, "addExpectedFailure", None)
-            if addExpectedFailure is not None:
-                addExpectedFailure(self, e.exc_info)
-            else:
-                warnings.warn("TestResult has no addExpectedFailure method, "
-                              "reporting as passes", RuntimeWarning)
-                result.addSuccess(self)
-
         self.start_time = time.time()
         orig_result = result
         if result is None:
             result = self.defaultTestResult()
             startTestRun = getattr(result, 'startTestRun', None)
             if startTestRun is not None:
                 startTestRun()
 
@@ -131,75 +119,65 @@ class CommonTestCase(unittest.TestCase):
                 self._addSkip(result, skip_why)
             finally:
                 result.stopTest(self)
             self.stop_time = time.time()
             return
         try:
             success = False
             try:
-                if self.expected == "fail":
-                    try:
-                        self.setUp()
-                    except Exception:
-                        raise _ExpectedFailure(sys.exc_info())
-                else:
-                    self.setUp()
+                self.setUp()
             except SkipTest as e:
                 self._addSkip(result, str(e))
             except KeyboardInterrupt:
                 raise
-            except _ExpectedFailure:
-                expected_failure(result)
             except:
                 result.addError(self, sys.exc_info())
             else:
                 try:
                     if self.expected == 'fail':
                         try:
                             testMethod()
-                        except:
+                        except Exception:
                             raise _ExpectedFailure(sys.exc_info())
                         raise _UnexpectedSuccess
                     else:
                         testMethod()
                 except self.failureException:
                     result.addFailure(self, sys.exc_info())
                 except KeyboardInterrupt:
                     raise
                 except self.failureException:
                     result.addFailure(self, sys.exc_info())
-                except _ExpectedFailure:
-                    expected_failure(result)
+                except _ExpectedFailure as e:
+                    addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+                    if addExpectedFailure is not None:
+                        addExpectedFailure(self, e.exc_info)
+                    else:
+                        warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
+                                      RuntimeWarning)
+                        result.addSuccess(self)
                 except _UnexpectedSuccess:
                     addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
                     if addUnexpectedSuccess is not None:
                         addUnexpectedSuccess(self)
                     else:
                         warnings.warn("TestResult has no addUnexpectedSuccess method, reporting as failures",
                                       RuntimeWarning)
                         result.addFailure(self, sys.exc_info())
                 except SkipTest as e:
                     self._addSkip(result, str(e))
                 except:
                     result.addError(self, sys.exc_info())
                 else:
                     success = True
                 try:
-                    if self.expected == "fail":
-                        try:
-                            self.tearDown()
-                        except:
-                            raise _ExpectedFailure(sys.exc_info())
-                    else:
-                        self.tearDown()
+                    self.tearDown()
                 except KeyboardInterrupt:
                     raise
-                except _ExpectedFailure:
-                    expected_failure(result)
                 except:
                     result.addError(self, sys.exc_info())
                     success = False
             # Here we could handle doCleanups() instead of calling cleanTest directly
             self.cleanTest()
 
             if success:
                 result.addSuccess(self)