diff options
author | Fred Drake <fdrake@acm.org> | 2002-10-25 20:42:44 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-10-25 20:42:44 (GMT) |
commit | 98e3b29b5969b7738c4c2e1e21fea47357ea6aa0 (patch) | |
tree | d6414c78641f3edd036c493166770cb9c6fd482e /Lib | |
parent | df393bd46a0b98197a73407c55750519cd159a2e (diff) | |
download | cpython-98e3b29b5969b7738c4c2e1e21fea47357ea6aa0.zip cpython-98e3b29b5969b7738c4c2e1e21fea47357ea6aa0.tar.gz cpython-98e3b29b5969b7738c4c2e1e21fea47357ea6aa0.tar.bz2 |
Add tests for both raw and non-raw versions of the items() methods.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_cfgparser.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 2409bf9..6d93c61 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -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() |