[Zope3-checkins] CVS: Zope3/lib/python/Persistence/tests - testModule.py:1.22
Jeremy Hylton
jeremy@zope.com
Fri, 20 Sep 2002 16:09:39 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence/tests
In directory cvs.zope.org:/tmp/cvs-serv11417/tests
Modified Files:
testModule.py
Log Message:
Add a test of __all__ support.
XXX It's incomplete because we need an __all__ in an __init__.
=== Zope3/lib/python/Persistence/tests/testModule.py 1.21 => 1.22 ===
--- Zope3/lib/python/Persistence/tests/testModule.py:1.21 Fri Sep 20 15:52:26 2002
+++ Zope3/lib/python/Persistence/tests/testModule.py Fri Sep 20 16:09:39 2002
@@ -283,6 +283,26 @@
except ImportError:
pass
+ def testImportAll(self):
+ mgr = PersistentModuleManager(self.registry)
+ mgr.new("A.B.C", """__all__ = ["a", "b"]; a, b, c = 1, 2, 3""")
+ get_transaction().commit()
+
+ from A.B.C import *
+ self.assertEqual(a, 1)
+ self.assertEqual(b, 2)
+ self.assertRaises(KeyError, locals().__getitem__, "c")
+
+ mgr = PersistentModuleManager(self.registry)
+ mgr.new("A.B.D", "from C import *")
+ get_transaction().commit()
+
+ import A.B.D
+ self.assert_(hasattr(A.B.D, "a"))
+ self.assert_(hasattr(A.B.D, "b"))
+ self.assert_(not hasattr(A.B.D, "c"))
+
+
class TestModuleReload(unittest.TestCase):
"""Test reloading of modules"""