~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-03 12:04:03 UTC
  • mfrom: (6404.3.1 908050-protect-unquote)
  • Revision ID: pqm@pqm.ubuntu.com-20120103120403-05m286q87wkbygl6
(vila) Robustly unquote configuration values (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2760
2760
            self.assertIdempotent('a,b')
2761
2761
 
2762
2762
 
 
2763
class TestDictFromStore(tests.TestCase):
 
2764
 
 
2765
    def test_unquote_not_string(self):
 
2766
        conf = config.MemoryStack('x=2\n[a_section]\na=1\n')
 
2767
        value = conf.get('a_section')
 
2768
        # Urgh, despite 'conf' asking for the no-name section, we get the
 
2769
        # content of another section as a dict o_O
 
2770
        self.assertEquals({'a': '1'}, value)
 
2771
        unquoted = conf.store.unquote(value)
 
2772
        # Which cannot be unquoted but shouldn't crash either (the use cases
 
2773
        # are getting the value or displaying it. In the later case, '%s' will
 
2774
        # do).
 
2775
        self.assertEquals({'a': '1'}, unquoted)
 
2776
        self.assertEquals("{u'a': u'1'}", '%s' % (unquoted,))
 
2777
 
 
2778
 
2763
2779
class TestIniFileStoreContent(tests.TestCaseWithTransport):
2764
2780
    """Simulate loading a config store with content of various encodings.
2765
2781