[Zope-Checkins] CVS: StandaloneZConfig/ZConfig/tests - test_schema.py:1.23

Fred L. Drake, Jr. fred at zope.com
Fri Jan 2 00:27:18 EST 2004


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

Modified Files:
	test_schema.py 
Log Message:
derived section types now inherit their datatype from the base type


=== StandaloneZConfig/ZConfig/tests/test_schema.py 1.22 => 1.23 ===
--- StandaloneZConfig/ZConfig/tests/test_schema.py:1.22	Mon Dec 29 17:40:47 2003
+++ StandaloneZConfig/ZConfig/tests/test_schema.py	Fri Jan  2 00:27:17 2004
@@ -26,6 +26,9 @@
 def appsection(value):
     return MySection(value)
 
+def get_foo(section):
+    return section.foo
+
 class MySection:
     def __init__(self, value):
         self.conf = value
@@ -666,6 +669,8 @@
                           """)
 
     def test_sectiontype_derived_keytype(self):
+        # make sure that a derived section type inherits the keytype
+        # of its base
         schema = self.load_schema_text("""\
             <schema>
               <sectiontype name='sect' keytype='identifier'/>
@@ -684,6 +689,23 @@
             """)
         self.assertEqual(conf.foo.foo, "bar")
         self.assertEqual(conf.foo.Foo, "BAR")
+
+    def test_sectiontype_inherited_datatype(self):
+        schema = self.load_schema_text("""\
+            <schema prefix='ZConfig.tests.test_schema'>
+              <sectiontype name='base' datatype='.get_foo'>
+                <key name="foo"/>
+              </sectiontype>
+              <sectiontype name='derived' extends='base'/>
+              <section name='*' type='derived' attribute='splat'/>
+            </schema>
+            """)
+        conf = self.load_config_text(schema, """\
+            <derived>
+              foo bar
+            </derived>
+            """)
+        self.assertEqual(conf.splat, "bar")
 
     def test_schema_keytype(self):
         schema = self.load_schema_text("""\




More information about the Zope-Checkins mailing list