[Zconfig]
SVN: ZConfig/branches/fdrake-textblock/tests/test_textblock.py
first few tests of the new functionality
Fred L. Drake, Jr.
fdrake at gmail.com
Tue Feb 8 13:09:48 EST 2005
Log message for revision 29084:
first few tests of the new functionality
Changed:
A ZConfig/branches/fdrake-textblock/tests/test_textblock.py
-=-
Added: ZConfig/branches/fdrake-textblock/tests/test_textblock.py
===================================================================
--- ZConfig/branches/fdrake-textblock/tests/test_textblock.py 2005-02-08 17:29:10 UTC (rev 29083)
+++ ZConfig/branches/fdrake-textblock/tests/test_textblock.py 2005-02-08 18:09:48 UTC (rev 29084)
@@ -0,0 +1,83 @@
+"""Tests for <textblocktype> and <textblock>.
+
+"""
+__docformat__ = "reStructuredText"
+
+import unittest
+
+import ZConfig
+
+from ZConfig.tests.support import TestBase, CONFIG_BASE
+
+
+def uppercase(value):
+ return str(value).upper()
+
+
+class TextBlockTestCase(TestBase):
+ """Tests of the text block support."""
+
+ def test_simple(self):
+ schema = self.load_schema_text("""\
+ <schema>
+ <textblocktype name='why'/>
+ <textblock attribute='explanation' type='why'/>
+ </schema>
+ """)
+ conf = self.load_config_text(schema, """\
+ <why>
+ Some long explanation goes here.
+ </why>
+ """)
+ self.assertEqual(conf.explanation.strip(),
+ "Some long explanation goes here.")
+
+ def test_with_datatype(self):
+ schema = self.load_schema_text("""\
+ <schema>
+ <textblocktype name='why'
+ datatype='%s.uppercase'/>
+ <textblock attribute='explanation' type='why'/>
+ </schema>
+ """ % __name__)
+ conf = self.load_config_text(schema, """\
+ <why>
+ Some long explanation goes here.
+ </why>
+ """)
+ self.assertEqual(conf.explanation.strip(),
+ "SOME LONG EXPLANATION GOES HERE.")
+
+ def test_with_default(self):
+ schema = self.load_schema_text("""\
+ <schema>
+ <textblocktype name='why'/>
+ <textblock attribute='explanation' type='why'>
+ <default>
+ default value
+ </default>
+ </textblock>
+ </schema>
+ """)
+ conf = self.load_config_text(schema, "")
+ self.assertEqual(conf.explanation.strip(), "default value")
+
+ def test_named(self):
+ schema = self.load_schema_text("""\
+ <schema>
+ <textblocktype name='why'/>
+ <textblock attribute='explanation' required='yes'
+ type='why' name='not'/>
+ </schema>
+ """)
+ conf = self.load_config_text(schema, """\
+ <why not>
+ Some long explanation goes here.
+ </why>
+ """)
+ self.assertEqual(conf.explanation.strip(),
+ "Some long explanation goes here.")
+
+
+def test_suite():
+ return unittest.makeSuite(TextBlockTestCase)
Property changes on: ZConfig/branches/fdrake-textblock/tests/test_textblock.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
More information about the ZConfig
mailing list