From 0db75089ef61ef5789a4be651ae60643e8b9eee3 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 14 Feb 2018 14:17:36 +0100 Subject: [PATCH] [FIX] base: prevent PhantomJS tests to send emails The emails sending is skipped during the tests. The mecanism to determine if the server was running tests was to check if the attribute `testing` was set for the thread. Unfortunately, this `testing` attribute is removed/set to false after the loading/installation of the modules is done, and phantomJS tests are ran post-installation, and therefore the emails that were potentialy sent following an action performed in a PhantomJS tour were not skipped. This occurred for instance in the tour `project.tour`, when the responsible of a task was changed, the sending of the assignation notification email was not skipped. In the case the machine on which the tests are ran does not have an smtp server (or mailcatcher) running on the port 25, this resulted in a test fail. --- odoo/addons/base/ir/ir_mail_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/ir/ir_mail_server.py b/odoo/addons/base/ir/ir_mail_server.py index bc4f51bebc1..6bb287ca69b 100644 --- a/odoo/addons/base/ir/ir_mail_server.py +++ b/odoo/addons/base/ir/ir_mail_server.py @@ -409,7 +409,7 @@ class IrMailServer(models.Model): message['To'] = x_forge_to # Do not actually send emails in testing mode! - if getattr(threading.currentThread(), 'testing', False): + if getattr(threading.currentThread(), 'testing', False) or self.env.registry.in_test_mode(): _test_logger.info("skip sending email in test mode") return message['Message-Id']