summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_configparser.py
diff options
context:
space:
mode:
authorPrince Roshan <princekrroshan01@gmail.com>2024-03-06 14:05:54 (GMT)
committerGitHub <noreply@github.com>2024-03-06 14:05:54 (GMT)
commite800265aa1f3451855a2fc14fbafc4d89392e35c (patch)
tree8cd6eb829895313aacae2c12f33f12b1345aa0c7 /Lib/test/test_configparser.py
parent27858e2a17924dfac9a10efc17caee1f5126ea19 (diff)
downloadcpython-e800265aa1f3451855a2fc14fbafc4d89392e35c.zip
cpython-e800265aa1f3451855a2fc14fbafc4d89392e35c.tar.gz
cpython-e800265aa1f3451855a2fc14fbafc4d89392e35c.tar.bz2
gh-107625: configparser: Raise error if a missing value is continued (GH-107651)
Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'Lib/test/test_configparser.py')
-rw-r--r--Lib/test/test_configparser.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py
index 2d7dfbd..5d58e34 100644
--- a/Lib/test/test_configparser.py
+++ b/Lib/test/test_configparser.py
@@ -1555,6 +1555,30 @@ class ReadFileTestCase(unittest.TestCase):
"'[badbad'"
)
+ def test_keys_without_value_with_extra_whitespace(self):
+ lines = [
+ '[SECT]\n',
+ 'KEY1\n',
+ ' KEY2 = VAL2\n', # note the Space before the key!
+ ]
+ parser = configparser.ConfigParser(
+ comment_prefixes="",
+ allow_no_value=True,
+ strict=False,
+ delimiters=('=',),
+ interpolation=None,
+ )
+ with self.assertRaises(configparser.MultilineContinuationError) as dse:
+ parser.read_file(lines)
+ self.assertEqual(
+ str(dse.exception),
+ "Key without value continued with an indented line.\n"
+ "file: '<???>', line: 3\n"
+ "' KEY2 = VAL2\\n'"
+ )
+
+
+
class CoverageOneHundredTestCase(unittest.TestCase):
"""Covers edge cases in the codebase."""