[Zope-CVS] SVN: zpkgtools/trunk/zpkgtools/ add a test that <resources> sections in the configuration file may not be

Fred L. Drake, Jr. fdrake at gmail.com
Mon Aug 29 12:51:44 EDT 2005


Log message for revision 38143:
  add a test that <resources> sections in the configuration file may not be
  nested, and fix a corresponding bug in the implementation
  

Changed:
  U   zpkgtools/trunk/zpkgtools/config.py
  U   zpkgtools/trunk/zpkgtools/tests/test_config.py

-=-
Modified: zpkgtools/trunk/zpkgtools/config.py
===================================================================
--- zpkgtools/trunk/zpkgtools/config.py	2005-08-29 15:57:18 UTC (rev 38142)
+++ zpkgtools/trunk/zpkgtools/config.py	2005-08-29 16:51:44 UTC (rev 38143)
@@ -69,7 +69,7 @@
         if typename != "resources":
             raise cfgparser.ConfigurationError(
                 "only <resources> sections are allowed")
-        if isinstance(parent, locationmap.LocationMap):
+        if isinstance(parent, locationmap.MapLoader):
             raise cfgparser.ConfigurationError(
                 "<resources> sections may not be nested")
         return locationmap.MapLoader(self.base, self.filename, self.locations)

Modified: zpkgtools/trunk/zpkgtools/tests/test_config.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_config.py	2005-08-29 15:57:18 UTC (rev 38142)
+++ zpkgtools/trunk/zpkgtools/tests/test_config.py	2005-08-29 16:51:44 UTC (rev 38143)
@@ -132,6 +132,26 @@
         finally:
             os.unlink(path)
 
+    def test_nested_resources(self):
+        cf = config.Configuration()
+        fd, path = tempfile.mkstemp(".conf", text=True)
+        f = os.fdopen(fd, "w+")
+        f.write(
+            "<resources>\n"
+            "  PKG1  svn://svn.example.net/repos/pkg1/trunk\n"
+            "  <resources>\n"
+            "    pkg2  svn://svn.example.net/repos/proj/trunk/src/pkg2\n"
+            "  </resources>\n"
+            "</resources>\n")
+        f.close()
+        where = os.path.dirname(path)
+        whereurl = urlutils.file_url(where)
+        try:
+            self.assertRaises(cfgparser.ConfigurationError,
+                              cf.loadPath, path)
+        finally:
+            os.unlink(path)
+
     def load_text(self, text, path=None, basedir=None):
         if path is None:
             if basedir is None:



More information about the Zope-CVS mailing list