From 3af0eb872a1c8260640aff752c5ea4d0a4342415 Mon Sep 17 00:00:00 2001
From: Fred Drake <fdrake@acm.org>
Date: Fri, 25 Oct 2002 18:09:24 +0000
Subject: [PATCH] Added (very) minimal tests of the RawConfigParser class.
 Moved the write() test to near the end of the file since it screws up
 font-lock.  ;-(

---
 Lib/test/test_cfgparser.py | 51 ++++++++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 16 deletions(-)

diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 90f7255540..fa01627ef8 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -55,22 +55,6 @@ def basic(src):
            '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()
@@ -138,6 +122,20 @@ def interpolation(src):
            == "something with lots of interpolation (10 steps)")
     expect_get_error(cf, ConfigParser.InterpolationDepthError, "Foo", "bar11")
 
+    # Now make sure we don't interpolate if we use RawConfigParser:
+    cf = ConfigParser.RawConfigParser({"getname": "%(__name__)s"})
+    sio = StringIO.StringIO(src)
+    cf.readfp(sio)
+    verify(cf.get("Foo", "getname") == "%(__name__)s")
+    verify(cf.get("Foo", "bar")
+           == "something %(with1)s interpolation (1 step)")
+    verify(cf.get("Foo", "bar9")
+           == "something %(with9)s lots of interpolation (9 steps)")
+    verify(cf.get("Foo", "bar10")
+           == "something %(with10)s lots of interpolation (10 steps)")
+    verify(cf.get("Foo", "bar11")
+           == "something %(with11)s lots of interpolation (11 steps)")
+
 
 def parse_errors():
     print "Testing parse errors..."
@@ -212,6 +210,27 @@ def expect_parse_error(exctype, src):
         raise TestFailed("Failed to catch expected " + exctype.__name__)
 
 
+# The long string literals present in the rest of the file screw up
+# font-lock in Emacs/XEmacs, so this stuff needs to stay near the end
+# of this file.
+
+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.
+""")
+
+
 basic(r"""
 [Foo Bar]
 foo=bar
-- 
2.40.0