summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-10-08 17:13:12 (GMT)
committerFred Drake <fdrake@acm.org>2001-10-08 17:13:12 (GMT)
commit168beada91a1cb70ed9186740dd1b689ca448bff (patch)
tree7a1a661dbe9ab1ea1ae71b39caa1e0c0a9fc617f
parent44383384b325aa9a492df52393f6cfdde9d9d8a2 (diff)
downloadcpython-168beada91a1cb70ed9186740dd1b689ca448bff.zip
cpython-168beada91a1cb70ed9186740dd1b689ca448bff.tar.gz
cpython-168beada91a1cb70ed9186740dd1b689ca448bff.tar.bz2
Added tests that check getboolean() with the newly allowed values from
SF patch #467580.
-rw-r--r--Lib/test/output/test_cfgparser1
-rw-r--r--Lib/test/test_cfgparser.py37
2 files changed, 38 insertions, 0 deletions
diff --git a/Lib/test/output/test_cfgparser b/Lib/test/output/test_cfgparser
index 61dcedf..5d705de 100644
--- a/Lib/test/output/test_cfgparser
+++ b/Lib/test/output/test_cfgparser
@@ -1,6 +1,7 @@
test_cfgparser
Testing basic accessors...
Testing case sensitivity...
+Testing interpretation of boolean Values...
Testing value interpolation...
Testing parse errors...
Testing query interface...
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index 0d8f199..c3d966c 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -78,6 +78,25 @@ def case_sensitivity():
verify(cf.get("MySection", "Option") == "first line\nsecond line")
+def boolean(src):
+ print "Testing interpretation of boolean Values..."
+ cf = ConfigParser.ConfigParser()
+ sio = StringIO.StringIO(src)
+ cf.readfp(sio)
+ for x in range(1, 5):
+ verify(cf.getboolean('BOOLTEST', 't%d' % (x)) == 1)
+ for x in range(1, 5):
+ verify(cf.getboolean('BOOLTEST', 'f%d' % (x)) == 0)
+ for x in range(1, 5):
+ try:
+ cf.getboolean('BOOLTEST', 'e%d' % (x))
+ except ValueError:
+ pass
+ else:
+ raise TestFailed(
+ "getboolean() failed to report a non boolean value")
+
+
def interpolation(src):
print "Testing value interpolation..."
cf = ConfigParser.ConfigParser({"getname": "%(__name__)s"})
@@ -180,6 +199,24 @@ foo[en]=English
foo[de]=Deutsch
""")
case_sensitivity()
+boolean(r"""
+[BOOLTEST]
+T1=1
+T2=TRUE
+T3=True
+T4=oN
+T5=yes
+F1=0
+F2=FALSE
+F3=False
+F4=oFF
+F5=nO
+E1=2
+E2=foo
+E3=-1
+E4=0.1
+E5=FALSE AND MORE
+""")
interpolation(r"""
[Foo]
bar=something %(with1)s interpolation (1 step)