[Zodb-checkins] CVS: Packages/ZConfig/tests - test_schema.py:1.1.2.29 test_zopeschema.py:1.1.2.3
Fred L. Drake, Jr.
fred@zope.com
Fri, 20 Dec 2002 11:24:52 -0500
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv19225/tests
Modified Files:
Tag: zconfig-schema-devel-branch
test_schema.py test_zopeschema.py
Log Message:
A bit of refactoring so test_zopeschema does not run all of the basic tests
a second time. This makes the report of the number of tests a little more
honest, and running the tests is quicker.
=== Packages/ZConfig/tests/test_schema.py 1.1.2.28 => 1.1.2.29 ===
--- Packages/ZConfig/tests/test_schema.py:1.1.2.28 Thu Dec 19 12:36:18 2002
+++ Packages/ZConfig/tests/test_schema.py Fri Dec 20 11:24:51 2002
@@ -40,9 +40,40 @@
self.length = len(value)
-class SchemaTestCase(unittest.TestCase):
+class BaseSchemaTest(unittest.TestCase):
+ """Utility methods which can be used with the schema support."""
- # tests
+ def load_both(self, schema_url, conf_url):
+ schema = self.load_schema(schema_url)
+ conf = self.load_config(schema, conf_url)
+ return schema, conf
+
+ def load_schema(self, relurl):
+ self.url = urlparse.urljoin(CONFIG_BASE, relurl)
+ self.schema = ZConfig.loadSchema(self.url)
+ self.assert_(self.schema.issection())
+ return self.schema
+
+ def load_schema_text(self, text):
+ sio = StringIO.StringIO(text)
+ self.schema = ZConfig.loadSchemaFile(sio)
+ return self.schema
+
+ def load_config(self, schema, conf_url, num_handlers=0):
+ conf_url = urlparse.urljoin(CONFIG_BASE, conf_url)
+ self.conf, self.handlers = ConfigLoader(schema).loadURL(conf_url)
+ self.assertEqual(len(self.handlers), num_handlers)
+ return self.conf
+
+ def load_config_text(self, schema, text, num_handlers=0):
+ sio = StringIO.StringIO(text)
+ self.conf, self.handlers = ZConfig.loadConfigFile(schema, sio)
+ self.assertEqual(len(self.handlers), num_handlers)
+ return self.conf
+
+
+class SchemaTestCase(BaseSchemaTest):
+ """Tests of the basic schema support itself."""
def test_minimal_schema(self):
schema = self.load_schema_text("<schema/>")
@@ -450,36 +481,6 @@
eq(convert('60000'), 60000)
eq(convert('65535'), 0xffff)
raises(ValueError, convert, '65536')
-
- # utilities
-
- def load_both(self, schema_url, conf_url):
- schema = self.load_schema(schema_url)
- conf = self.load_config(schema, conf_url)
- return schema, conf
-
- def load_schema(self, relurl):
- self.url = urlparse.urljoin(CONFIG_BASE, relurl)
- self.schema = ZConfig.loadSchema(self.url)
- self.assert_(self.schema.issection())
- return self.schema
-
- def load_schema_text(self, text):
- sio = StringIO.StringIO(text)
- self.schema = ZConfig.loadSchemaFile(sio)
- return self.schema
-
- def load_config(self, schema, conf_url, num_handlers=0):
- conf_url = urlparse.urljoin(CONFIG_BASE, conf_url)
- self.conf, self.handlers = ConfigLoader(schema).loadURL(conf_url)
- self.assertEqual(len(self.handlers), num_handlers)
- return self.conf
-
- def load_config_text(self, schema, text, num_handlers=0):
- sio = StringIO.StringIO(text)
- self.conf, self.handlers = ZConfig.loadConfigFile(schema, sio)
- self.assertEqual(len(self.handlers), num_handlers)
- return self.conf
def test_suite():
=== Packages/ZConfig/tests/test_zopeschema.py 1.1.2.2 => 1.1.2.3 ===
--- Packages/ZConfig/tests/test_zopeschema.py:1.1.2.2 Thu Dec 19 17:11:22 2002
+++ Packages/ZConfig/tests/test_zopeschema.py Fri Dec 20 11:24:51 2002
@@ -16,7 +16,7 @@
import unittest
import ZConfig
-from ZConfig.tests.test_schema import SchemaTestCase
+from ZConfig.tests.test_schema import BaseSchemaTest
try:
True
@@ -110,7 +110,7 @@
pos, kw = _get_arglist(arglist)
return klass, pos, kw
-class ZopeSchemaTestCase(SchemaTestCase):
+class ZopeSchemaTestCase(BaseSchemaTest):
# tests