]> granicus.if.org Git - python/commitdiff
Add tests for both raw and non-raw versions of the items() methods.
authorFred Drake <fdrake@acm.org>
Fri, 25 Oct 2002 20:42:44 +0000 (20:42 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 25 Oct 2002 20:42:44 +0000 (20:42 +0000)
Lib/test/test_cfgparser.py

index 2409bf94e972460ed298408309060f73f070d4a0..6d93c61227b46bb037c3dfbbe7787e380efd4e5d 100644 (file)
@@ -230,6 +230,18 @@ class TestCaseBase(unittest.TestCase):
             "bar=%(foo)s\n",
             defaults={"getname": "%(__name__)s"})
 
+    def check_items_config(self, expected):
+        cf = self.fromstring(
+            "[section]\n"
+            "name = value\n"
+            "key: |%(name)s| \n"
+            "getdefault: |%(default)s|\n"
+            "getname: |%(__name__)s|",
+            defaults={"default": "<default>"})
+        L = list(cf.items("section"))
+        L.sort()
+        self.assertEqual(L, expected)
+
 
 class ConfigParserTestCase(TestCaseBase):
     config_class = ConfigParser.ConfigParser
@@ -245,6 +257,13 @@ class ConfigParserTestCase(TestCaseBase):
            "something with lots of interpolation (10 steps)")
         self.get_error(ConfigParser.InterpolationDepthError, "Foo", "bar11")
 
+    def test_items(self):
+        self.check_items_config([('default', '<default>'),
+                                 ('getdefault', '|<default>|'),
+                                 ('getname', '|section|'),
+                                 ('key', '|value|'),
+                                 ('name', 'value')])
+
 
 class RawConfigParserTestCase(TestCaseBase):
     config_class = ConfigParser.RawConfigParser
@@ -262,6 +281,13 @@ class RawConfigParserTestCase(TestCaseBase):
         eq(cf.get("Foo", "bar11"),
            "something %(with11)s lots of interpolation (11 steps)")
 
+    def test_items(self):
+        self.check_items_config([('default', '<default>'),
+                                 ('getdefault', '|%(default)s|'),
+                                 ('getname', '|%(__name__)s|'),
+                                 ('key', '|%(name)s|'),
+                                 ('name', 'value')])
+
 
 def test_main():
     suite = unittest.TestSuite()