[Zodb-checkins] CVS: Zope3/lib/python/Persistence/tests - testModule.py:1.18
Jeremy Hylton
jeremy@zope.com
Thu, 19 Sep 2002 18:07:03 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/tests
In directory cvs.zope.org:/tmp/cvs-serv14427/tests
Modified Files:
testModule.py
Log Message:
Add simple test of packages
=== Zope3/lib/python/Persistence/tests/testModule.py 1.17 => 1.18 ===
--- Zope3/lib/python/Persistence/tests/testModule.py:1.17 Thu Sep 19 17:37:21 2002
+++ Zope3/lib/python/Persistence/tests/testModule.py Thu Sep 19 18:07:02 2002
@@ -8,7 +8,7 @@
from Persistence.PersistentDict import PersistentDict
from Persistence.Module import \
PersistentModuleManager, PersistentModuleRegistry, \
- PersistentModuleImporter
+ PersistentModuleImporter, PersistentPackage
from Persistence import tests
from Transaction import get_transaction
@@ -63,7 +63,7 @@
self._registry = registry
def __import__(self, name, globals={}, locals={}, fromlist=[]):
- mod = self._registry.findModule(name)
+ mod = self._import(self._registry, name, fromlist)
if mod is not None:
return mod
return self._saved_import(name, globals, locals, fromlist)
@@ -220,6 +220,20 @@
i = o.m()
j = o.m()
self.assertEqual(i + 1, j)
+
+ def testPackage(self):
+ mgr = PersistentModuleManager(self.registry)
+ mgr.new("A.B.C", "def f(x): return x")
+ get_transaction().commit()
+
+ import A.B.C
+ self.assert_(isinstance(A, PersistentPackage))
+ self.assertEqual(A.B.C.f("A"), "A")
+
+ mgr = PersistentModuleManager(self.registry)
+ self.assertRaises(ValueError,
+ mgr.new, "A.B", "def f(x): return x + 1")
+
class TestModuleReload(unittest.TestCase):
"""Test reloading of modules"""