From b6f79b6844abacf89bd68a0d66a34ca9cf00af66 Mon Sep 17 00:00:00 2001
From: Julien Muchembled <jm@nexedi.com>
Date: Wed, 17 Oct 2012 23:03:08 +0200
Subject: [PATCH] ERP5Site_setupDummyMailHost: do not replace MailHost
 permanently

Similar to commit cc7b1372bf18d74a9b7640f3c32a60690fabd639
---
 .../ExtensionTemplateItem/MailHostUtils.py       | 16 +++++++++-------
 bt5/erp5_ui_test_core/bt/revision                |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/bt5/erp5_ui_test_core/ExtensionTemplateItem/MailHostUtils.py b/bt5/erp5_ui_test_core/ExtensionTemplateItem/MailHostUtils.py
index 64dcfab5b9..45d7a752da 100644
--- a/bt5/erp5_ui_test_core/ExtensionTemplateItem/MailHostUtils.py
+++ b/bt5/erp5_ui_test_core/ExtensionTemplateItem/MailHostUtils.py
@@ -26,14 +26,16 @@
 #
 ##############################################################################
 
+from ExtensionClass import pmc_init_of
 from Products.ERP5Type.tests.utils import DummyMailHost
 
 def setupDummyMailHost(self):
-  portal = self.getPortalObject()
-  # Replace MailHost by DummyMailHost
-  if 'MailHost' in portal.objectIds():
-    portal.manage_delObjects(['MailHost'])
-  portal._setObject('MailHost', DummyMailHost('MailHost'))
+  """Replace Original Mail Host by Dummy Mail Host in a non-persistent way
+
+  Copied & pasted from ERP5TypeTestCaseMixin._setUpDummyMailHost
+  """
+  cls = self.getPortalObject().portal.MailHost.__class__
+  if not issubclass(cls, DummyMailHostMixin):
+    cls.__bases__ = (DummyMailHostMixin,) + cls.__bases__
+    pmc_init_of(cls)
   return True
-  
-  
diff --git a/bt5/erp5_ui_test_core/bt/revision b/bt5/erp5_ui_test_core/bt/revision
index 2ebc6516c7..f0b5c72cad 100644
--- a/bt5/erp5_ui_test_core/bt/revision
+++ b/bt5/erp5_ui_test_core/bt/revision
@@ -1 +1 @@
-56
\ No newline at end of file
+57
\ No newline at end of file
-- 
2.30.9