[Checkins] SVN: transaction/branches/sphinx/ Move utility helpers into shared module.
Tres Seaver
cvs-admin at zope.org
Mon Dec 17 22:09:05 UTC 2012
Log message for revision 128716:
Move utility helpers into shared module.
Changed:
_U transaction/branches/sphinx/
U transaction/branches/sphinx/docs/hooks.rst
A transaction/branches/sphinx/transaction/tests/common.py
U transaction/branches/sphinx/transaction/tests/test__transaction.py
-=-
Modified: transaction/branches/sphinx/docs/hooks.rst
===================================================================
--- transaction/branches/sphinx/docs/hooks.rst 2012-12-17 22:09:04 UTC (rev 128715)
+++ transaction/branches/sphinx/docs/hooks.rst 2012-12-17 22:09:04 UTC (rev 128716)
@@ -104,9 +104,9 @@
>>> t.addBeforeCommitHook(hook, '2')
- >>> from transaction.tests.test__transaction import DummyFile
- >>> from transaction.tests.test__transaction import Monkey
- >>> from transaction.tests.test__transaction import assertRaisesEx
+ >>> from transaction.tests.common import DummyFile
+ >>> from transaction.tests.common import Monkey
+ >>> from transaction.tests.common import assertRaisesEx
>>> from transaction import _transaction
>>> buffer = DummyFile()
>>> with Monkey(_transaction, _TB_BUFFER=buffer):
@@ -270,9 +270,9 @@
>>> t.join(FailingDataManager())
>>> t.addAfterCommitHook(hook, '2')
- >>> from transaction.tests.test__transaction import DummyFile
- >>> from transaction.tests.test__transaction import Monkey
- >>> from transaction.tests.test__transaction import assertRaisesEx
+ >>> from transaction.tests.common import DummyFile
+ >>> from transaction.tests.common import Monkey
+ >>> from transaction.tests.common import assertRaisesEx
>>> from transaction import _transaction
>>> buffer = DummyFile()
>>> with Monkey(_transaction, _TB_BUFFER=buffer):
Added: transaction/branches/sphinx/transaction/tests/common.py
===================================================================
--- transaction/branches/sphinx/transaction/tests/common.py (rev 0)
+++ transaction/branches/sphinx/transaction/tests/common.py 2012-12-17 22:09:04 UTC (rev 128716)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# Copyright (c) 2012 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+
+class DummyFile(object):
+ def __init__(self):
+ self._lines = []
+ def write(self, text):
+ self._lines.append(text)
+ def writelines(self, lines):
+ self._lines.extend(lines)
+
+class Monkey(object):
+ # context-manager for replacing module names in the scope of a test.
+ def __init__(self, module, **kw):
+ self.module = module
+ self.to_restore = dict([(key, getattr(module, key)) for key in kw])
+ for key, value in kw.items():
+ setattr(module, key, value)
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ for key, value in self.to_restore.items():
+ setattr(self.module, key, value)
+
+def assertRaisesEx(e_type, checked, *args, **kw):
+ try:
+ checked(*args, **kw)
+ except e_type as e:
+ return e
+ raise AssertionError("Didn't raise: %s" % e_type.__name__)
Modified: transaction/branches/sphinx/transaction/tests/test__transaction.py
===================================================================
--- transaction/branches/sphinx/transaction/tests/test__transaction.py 2012-12-17 22:09:04 UTC (rev 128715)
+++ transaction/branches/sphinx/transaction/tests/test__transaction.py 2012-12-17 22:09:04 UTC (rev 128716)
@@ -39,37 +39,6 @@
import unittest
-class DummyFile(object):
- def __init__(self):
- self._lines = []
- def write(self, text):
- self._lines.append(text)
- def writelines(self, lines):
- self._lines.extend(lines)
-
-class Monkey(object):
- # context-manager for replacing module names in the scope of a test.
- def __init__(self, module, **kw):
- self.module = module
- self.to_restore = dict([(key, getattr(module, key)) for key in kw])
- for key, value in kw.items():
- setattr(module, key, value)
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- for key, value in self.to_restore.items():
- setattr(self.module, key, value)
-
-def assertRaisesEx(e_type, checked, *args, **kw):
- try:
- checked(*args, **kw)
- except e_type as e:
- return e
- raise AssertionError("Didn't raise: %s" % e_type.__name__)
-
-
class TransactionTests(unittest.TestCase):
def _getTargetClass(self):
More information about the checkins
mailing list