prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Exceptions in `setup_test` should leave the test in `ERROR` status
  Regardless of the type of the exception, `setup_test` error should cause `ERROR` status.
  
  This is different from a test method.
  In a test method, an exception based on signals.TestFailure should cause the test to exit with `FAILED` status.
  
  This is to be consistent with pyunit's behavior.
  
  </issue>
  <code>
  [start of mobly/signals.py]
  1 # Copyright 2016 Google Inc.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 """This module is where all the test signal classes and related utilities live.
  15 """
  16 
  17 import functools
  18 import json
  19 
  20 
  21 class TestSignalError(Exception):
  22     """Raised when an error occurs inside a test signal."""
  23 
  24 
  25 class TestSignal(Exception):
  26     """Base class for all test result control signals. This is used to signal
  27     the result of a test.
  28 
  29     Attribute:
  30         details: A string that describes the reason for raising this signal.
  31         extras: A json-serializable data type to convey extra information about
  32             a test result.
  33     """
  34 
  35     def __init__(self, details, extras=None):
  36         super(TestSignal, self).__init__(details)
  37         self.details = str(details)
  38         try:
  39             json.dumps(extras)
  40             self.extras = extras
  41         except TypeError:
  42             raise TestSignalError('Extras must be json serializable. %s '
  43                                   'is not.' % extras)
  44 
  45     def __str__(self):
  46         return 'Details=%s, Extras=%s' % (self.details, self.extras)
  47 
  48 
  49 class TestFailure(TestSignal):
  50     """Raised when a test has failed."""
  51 
  52 
  53 class TestPass(TestSignal):
  54     """Raised when a test has passed."""
  55 
  56 
  57 class TestSkip(TestSignal):
  58     """Raised when a test has been skipped."""
  59 
  60 
  61 class TestAbortClass(TestSignal):
  62     """Raised when all subsequent tests within the same test class should
  63     be aborted.
  64     """
  65 
  66 
  67 class TestAbortAll(TestSignal):
  68     """Raised when all subsequent tests should be aborted."""
  69 
  70 
  71 class ControllerError(Exception):
  72     """Raised when an error occured in controller classes."""
  73
  [end of mobly/signals.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mobly/signals.py b/mobly/signals.py
  --- a/mobly/signals.py
  +++ b/mobly/signals.py
  @@ -46,6 +46,10 @@
           return 'Details=%s, Extras=%s' % (self.details, self.extras)
   
   
  +class TestError(TestSignal):
  +    """Raised when a test has an unexpected error."""
  +
  +
   class TestFailure(TestSignal):
       """Raised when a test has failed."""
  
verification_info: {"golden_diff": "diff --git a/mobly/signals.py b/mobly/signals.py\n--- a/mobly/signals.py\n+++ b/mobly/signals.py\n@@ -46,6 +46,10 @@\n         return 'Details=%s, Extras=%s' % (self.details, self.extras)\n \n \n+class TestError(TestSignal):\n+    \"\"\"Raised when a test has an unexpected error.\"\"\"\n+\n+\n class TestFailure(TestSignal):\n     \"\"\"Raised when a test has failed.\"\"\"\n", "issue": "Exceptions in `setup_test` should leave the test in `ERROR` status\nRegardless of the type of the exception, `setup_test` error should cause `ERROR` status.\r\n\r\nThis is different from a test method.\r\nIn a test method, an exception based on signals.TestFailure should cause the test to exit with `FAILED` status.\r\n\r\nThis is to be consistent with pyunit's behavior.\n", "before_files": [{"content": "# Copyright 2016 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"This module is where all the test signal classes and related utilities live.\n\"\"\"\n\nimport functools\nimport json\n\n\nclass TestSignalError(Exception):\n    \"\"\"Raised when an error occurs inside a test signal.\"\"\"\n\n\nclass TestSignal(Exception):\n    \"\"\"Base class for all test result control signals. This is used to signal\n    the result of a test.\n\n    Attribute:\n        details: A string that describes the reason for raising this signal.\n        extras: A json-serializable data type to convey extra information about\n            a test result.\n    \"\"\"\n\n    def __init__(self, details, extras=None):\n        super(TestSignal, self).__init__(details)\n        self.details = str(details)\n        try:\n            json.dumps(extras)\n            self.extras = extras\n        except TypeError:\n            raise TestSignalError('Extras must be json serializable. %s '\n                                  'is not.' % extras)\n\n    def __str__(self):\n        return 'Details=%s, Extras=%s' % (self.details, self.extras)\n\n\nclass TestFailure(TestSignal):\n    \"\"\"Raised when a test has failed.\"\"\"\n\n\nclass TestPass(TestSignal):\n    \"\"\"Raised when a test has passed.\"\"\"\n\n\nclass TestSkip(TestSignal):\n    \"\"\"Raised when a test has been skipped.\"\"\"\n\n\nclass TestAbortClass(TestSignal):\n    \"\"\"Raised when all subsequent tests within the same test class should\n    be aborted.\n    \"\"\"\n\n\nclass TestAbortAll(TestSignal):\n    \"\"\"Raised when all subsequent tests should be aborted.\"\"\"\n\n\nclass ControllerError(Exception):\n    \"\"\"Raised when an error occured in controller classes.\"\"\"\n", "path": "mobly/signals.py"}]}