From 4ed26f94d796fa4317d9e037c09c4a8db0f563d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Tue, 20 Nov 2012 13:52:52 +0100
Subject: [PATCH] Share method in module.

---
 .../TestTemplateItem/testSlapOSAccountingAlarm.py   | 11 +----------
 .../TestTemplateItem/testSlapOSAccountingRule.py    | 13 +------------
 master/product/SlapOS/tests/testSlapOSMixin.py      | 10 ++++++++++
 3 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingAlarm.py b/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingAlarm.py
index 56f11c77c..4460a3aa2 100644
--- a/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingAlarm.py
+++ b/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingAlarm.py
@@ -9,7 +9,7 @@ import transaction
 import functools
 from Products.ERP5Type.tests.utils import createZODBPythonScript
 from Products.SlapOS.tests.testSlapOSMixin import \
-  testSlapOSMixin
+  testSlapOSMixin, withAbort
 import os
 import tempfile
 from DateTime import DateTime
@@ -1175,15 +1175,6 @@ class TestHostingSubscription_requestUpdateOpenSaleOrder(testSlapOSMixin):
     self.assertEqual(request_time_2, validated_line_2.getStartDate())
     self.assertEqual(stop_date_2, validated_line_2.getStopDate())
 
-def withAbort(func):
-  @functools.wraps(func)
-  def wrapped(self, *args, **kwargs):
-    try:
-      func(self, *args, **kwargs)
-    finally:
-      transaction.abort()
-  return wrapped
-
 class Simulator:
   def __init__(self, outfile, method, to_return=None):
     self.outfile = outfile
diff --git a/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingRule.py b/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingRule.py
index 3f7b2c997..dce96e31f 100644
--- a/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingRule.py
+++ b/master/bt5/slapos_accounting/TestTemplateItem/testSlapOSAccountingRule.py
@@ -6,20 +6,9 @@
 ##############################################################################
 
 from Products.SlapOS.tests.testSlapOSMixin import \
-  testSlapOSMixin
+  testSlapOSMixin, withAbort
 from DateTime import DateTime
 from Products.ERP5Type.DateUtils import addToDate
-import transaction
-import functools
-
-def withAbort(func):
-  @functools.wraps(func)
-  def wrapped(self, *args, **kwargs):
-    try:
-      func(self, *args, **kwargs)
-    finally:
-      transaction.abort()
-  return wrapped
 
 class TestDefaultInvoiceTransactionRule(testSlapOSMixin):
   @withAbort
diff --git a/master/product/SlapOS/tests/testSlapOSMixin.py b/master/product/SlapOS/tests/testSlapOSMixin.py
index df4d5b29b..5cf65ebf0 100644
--- a/master/product/SlapOS/tests/testSlapOSMixin.py
+++ b/master/product/SlapOS/tests/testSlapOSMixin.py
@@ -30,8 +30,18 @@ import random
 import transaction
 import unittest
 import Products.Vifib.tests.VifibMixin
+import functools
 from Products.ERP5Type.tests.utils import DummyMailHost
 
+def withAbort(func):
+  @functools.wraps(func)
+  def wrapped(self, *args, **kwargs):
+    try:
+      func(self, *args, **kwargs)
+    finally:
+      transaction.abort()
+  return wrapped
+
 class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin):
 
   def _setUpDummyMailHost(self):
-- 
2.30.9