configparser: read-only attributes to get the section name and parser from a SectionProxy instance

This commit is contained in:
Łukasz Langa 2010-11-21 13:56:42 +00:00
parent 5c86339bd0
commit a73dc9d5e8
2 changed files with 34 additions and 17 deletions

View file

@ -135,8 +135,15 @@ class BasicTestCase(CfgParserTestCaseClass):
# mapping access
eq(cf['Foo Bar']['foo'], 'bar1')
eq(cf['Spacey Bar']['foo'], 'bar2')
eq(cf['Spacey Bar From The Beginning']['foo'], 'bar3')
eq(cf['Spacey Bar From The Beginning']['baz'], 'qwe')
section = cf['Spacey Bar From The Beginning']
eq(section.name, 'Spacey Bar From The Beginning')
self.assertIs(section.parser, cf)
with self.assertRaises(AttributeError):
section.name = 'Name is read-only'
with self.assertRaises(AttributeError):
section.parser = 'Parser is read-only'
eq(section['foo'], 'bar3')
eq(section['baz'], 'qwe')
eq(cf['Commented Bar']['foo'], 'bar4')
eq(cf['Commented Bar']['baz'], 'qwe')
eq(cf['Spaces']['key with spaces'], 'value')