[Zope-Checkins] CVS: Packages/ZConfig/tests - testInterp.py:1.4
Fred L. Drake, Jr.
fdrake@acm.org
Wed, 9 Oct 2002 17:41:06 -0400
Update of /cvs-repository/Packages/ZConfig/tests
In directory cvs.zope.org:/tmp/cvs-serv21204
Modified Files:
testInterp.py
Log Message:
Fix tests after adjusting edge cases.
Add ugly __future__ import to make the tests run using Python 2.1.x as
well.
=== Packages/ZConfig/tests/testInterp.py 1.3 => 1.4 ===
--- Packages/ZConfig/tests/testInterp.py:1.3 Wed Oct 9 15:15:25 2002
+++ Packages/ZConfig/tests/testInterp.py Wed Oct 9 17:41:05 2002
@@ -1,5 +1,8 @@
"""Tests of the string interpolation module."""
+# This is needed to support Python 2.1.
+from __future__ import nested_scopes
+
import unittest
from ZConfig.Interpolation import get, interpolate
@@ -42,7 +45,6 @@
def check(s):
self.assertRaises(InterpolationSyntaxError,
interpolate, s, d)
- check("$1")
check("${")
check("${name")
check("${1name}")
@@ -51,10 +53,11 @@
def test_edge_cases(self):
# It's debatable what should happen for these cases, so we'll
# follow the lead of the Bourne shell here.
- def check(s, value):
- self.assertEqual(interpolate(s, {}), value)
- check("$", "$")
- check("$ stuff", "$ stuff")
+ def check(s):
+ self.assertEqual(interpolate(s, {}), s)
+ check("$1")
+ check("$")
+ check("$ stuff")
def test_non_nesting(self):
d = {"name": "$value"}
@@ -70,11 +73,6 @@
check("nest", "nested")
def test_nesting_errors(self):
- d = {"name": "$splat",
- "splat": "$foo",
- "foo": "$"}
- self.assertRaises(InterpolationSyntaxError,
- get, d, "name")
d = {"name": "$splat",
"splat": "$name"}
self.assertRaises(InterpolationRecursionError,