[Zope3-checkins] CVS: StandaloneZConfig/ZConfig/tests - test_datatypes.py:1.11

Fred L. Drake, Jr. fred at zope.com
Tue Mar 16 16:28:41 EST 2004


Update of /cvs-repository/StandaloneZConfig/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv5818/ZConfig/tests

Modified Files:
	test_datatypes.py 
Log Message:
ZConfig must not mask imports from the top level that happen to have a dotted
name beginning with a name found inside ZConfig; datatypes are not specified
relative to the ZConfig package


=== StandaloneZConfig/ZConfig/tests/test_datatypes.py 1.10 => 1.11 ===
--- StandaloneZConfig/ZConfig/tests/test_datatypes.py:1.10	Thu Feb  5 11:40:29 2004
+++ StandaloneZConfig/ZConfig/tests/test_datatypes.py	Tue Mar 16 16:28:40 2004
@@ -15,6 +15,7 @@
 
 import os
 import sys
+import shutil
 import socket
 import tempfile
 import unittest
@@ -327,8 +328,37 @@
         raises(ValueError, convert, '120w')
 
 
+class RegistryTestCase(unittest.TestCase):
+
+    def test_registry_does_not_mask_toplevel_imports(self):
+        old_sys_path = sys.path[:]
+        tmpdir = tempfile.mkdtemp(prefix="test_datatypes_")
+        fn = os.path.join(tmpdir, "datatypes.py")
+        f = open(fn, "w")
+        f.write(TEST_DATATYPE_SOURCE)
+        f.close()
+        registry = ZConfig.datatypes.Registry()
+
+        # we really want the temp area to override everything else:
+        sys.path.insert(0, tmpdir)
+        try:
+            datatype = registry.get("datatypes.my_sample_datatype")
+        finally:
+            shutil.rmtree(tmpdir)
+            sys.path[:] = old_sys_path
+        self.assertEqual(datatype, 42)
+
+TEST_DATATYPE_SOURCE = """
+# sample datatypes file
+
+my_sample_datatype = 42
+"""
+
+
 def test_suite():
-    return unittest.makeSuite(DatatypeTestCase)
+    suite = unittest.makeSuite(DatatypeTestCase)
+    suite.addTest(unittest.makeSuite(RegistryTestCase))
+    return suite
 
 
 if __name__ == '__main__':




More information about the Zope3-Checkins mailing list