summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cfgparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_cfgparser.py')
-rw-r--r--Lib/test/test_cfgparser.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index f43d1d7..a20678d 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -755,6 +755,34 @@ class SafeConfigParserTestCaseTrickyFile(CfgParserTestCaseClass):
with self.assertRaises(UnicodeDecodeError):
cf.read(tricky, encoding='ascii')
+
+class Issue7005TestCase(unittest.TestCase):
+ """Test output when None is set() as a value and allow_no_value == False.
+
+ http://bugs.python.org/issue7005
+
+ """
+
+ expected_output = "[section]\noption = None\n\n"
+
+ def prepare(self, config_class):
+ # This is the default, but that's the point.
+ cp = config_class(allow_no_value=False)
+ cp.add_section("section")
+ cp.set("section", "option", None)
+ sio = io.StringIO()
+ cp.write(sio)
+ return sio.getvalue()
+
+ def test_none_as_value_stringified(self):
+ output = self.prepare(configparser.ConfigParser)
+ self.assertEqual(output, self.expected_output)
+
+ def test_none_as_value_stringified_raw(self):
+ output = self.prepare(configparser.RawConfigParser)
+ self.assertEqual(output, self.expected_output)
+
+
class SortedTestCase(RawConfigParserTestCase):
dict_type = SortedDict
@@ -811,6 +839,7 @@ def test_main():
SafeConfigParserTestCaseNoValue,
SafeConfigParserTestCaseTrickyFile,
SortedTestCase,
+ Issue7005TestCase,
StrictTestCase,
CompatibleTestCase,
)