]> granicus.if.org Git - python/commitdiff
Add test cases for ConfigParser.remove_option() behavior. This includes
authorFred Drake <fdrake@acm.org>
Mon, 4 Dec 2000 16:30:40 +0000 (16:30 +0000)
committerFred Drake <fdrake@acm.org>
Mon, 4 Dec 2000 16:30:40 +0000 (16:30 +0000)
coverage to ensure bug #124324 does not re-surface.

Lib/test/test_cfgparser.py

index 00b84659b6d67b0945b036703c1fac306b054fc6..bd06d3bb857bafd1bc79e9401d3aedb0b29105a1 100644 (file)
@@ -1,6 +1,9 @@
 import ConfigParser
 import StringIO
 
+from test_support import TestFailed
+
+
 def basic(src):
     print
     print "Testing basic accessors..."
@@ -25,6 +28,27 @@ def basic(src):
     else:
         print '__name__ "option" properly hidden by the API.'
 
+    # Make sure the right things happen for remove_option();
+    # added to include check for SourceForge bug #123324:
+    if not cf.remove_option('Foo Bar', 'foo'):
+        raise TestFailed(
+            "remove_option() failed to report existance of option")
+    if cf.has_option('Foo Bar', 'foo'):
+        raise TestFailed("remove_option() failed to remove option")
+    if cf.remove_option('Foo Bar', 'foo'):
+        raise TestFailed(
+            "remove_option() failed to report non-existance of option"
+            " that was removed")
+    try:
+        cf.remove_option('No Such Section', 'foo')
+    except ConfigParser.NoSectionError:
+        pass
+    else:
+        raise TestFailed(
+            "remove_option() failed to report non-existance of option"
+            " that never existed")
+
+
 def interpolation(src):
     print
     print "Testing value interpolation..."