summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-02 15:26:09 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-03 10:40:21 +0100
commit967b45bc1a07ae0e2b3e9522b4857e773deacbd9 (patch)
tree00b8eb6edbe63cd86aa6a01410f2c878ff962a8c /tests
parentNeater is_presence_visible() code (diff)
downloadsynapse-967b45bc1a07ae0e2b3e9522b4857e773deacbd9.tar.xz
Allow optional non-suppression of exceptions through the Distributor
Diffstat (limited to 'tests')
-rw-r--r--tests/test_distributor.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/tests/test_distributor.py b/tests/test_distributor.py
index 21c91f335b..2869fdfd76 100644
--- a/tests/test_distributor.py
+++ b/tests/test_distributor.py
@@ -13,9 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import unittest
-
 from twisted.internet import defer
+from twisted.trial import unittest
 
 from mock import Mock, patch
 
@@ -75,6 +74,24 @@ class DistributorTestCase(unittest.TestCase):
             self.assertIsInstance(mock_logger.warning.call_args[0][0],
                     str)
 
+    @defer.inlineCallbacks
+    def test_signal_catch_no_suppress(self):
+        # Gut-wrenching
+        self.dist.suppress_failures = False
+
+        self.dist.declare("whail")
+
+        observer = Mock()
+        observer.return_value = defer.fail(
+            Exception("Oopsie")
+        )
+
+        self.dist.observe("whail", observer)
+
+        d = self.dist.fire("whail")
+
+        yield self.assertFailure(d, Exception)
+
     def test_signal_prereg(self):
         observer = Mock()
         self.dist.observe("flare", observer)
@@ -85,5 +102,6 @@ class DistributorTestCase(unittest.TestCase):
         observer.assert_called_with(4, 5)
 
     def test_signal_undeclared(self):
-        with self.assertRaises(KeyError):
+        def code():
             self.dist.fire("notification")
+        self.assertRaises(KeyError, code)