diff options
author | Michael W. Hudson <mwh@python.net> | 2002-03-15 10:25:12 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2002-03-15 10:25:12 (GMT) |
commit | b14519ba183e3cd7d86e96bb090510399122b87d (patch) | |
tree | e89a4668c639c97117a0d18cb18070f1a7704c80 /Lib | |
parent | 3813281fec352449db98572c119179f4b3faec8d (diff) | |
download | cpython-b14519ba183e3cd7d86e96bb090510399122b87d.zip cpython-b14519ba183e3cd7d86e96bb090510399122b87d.tar.gz cpython-b14519ba183e3cd7d86e96bb090510399122b87d.tar.bz2 |
backport akuchling's checkin of
revision 1.10 of test_cfgparser.py
As part of fixing bug #523301, add a simple test of ConfigParser.write()
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_cfgparser.py | 29 |
1 files changed, 29 insertions, 0 deletions
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] |