changeset 711:6557cf9ecea5

FIX: When using attribute access for configurations the values are interpolated since long ago: fix the docu and add a test for that behaviour
author Franz Glasner <f.glasner@feldmann-mg.com>
date Tue, 15 Aug 2023 15:09:11 +0200
parents ff0de14493f1
children 8a28ff4ea59c
files configmix/config.py tests/test.py
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/configmix/config.py	Tue Aug 15 14:31:46 2023 +0200
+++ b/configmix/config.py	Tue Aug 15 15:09:11 2023 +0200
@@ -474,8 +474,8 @@
     """The configuration dictionary with attribute support or
     variable substitution.
 
-    .. note:: When retrieving by attribute names variables will *not*
-              substituted.
+    .. note:: When retrieving by attribute names variables will be
+              interpolated.
 
     """
 
@@ -1023,7 +1023,7 @@
                                    "%r (cached)" % (s, ))
                 else:
                     return res
-                
+
         if ((len_s >= 6)
                 and (s[2] == _FILTER_SEPARATOR)
                 and (start == 0)):
--- a/tests/test.py	Tue Aug 15 14:31:46 2023 +0200
+++ b/tests/test.py	Tue Aug 15 15:09:11 2023 +0200
@@ -1869,6 +1869,12 @@
         self.assertEqual(0x20, jcfg.key3)
         self.assertEqual(u"off", jcfg.tree2.key6)
 
+    def test_attribute_access_interpolates(self):
+        cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py"))
+        self.assertEqual(
+            [u"val1", u"val2", u"in the root namespace"],
+            cfg.tree1.tree2.key8)
+
     def test_attribute_access_non_existing(self):
         cfg = configmix.load(os.path.join(TESTDATADIR, "conf10.py"))
         jcfg = cfg.jailed(rootpath=(u"tree1",))