[Zodb-checkins] CVS: Packages/ZConfig/tests - testConfig.py:1.15

Fred L. Drake, Jr. fred@zope.com
Wed, 4 Dec 2002 16:20:45 -0500


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

Modified Files:
	testConfig.py 
Log Message:
Implement the %define directive and $-substitution within values.
Further documentation is needed.


=== Packages/ZConfig/tests/testConfig.py 1.14 => 1.15 ===
--- Packages/ZConfig/tests/testConfig.py:1.14	Tue Nov 26 18:08:28 2002
+++ Packages/ZConfig/tests/testConfig.py	Wed Dec  4 16:20:43 2002
@@ -25,6 +25,7 @@
 from ZConfig.Context import Context
 from ZConfig.Common import ConfigurationError, ConfigurationTypeError
 from ZConfig.Common import ConfigurationMissingSectionError
+from ZConfig.Common import ConfigurationSyntaxError
 
 try:
     __file__
@@ -50,6 +51,10 @@
         self.assert_(conf.delegate is None)
         return conf
 
+    def loadtext(self, text):
+        sio = StringIO.StringIO(text)
+        return ZConfig.loadfile(sio)
+
     def check_simple_gets(self, conf):
         self.assertEqual(conf.get('empty'), '')
         self.assertEqual(conf.getint('int-var'), 12)
@@ -229,6 +234,22 @@
         self.assertEqual(conf.get("VAR2"), "value2")
         self.assertEqual(conf.get("var3"), "value3")
         self.assertEqual(conf.get("VAR3"), "value3")
+
+    def test_define(self):
+        conf = self.load("simple.conf")
+        self.assertEqual(conf.get("getname"), "value")
+        self.assertEqual(conf.get("getnametwice"), "valuevalue")
+        self.assertEqual(conf.get("getdollars"), "$$")
+        self.assertEqual(conf.get("getempty"), "xy")
+        self.assertEqual(conf.get("getwords"), "abc two words def")
+
+    def test_define_errors(self):
+        self.assertRaises(ConfigurationSyntaxError,
+                          self.loadtext, "%define\n")
+        self.assertRaises(ConfigurationSyntaxError,
+                          self.loadtext, "%define abc-def\n")
+        self.assertRaises(ConfigurationSyntaxError,
+                          self.loadtext, "%define a value\n%define a value\n")
 
     def test_fragment_ident_disallowed(self):
         self.assertRaises(ConfigurationError,