test_cfgparser
Testing basic accessors...
+Testing writing of files...
Testing case sensitivity...
Testing interpretation of boolean Values...
Testing value interpolation...
verify(L == [r'Commented Bar',
r'Foo Bar',
r'Internationalized Stuff',
+ r'Long Line',
r'Section\with$weird%characters[' '\t',
r'Spacey Bar',
],
"remove_option() failed to report non-existance of option"
" that never existed")
+ verify(cf.get('Long Line', 'foo', raw=1) ==
+ 'this line is much, much longer than my editor\nlikes it.')
+
+def write(src):
+ print "Testing writing of files..."
+ cf = ConfigParser.ConfigParser()
+ sio = StringIO.StringIO(src)
+ cf.readfp(sio)
+ output = StringIO.StringIO()
+ cf.write(output)
+ verify(output, """[DEFAULT]
+foo = another very
+ long line
+
+[Long Line]
+foo = this line is much, much longer than my editor
+ likes it.
+""")
+
def case_sensitivity():
print "Testing case sensitivity..."
cf = ConfigParser.ConfigParser()
foo = bar
[Commented Bar]
foo: bar ; comment
+[Long Line]
+foo: this line is much, much longer than my editor
+ likes it.
[Section\with$weird%characters[""" '\t' r"""]
[Internationalized Stuff]
foo[bg]: Bulgarian
foo[en]=English
foo[de]=Deutsch
""")
+write("""[Long Line]
+foo: this line is much, much longer than my editor
+ likes it.
+[DEFAULT]
+foo: another very
+ long line""")
case_sensitivity()
boolean(r"""
[BOOLTEST]