Rev 5578: @jam: Here are the tests mentioned above. in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Fri Feb 18 19:24:10 UTC 2011


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5578
revision-id: v.ladeuil+lp at free.fr-20110218192410-e26rjil4fk2zkh06
parent: v.ladeuil+lp at free.fr-20110218155421-l36l3xv5822nxgrj
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: expand-options
timestamp: Fri 2011-02-18 20:24:10 +0100
message:
  @jam: Here are the tests mentioned above.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-02-18 11:33:53 +0000
+++ b/bzrlib/tests/test_config.py	2011-02-18 19:24:10 +0000
@@ -630,6 +630,38 @@
         self.assertEquals(['{foo', '}', '{', 'bar}'],
                           conf.get_user_option('hidden'))
 
+class TestLocationConfigOptionExpansion(tests.TestCaseInTempDir):
+
+    def get_config(self, location, string=None):
+        if string is None:
+            string = ''
+        # Since we don't save the config we won't strictly require to inherit
+        # from TestCaseInTempDir, but an error occurs so quickly...
+        c = config.LocationConfig.from_string(string, location)
+        return c
+
+    def test_dont_cross_unrelated_section(self):
+        c = self.get_config('/another/branch/path','''
+[/one/branch/path]
+foo = hello
+bar = {foo}/2
+
+[/another/branch/path]
+bar = {foo}/2
+''')
+        self.assertRaises(errors.ExpandingUnknownOption,
+                          c.get_user_option, 'bar')
+
+    def test_cross_related_sections(self):
+        c = self.get_config('/project/branch/path','''
+[/project]
+foo = qu
+
+[/project/branch/path]
+bar = {foo}ux
+''')
+        self.assertEquals('quux', c.get_user_option('bar'))
+
 
 class TestIniBaseConfigOnDisk(tests.TestCaseInTempDir):
 



More information about the bazaar-commits mailing list