--- a/devtools/testlib.py Mon Oct 04 19:09:09 2010 +0200
+++ b/devtools/testlib.py Wed Oct 06 10:46:20 2010 +0200
@@ -45,6 +45,7 @@
from cubicweb.sobjects import notification
from cubicweb.web import Redirect, application
from cubicweb.server.session import security_enabled
+from cubicweb.server.hook import SendMailOp
from cubicweb.devtools import SYSTEM_ENTITIES, SYSTEM_RELATIONS, VIEW_VALIDATORS
from cubicweb.devtools import BASE_URL, fake, htmlparser
from cubicweb.utils import json
@@ -291,6 +292,9 @@
# default test setup and teardown #########################################
def setUp(self):
+ # monkey patch send mail operation so emails are sent synchronously
+ self._old_mail_commit_event = SendMailOp.commit_event
+ SendMailOp.commit_event = SendMailOp.sendmails
pause_tracing()
previous_failure = self.__class__.__dict__.get('_repo_init_failed')
if previous_failure is not None:
@@ -312,6 +316,7 @@
for cnx in self._cnxs:
if not cnx._closed:
cnx.close()
+ SendMailOp.commit_event = self._old_mail_commit_event
def setup_database(self):
"""add your database setup code by overriding this method"""