summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2012-07-07 16:58:44 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2012-07-07 16:58:44 (GMT)
commit31196dd7d0d2a4241d2d2cc9cf7721f91eb9eb8b (patch)
tree179b26b865cc3aa728c02492d1d1b0c393ebcb67 /Lib/test
parent5aa43542974c32b5a2a16acf42204e7a3cfcade9 (diff)
parentcba243215e8d0459e10332d44495761ddb8cfafb (diff)
downloadcpython-31196dd7d0d2a4241d2d2cc9cf7721f91eb9eb8b.zip
cpython-31196dd7d0d2a4241d2d2cc9cf7721f91eb9eb8b.tar.gz
cpython-31196dd7d0d2a4241d2d2cc9cf7721f91eb9eb8b.tar.bz2
Merge remote
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_configparser.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/Lib/test/test_configparser.py b/Lib/test/test_configparser.py
index a6e9050..8d82182 100644
--- a/Lib/test/test_configparser.py
+++ b/Lib/test/test_configparser.py
@@ -1618,6 +1618,42 @@ class ExceptionPicklingTestCase(unittest.TestCase):
self.assertEqual(repr(e1), repr(e2))
+class InlineCommentStrippingTestCase(unittest.TestCase):
+ """Tests for issue #14590: ConfigParser doesn't strip inline comment when
+ delimiter occurs earlier without preceding space.."""
+
+ def test_stripping(self):
+ cfg = configparser.ConfigParser(inline_comment_prefixes=(';', '#',
+ '//'))
+ cfg.read_string("""
+ [section]
+ k1 = v1;still v1
+ k2 = v2 ;a comment
+ k3 = v3 ; also a comment
+ k4 = v4;still v4 ;a comment
+ k5 = v5;still v5 ; also a comment
+ k6 = v6;still v6; and still v6 ;a comment
+ k7 = v7;still v7; and still v7 ; also a comment
+
+ [multiprefix]
+ k1 = v1;still v1 #a comment ; yeah, pretty much
+ k2 = v2 // this already is a comment ; continued
+ k3 = v3;#//still v3# and still v3 ; a comment
+ """)
+ s = cfg['section']
+ self.assertEqual(s['k1'], 'v1;still v1')
+ self.assertEqual(s['k2'], 'v2')
+ self.assertEqual(s['k3'], 'v3')
+ self.assertEqual(s['k4'], 'v4;still v4')
+ self.assertEqual(s['k5'], 'v5;still v5')
+ self.assertEqual(s['k6'], 'v6;still v6; and still v6')
+ self.assertEqual(s['k7'], 'v7;still v7; and still v7')
+ s = cfg['multiprefix']
+ self.assertEqual(s['k1'], 'v1;still v1')
+ self.assertEqual(s['k2'], 'v2')
+ self.assertEqual(s['k3'], 'v3;#//still v3# and still v3')
+
+
def test_main():
support.run_unittest(
ConfigParserTestCase,
@@ -1640,4 +1676,5 @@ def test_main():
ReadFileTestCase,
CoverageOneHundredTestCase,
ExceptionPicklingTestCase,
+ InlineCommentStrippingTestCase,
)