Commit 1bf71172 authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

As part of fixing bug #523301, add a simple test of ConfigParser.write()

parent 00824ed7
test_cfgparser test_cfgparser
Testing basic accessors... Testing basic accessors...
Testing writing of files...
Testing case sensitivity... Testing case sensitivity...
Testing interpretation of boolean Values... Testing interpretation of boolean Values...
Testing value interpolation... Testing value interpolation...
......
...@@ -14,6 +14,7 @@ def basic(src): ...@@ -14,6 +14,7 @@ def basic(src):
verify(L == [r'Commented Bar', verify(L == [r'Commented Bar',
r'Foo Bar', r'Foo Bar',
r'Internationalized Stuff', r'Internationalized Stuff',
r'Long Line',
r'Section\with$weird%characters[' '\t', r'Section\with$weird%characters[' '\t',
r'Spacey Bar', r'Spacey Bar',
], ],
...@@ -47,6 +48,25 @@ def basic(src): ...@@ -47,6 +48,25 @@ def basic(src):
"remove_option() failed to report non-existance of option" "remove_option() failed to report non-existance of option"
" that never existed") " 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(): def case_sensitivity():
print "Testing case sensitivity..." print "Testing case sensitivity..."
...@@ -191,6 +211,9 @@ foo=bar ...@@ -191,6 +211,9 @@ foo=bar
foo = bar foo = bar
[Commented Bar] [Commented Bar]
foo: bar ; comment foo: bar ; comment
[Long Line]
foo: this line is much, much longer than my editor
likes it.
[Section\with$weird%characters[""" '\t' r"""] [Section\with$weird%characters[""" '\t' r"""]
[Internationalized Stuff] [Internationalized Stuff]
foo[bg]: Bulgarian foo[bg]: Bulgarian
...@@ -198,6 +221,12 @@ foo=Default ...@@ -198,6 +221,12 @@ foo=Default
foo[en]=English foo[en]=English
foo[de]=Deutsch 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() case_sensitivity()
boolean(r""" boolean(r"""
[BOOLTEST] [BOOLTEST]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment