summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_configparser.py
diff options
context:
space:
mode:
authorJames Tocknell <aragilar+github@gmail.com>2017-08-21 22:46:30 (GMT)
committerƁukasz Langa <lukasz@langa.pl>2017-08-21 22:46:30 (GMT)
commit44e6ad87340d50f48daf53b6a61138377d0d0d10 (patch)
tree4292c52f67030aa6223c544d5f4ecf7e7318709c /Lib/test/test_configparser.py
parent9a83f651f31b47b3f6c8b210f7807b26e8c373a5 (diff)
downloadcpython-44e6ad87340d50f48daf53b6a61138377d0d0d10.zip
cpython-44e6ad87340d50f48daf53b6a61138377d0d0d10.tar.gz
cpython-44e6ad87340d50f48daf53b6a61138377d0d0d10.tar.bz2
bpo-23835: Enforce that configparser defaults are strings (#2558)
* Enforce that configparser defaults are strings * Update test_configparser.py
Diffstat (limited to 'Lib/test/test_configparser.py')
-rw-r--r--Lib/test/test_configparser.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py
index 72c3f19..be22fa4 100644
--- a/Lib/test/test_configparser.py
+++ b/Lib/test/test_configparser.py
@@ -855,6 +855,15 @@ boolean {0[0]} NO
self.assertEqual(cf.get('DEFAULT', 'test'), 'test')
self.assertEqual(cf['DEFAULT']['test'], 'test')
+ def test_defaults_keyword(self):
+ # test that bpo-23835 is fixed
+ cf = self.newconfig(defaults={1: 2.4})
+ self.assertEqual(cf[self.default_section]['1'], '2.4')
+ self.assertAlmostEqual(cf[self.default_section].getfloat('1'), 2.4)
+ cf = self.newconfig(defaults={"A": 5.2})
+ self.assertEqual(cf[self.default_section]['a'], '5.2')
+ self.assertAlmostEqual(cf[self.default_section].getfloat('a'), 5.2)
+
class StrictTestCase(BasicTestCase, unittest.TestCase):
config_class = configparser.RawConfigParser