[Zope3-checkins] CVS: Packages/ZConfig/tests - testSubstitution.py:1.5

Fred L. Drake, Jr. fred@zope.com
Tue, 3 Dec 2002 10:31:18 -0500


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

Modified Files:
	testSubstitution.py 
Log Message:
Added function ZConfig.Substitution.getnames().

=== Packages/ZConfig/tests/testSubstitution.py 1.4 => 1.5 ===
--- Packages/ZConfig/tests/testSubstitution.py:1.4	Tue Dec  3 09:59:55 2002
+++ Packages/ZConfig/tests/testSubstitution.py	Tue Dec  3 10:31:17 2002
@@ -8,7 +8,7 @@
 from types import StringType
 from UserDict import UserDict
 
-from ZConfig.Substitution import get, substitute
+from ZConfig.Substitution import get, getnames, substitute
 from ZConfig.Substitution import SubstitutionRecursionError
 from ZConfig.Substitution import SubstitutionSyntaxError
 
@@ -118,6 +118,22 @@
             else:
                 name = exc.__module__ + "." + exc.__name__
             self.fail("expected exception " + name)
+
+    def test_getnames(self):
+        self.assertEqual(getnames(""), [])
+        self.assertEqual(getnames("abc"), [])
+        self.assertEqual(getnames("$"), [])
+        self.assertEqual(getnames("$$"), [])
+        self.assertEqual(getnames("$abc"), ["abc"])
+        self.assertEqual(getnames("$abc$abc"), ["abc"])
+        self.assertEqual(getnames("$abc$def"), ["abc", "def"])
+        self.assertEqual(getnames("${abc}${def}"), ["abc", "def"])
+        self.assertEqual(getnames("$abc xyz${def}pqr$def"), ["abc", "def"])
+        self.assertEqual(getnames("$ABC xyz${def}pqr$DEF"), ["abc", "def"])
+        self.assertRaises(SubstitutionSyntaxError, getnames, "${")
+        self.assertRaises(SubstitutionSyntaxError, getnames, "${name")
+        self.assertRaises(SubstitutionSyntaxError, getnames, "${1name}")
+        self.assertRaises(SubstitutionSyntaxError, getnames, "${ name}")
 
 
 def test_suite():