Skip to content

Commit de81e74

Browse files
committed
Add tests; edit NEWS entry.
1 parent ca0d4f7 commit de81e74

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

Lib/test/test_configparser.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,29 @@ def test_basic(self):
359359
the larch {0[1]} 1
360360
""".format(self.delimiters)))
361361

362-
def test_space_delimiter(self):
362+
@support.subTests('data', [
363+
'foo bar=baz',
364+
'foo bar=baz',
365+
'foo=bar=baz',
366+
'foo = bar=baz',
367+
'foo\t \t=\t \tbar=baz',
368+
])
369+
def test_space_delimiter(self, data):
363370
# gh-156353: Space should be accepted as a delimiter
364371
cf = self.newconfig(delimiters=(' ', '='))
365-
cf.read_string("[all]\nfoo bar=baz")
372+
cf.read_string(f"[all]\n{data}")
373+
self.assertEqual(cf.options('all'), ['foo'])
374+
self.assertEqual(cf.get('all', 'foo'), 'bar=baz')
375+
376+
@support.subTests('delimiter', ' =:;#x\t\0\N{RS}\N{CEDILLA}\N{CAT}')
377+
@support.subTests('space_before', ['', ' ', '\t', ' \t'])
378+
@support.subTests('space_after', ['', ' ', '\t', ' \t'])
379+
def test_any_delimiter(self, delimiter, space_before, space_after):
380+
cf = self.newconfig(
381+
delimiters=(delimiter,),
382+
inline_comment_prefixes=None,
383+
)
384+
cf.read_string(f"[all]\nfoo{space_before}{delimiter}{space_after}bar=baz")
366385
self.assertEqual(cf.options('all'), ['foo'])
367386
self.assertEqual(cf.get('all', 'foo'), 'bar=baz')
368387

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix :mod:`configparser` space delimiter parsing when using ``delimiters=(' ', '=')``.
1+
Fix :mod:`configparser` parsing when using whitespace in *delimiters*.

0 commit comments

Comments
 (0)