diff options
author | Fred Drake <fdrake@acm.org> | 2002-10-25 18:09:24 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-10-25 18:09:24 (GMT) |
commit | 3af0eb872a1c8260640aff752c5ea4d0a4342415 (patch) | |
tree | 3e2cd870b1343bb6bea7811f7ae3ebe64e8cbad6 /Lib/test | |
parent | fce6557c6b7176eb599c6b7e449936e98faf197f (diff) | |
download | cpython-3af0eb872a1c8260640aff752c5ea4d0a4342415.zip cpython-3af0eb872a1c8260640aff752c5ea4d0a4342415.tar.gz cpython-3af0eb872a1c8260640aff752c5ea4d0a4342415.tar.bz2 |
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. ;-(
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_cfgparser.py | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 90f7255..fa01627 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 |