diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2002-03-08 18:10:12 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2002-03-08 18:10:12 (GMT) |
commit | 1bf71172f8e1acfce05d8443e3998c425974aeef (patch) | |
tree | f94fb8f12fd2e3dbb6df54c98c5c477ed2ea3ca6 | |
parent | 00824ed733a5bd9cd94227fdfbf33b98f1ae900a (diff) | |
download | cpython-1bf71172f8e1acfce05d8443e3998c425974aeef.zip cpython-1bf71172f8e1acfce05d8443e3998c425974aeef.tar.gz cpython-1bf71172f8e1acfce05d8443e3998c425974aeef.tar.bz2 |
As part of fixing bug #523301, add a simple test of ConfigParser.write()
-rw-r--r-- | Lib/test/output/test_cfgparser | 1 | ||||
-rw-r--r-- | Lib/test/test_cfgparser.py | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/output/test_cfgparser b/Lib/test/output/test_cfgparser index 5d705de..683fe1a 100644 --- a/Lib/test/output/test_cfgparser +++ b/Lib/test/output/test_cfgparser @@ -1,5 +1,6 @@ test_cfgparser Testing basic accessors... +Testing writing of files... Testing case sensitivity... Testing interpretation of boolean Values... Testing value interpolation... diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index c3d966c..57e7125 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -14,6 +14,7 @@ def basic(src): verify(L == [r'Commented Bar', r'Foo Bar', r'Internationalized Stuff', + r'Long Line', r'Section\with$weird%characters[' '\t', r'Spacey Bar', ], @@ -47,7 +48,26 @@ def basic(src): "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() @@ -191,6 +211,9 @@ foo=bar 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 @@ -198,6 +221,12 @@ foo=Default 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] |