[Zope3-checkins] CVS: Packages/ZConfig/tests - test_schema.py:1.1.2.2

Fred L. Drake, Jr. fred@zope.com
Wed, 11 Dec 2002 15:31:22 -0500


Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv23869

Modified Files:
      Tag: zconfig-schema-devel-branch
	test_schema.py 
Log Message:
- Reorganize test object methods.
- Avoid using an external file for trivial schema only used once.


=== Packages/ZConfig/tests/test_schema.py 1.1.2.1 => 1.1.2.2 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.1	Wed Dec 11 15:10:52 2002
+++ Packages/ZConfig/tests/test_schema.py	Wed Dec 11 15:31:22 2002
@@ -13,6 +13,7 @@
 ##############################################################################
 """Tests of ZConfig schemas."""
 
+import StringIO
 import unittest
 import urlparse
 
@@ -23,20 +24,11 @@
 
 
 class SchemaTestCase(unittest.TestCase):
-    def load(self, relurl):
-        self.url = urlparse.urljoin(CONFIG_BASE, relurl)
-        self.schema = ZConfig.loadSchema(self.url)
-        self.assert_(self.schema.issection())
-        return self.schema
 
-    def loadBoth(self, schema_url, conf_url):
-        schema = self.load(schema_url)
-        conf_url = urlparse.urljoin(CONFIG_BASE, conf_url)
-        conf = ConfigLoader(schema).loadURL(conf_url)
-        return schema, conf
+    # tests
 
     def test_minimal_schema(self):
-        schema = self.load("minimal.xml")
+        schema = self.loadtext("<schema/>")
         self.assertEqual(len(schema), 0)
         self.assertEqual(schema.getchildnames(), [])
         self.assertRaises(IndexError,
@@ -59,6 +51,24 @@
         check(not conf.false_var_1)
         check(not conf.false_var_2)
         check(not conf.false_var_3)
+
+    # utilities
+
+    def load(self, relurl):
+        self.url = urlparse.urljoin(CONFIG_BASE, relurl)
+        self.schema = ZConfig.loadSchema(self.url)
+        self.assert_(self.schema.issection())
+        return self.schema
+
+    def loadtext(self, text):
+        sio = StringIO.StringIO(text)
+        return ZConfig.loadSchemaFile(sio)
+
+    def loadBoth(self, schema_url, conf_url):
+        schema = self.load(schema_url)
+        conf_url = urlparse.urljoin(CONFIG_BASE, conf_url)
+        conf = ConfigLoader(schema).loadURL(conf_url)
+        return schema, conf
 
 
 def test_suite():