Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98e3b29

Browse files
committed
Add tests for both raw and non-raw versions of the items() methods.
1 parent df393bd commit 98e3b29

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lib/test/test_cfgparser.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@ def get_interpolation_config(self):
230230
"bar=%(foo)s\n",
231231
defaults={"getname": "%(__name__)s"})
232232

233+
def check_items_config(self, expected):
234+
cf = self.fromstring(
235+
"[section]\n"
236+
"name = value\n"
237+
"key: |%(name)s| \n"
238+
"getdefault: |%(default)s|\n"
239+
"getname: |%(__name__)s|",
240+
defaults={"default": "<default>"})
241+
L = list(cf.items("section"))
242+
L.sort()
243+
self.assertEqual(L, expected)
244+
233245

234246
class ConfigParserTestCase(TestCaseBase):
235247
config_class = ConfigParser.ConfigParser
@@ -245,6 +257,13 @@ def test_interpolation(self):
245257
"something with lots of interpolation (10 steps)")
246258
self.get_error(ConfigParser.InterpolationDepthError, "Foo", "bar11")
247259

260+
def test_items(self):
261+
self.check_items_config([('default', '<default>'),
262+
('getdefault', '|<default>|'),
263+
('getname', '|section|'),
264+
('key', '|value|'),
265+
('name', 'value')])
266+
248267

249268
class RawConfigParserTestCase(TestCaseBase):
250269
config_class = ConfigParser.RawConfigParser
@@ -262,6 +281,13 @@ def test_interpolation(self):
262281
eq(cf.get("Foo", "bar11"),
263282
"something %(with11)s lots of interpolation (11 steps)")
264283

284+
def test_items(self):
285+
self.check_items_config([('default', '<default>'),
286+
('getdefault', '|%(default)s|'),
287+
('getname', '|%(__name__)s|'),
288+
('key', '|%(name)s|'),
289+
('name', 'value')])
290+
265291

266292
def test_main():
267293
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)