Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d5f7e8

Browse files
committed
Add test cases for ConfigParser.remove_option() behavior. This includes
coverage to ensure bug #124324 does not re-surface.
1 parent ff4a23b commit 3d5f7e8

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lib/test/test_cfgparser.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import ConfigParser
22
import StringIO
33

4+
from test_support import TestFailed
5+
6+
47
def basic(src):
58
print
69
print "Testing basic accessors..."
@@ -25,6 +28,27 @@ def basic(src):
2528
else:
2629
print '__name__ "option" properly hidden by the API.'
2730

31+
# Make sure the right things happen for remove_option();
32+
# added to include check for SourceForge bug #123324:
33+
if not cf.remove_option('Foo Bar', 'foo'):
34+
raise TestFailed(
35+
"remove_option() failed to report existance of option")
36+
if cf.has_option('Foo Bar', 'foo'):
37+
raise TestFailed("remove_option() failed to remove option")
38+
if cf.remove_option('Foo Bar', 'foo'):
39+
raise TestFailed(
40+
"remove_option() failed to report non-existance of option"
41+
" that was removed")
42+
try:
43+
cf.remove_option('No Such Section', 'foo')
44+
except ConfigParser.NoSectionError:
45+
pass
46+
else:
47+
raise TestFailed(
48+
"remove_option() failed to report non-existance of option"
49+
" that never existed")
50+
51+
2852
def interpolation(src):
2953
print
3054
print "Testing value interpolation..."

0 commit comments

Comments
 (0)