[enh] don't catch all exceptions in notification hooks during tests
authorLaurent Peuch <cortex@worlddomination.be>
Tue, 23 Apr 2019 09:33:52 +0200
changeset 12583 4f59a56e6d89
parent 12582 2b0a3f2607f0
child 12584 6eba53763482
[enh] don't catch all exceptions in notification hooks during tests
cubicweb/hooks/notification.py
doc/changes/3.27.rst
--- a/cubicweb/hooks/notification.py	Thu Apr 18 15:09:36 2019 +0200
+++ b/cubicweb/hooks/notification.py	Tue Apr 23 09:33:52 2019 +0200
@@ -70,6 +70,12 @@
                 # to prevent them all.
                 self.exception('Notification failed')
 
+                if self.cnx.vreg.config.mode == "test":
+                    # reraise in testing context because we actually want to
+                    # have those exceptions here and that self.exception is
+                    # filtered in test context
+                    raise
+
 
 class NotificationHook(hook.Hook):
     __abstract__ = True
--- a/doc/changes/3.27.rst	Thu Apr 18 15:09:36 2019 +0200
+++ b/doc/changes/3.27.rst	Tue Apr 23 09:33:52 2019 +0200
@@ -27,6 +27,10 @@
 
 * Python 2 support has been dropped.
 
+* Exceptions in notification hooks aren't catched-all anymore during tests so
+  one can expect tests that seem to pass (but were actually silently failing)
+  to fail now.
+
 Deprecated code drops
 ---------------------