]> granicus.if.org Git - python/commitdiff
As part of fixing bug #523301, add a simple test of ConfigParser.write()
authorAndrew M. Kuchling <amk@amk.ca>
Fri, 8 Mar 2002 18:10:12 +0000 (18:10 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Fri, 8 Mar 2002 18:10:12 +0000 (18:10 +0000)
Lib/test/output/test_cfgparser
Lib/test/test_cfgparser.py

index 5d705def2887079a6871c395009401bf615b1426..683fe1ad74f035109cfcc245efea2560fc176941 100644 (file)
@@ -1,5 +1,6 @@
 test_cfgparser
 Testing basic accessors...
+Testing writing of files...
 Testing case sensitivity...
 Testing interpretation of boolean Values...
 Testing value interpolation...
index c3d966c3f128d5220fe807e2fca0da0068eae0d1..57e712579be74a10255b7ff5789e3c2ea1ddeee8 100644 (file)
@@ -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]