~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

(vila) Merge 2.2 into 2.3 including fix for bug #710410 and tests
        fallouts (Alexander Belchenko)

Show diffs side-by-side

added added

removed removed

Lines of Context:
309
309
        """
310
310
        co = config.ConfigObj()
311
311
        co['test'] = 'foo#bar'
312
 
        lines = co.write()
 
312
        outfile = StringIO()
 
313
        co.write(outfile=outfile)
 
314
        lines = outfile.getvalue().splitlines()
313
315
        self.assertEqual(lines, ['test = "foo#bar"'])
314
316
        co2 = config.ConfigObj(lines)
315
317
        self.assertEqual(co2['test'], 'foo#bar')
316
318
 
 
319
    def test_triple_quotes(self):
 
320
        # Bug #710410: if the value string has triple quotes
 
321
        # then ConfigObj versions up to 4.7.2 will quote them wrong
 
322
        # and won't able to read them back
 
323
        triple_quotes_value = '''spam
 
324
""" that's my spam """
 
325
eggs'''
 
326
        co = config.ConfigObj()
 
327
        co['test'] = triple_quotes_value
 
328
        # While writing this test another bug in ConfigObj has been found:
 
329
        # method co.write() without arguments produces list of lines
 
330
        # one option per line, and multiline values are not split
 
331
        # across multiple lines,
 
332
        # and that breaks the parsing these lines back by ConfigObj.
 
333
        # This issue only affects test, but it's better to avoid
 
334
        # `co.write()` construct at all.
 
335
        # [bialix 20110222] bug report sent to ConfigObj's author
 
336
        outfile = StringIO()
 
337
        co.write(outfile=outfile)
 
338
        output = outfile.getvalue()
 
339
        # now we're trying to read it back
 
340
        co2 = config.ConfigObj(StringIO(output))
 
341
        self.assertEquals(triple_quotes_value, co2['test'])
 
342
 
317
343
 
318
344
erroneous_config = """[section] # line 1
319
345
good=good # line 2