changeset 506:dffa692751b1

Implement clear_cache() for the configuration
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 18 Dec 2021 11:06:34 +0100
parents 9e5fec21e2fb
children 402c7f5a2b76
files configmix/config.py tests/test.py
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configmix/config.py	Sat Dec 18 02:36:30 2021 +0100
+++ b/configmix/config.py	Sat Dec 18 11:06:34 2021 +0100
@@ -337,6 +337,9 @@
         self.__cache = {}
         super(Configuration, self).__init__(*args, **kwds)
 
+    def clear_cache(self):
+        self.__cache.clear()
+
     def __getitem__(self, key):
         """Mapping and list interface that forwards to :meth:`~.getvarl_s`
 
--- a/tests/test.py	Sat Dec 18 02:36:30 2021 +0100
+++ b/tests/test.py	Sat Dec 18 11:06:34 2021 +0100
@@ -828,6 +828,10 @@
 
         self.assertEqual([u"key1", u"key2", u"tree1"], s)
 
+    def test45_clear_cache(self):
+        cfg = self._load(os.path.join(TESTDATADIR, "conf10.py"))
+        cfg.clear_cache()
+
 
 class T02LoadAndMerge(_T02MixinLoadAndMerge, unittest.TestCase):