[Zope3-checkins] SVN: Zope3/trunk/src/zope/testing/module.py Added
a helper module for having doctest text files masquerade as
Jim Fulton
jim at zope.com
Mon Jan 17 18:22:58 EST 2005
Log message for revision 28858:
Added a helper module for having doctest text files masquerade as
modules. This is necessary to test pickling or persistence.
Changed:
A Zope3/trunk/src/zope/testing/module.py
-=-
Added: Zope3/trunk/src/zope/testing/module.py
===================================================================
--- Zope3/trunk/src/zope/testing/module.py 2005-01-17 23:07:47 UTC (rev 28857)
+++ Zope3/trunk/src/zope/testing/module.py 2005-01-17 23:22:57 UTC (rev 28858)
@@ -0,0 +1,37 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation 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.
+#
+##############################################################################
+"""Fake module support
+
+$Id$
+"""
+
+import sys
+
+class FakeModule:
+ def __init__(self, dict):
+ self.__dict = dict
+ def __getattr__(self, name):
+ try:
+ return self.__dict[name]
+ except KeyError:
+ raise AttributeError, name
+
+def setUp(test, name='README.txt'):
+ dict = test.globs
+ dict.clear()
+ dict['__name__'] = name
+ sys.modules[name] = FakeModule(dict)
+
+def tearDown(test, name='README.txt'):
+ del sys.modules[name]
Property changes on: Zope3/trunk/src/zope/testing/module.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the Zope3-Checkins
mailing list