diff options
author | Fred Drake <fdrake@acm.org> | 2001-02-26 21:55:34 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-02-26 21:55:34 (GMT) |
commit | 3c823aa4b64653043ac8cdcb858b4042087862b0 (patch) | |
tree | 1248e09b65cf05808df6a78da49d774bc1b3e0fa /Lib/test | |
parent | ffc215a2792db293786120c8c2aebd39f80c8e15 (diff) | |
download | cpython-3c823aa4b64653043ac8cdcb858b4042087862b0.zip cpython-3c823aa4b64653043ac8cdcb858b4042087862b0.tar.gz cpython-3c823aa4b64653043ac8cdcb858b4042087862b0.tar.bz2 |
Make sure ConfigParser uses .optionxform() consistently; this affects
.has_option(), .remove_option(), and .set().
This closes SF tracker #232913.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/output/test_cfgparser | 1 | ||||
-rw-r--r-- | Lib/test/test_cfgparser.py | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/output/test_cfgparser b/Lib/test/output/test_cfgparser index eb16536..61dcedf 100644 --- a/Lib/test/output/test_cfgparser +++ b/Lib/test/output/test_cfgparser @@ -1,5 +1,6 @@ test_cfgparser Testing basic accessors... +Testing case sensitivity... Testing value interpolation... Testing parse errors... Testing query interface... diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index e9d4ee5..62395a0 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -48,6 +48,29 @@ def basic(src): " that never existed") +def case_sensitivity(): + print "Testing case sensitivity..." + cf = ConfigParser.ConfigParser() + cf.add_section("A") + cf.add_section("a") + L = cf.sections() + L.sort() + verify(L == ["A", "a"]) + cf.set("a", "B", "value") + verify(cf.options("a") == ["b"]) + verify(cf.get("a", "b", raw=1) == "value", + "could not locate option, expecting case-insensitive option names") + verify(cf.has_option("a", "b")) + cf.set("A", "A-B", "A-B value") + for opt in ("a-b", "A-b", "a-B", "A-B"): + verify(cf.has_option("A", opt), + "has_option() returned false for option which should exist") + verify(cf.options("A") == ["a-b"]) + verify(cf.options("a") == ["b"]) + cf.remove_option("a", "B") + verify(cf.options("a") == []) + + def interpolation(src): print "Testing value interpolation..." cf = ConfigParser.ConfigParser({"getname": "%(__name__)s"}) @@ -149,6 +172,7 @@ foo=Default foo[en]=English foo[de]=Deutsch """) +case_sensitivity() interpolation(r""" [Foo] bar=something %(with1)s interpolation (1 step) |