[Zodb-checkins] CVS: Packages/ZConfig/tests - testSubstitution.py:1.8

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


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

Modified Files:
	testSubstitution.py 
Log Message:
Be more strict when scanning the source text:  If '$' is not followed
by '$' or a name, raise an exception.  (Previously this used '' for
the replacement text.)


=== Packages/ZConfig/tests/testSubstitution.py 1.7 => 1.8 ===
--- Packages/ZConfig/tests/testSubstitution.py:1.7	Wed Dec  4 17:48:31 2002
+++ Packages/ZConfig/tests/testSubstitution.py	Wed Dec  4 20:10:17 2002
@@ -5,7 +5,9 @@
 
 import unittest
 
-from ZConfig.Substitution import isname, substitute, SubstitutionSyntaxError
+from ZConfig.Substitution import isname, substitute
+from ZConfig.Substitution import SubstitutionReplacementError
+from ZConfig.Substitution import SubstitutionSyntaxError
 
 
 class SubstitutionTestCase(unittest.TestCase):
@@ -34,9 +36,12 @@
 
     def test_undefined_names(self):
         d = {"name": "value"}
-        self.assertEqual(substitute("$splat", d), "")
-        self.assertEqual(substitute("$splat1", d), "")
-        self.assertEqual(substitute("$splat_", d), "")
+        self.assertRaises(SubstitutionReplacementError,
+                          substitute, "$splat", d)
+        self.assertRaises(SubstitutionReplacementError,
+                          substitute, "$splat1", d)
+        self.assertRaises(SubstitutionReplacementError,
+                          substitute, "$splat_", d)
 
     def test_syntax_errors(self):
         d = {"name": "${next"}
@@ -52,7 +57,8 @@
         # It's debatable what should happen for these cases, so we'll
         # follow the lead of the Bourne shell here.
         def check(s):
-            self.assertEqual(substitute(s, {}), s)
+            self.assertRaises(SubstitutionSyntaxError,
+                              substitute, s, {})
         check("$1")
         check("$")
         check("$ stuff")