diff --git a/ChangeLog b/ChangeLog index 09f244a..85fdc0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ Sun Oct 26 08:50:38 2014 +0200 Emmanuel Garette * frozen with force_default_on_freeze can change owner * add force_permissive to config __iter__ * pass force_permissive to slave for a master or to master for a slave + * remove mandatory_warnings in config.py + * add force_permissive in mandatory_warnings Sat Oct 25 22:48:08 2014 +0200 Emmanuel Garette * cannot add unvalaible consistency for an option diff --git a/test/test_mandatory.py b/test/test_mandatory.py index 59da145..ae73418 100644 --- a/test/test_mandatory.py +++ b/test/test_mandatory.py @@ -211,6 +211,7 @@ def test_mandatory_warnings_ro(): config.str = 'a' config.read_only() assert config.cfgimpl_get_values().mandatory_warnings() == ['str1', 'unicode2', 'str3'] + assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3'] sleep(.1) @@ -223,6 +224,7 @@ def test_mandatory_warnings_rw(): assert config.cfgimpl_get_values().mandatory_warnings() == ['str', 'str1', 'unicode2', 'str3'] config.str = 'a' assert config.cfgimpl_get_values().mandatory_warnings() == ['str1', 'unicode2', 'str3'] + assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3'] sleep(.1) @@ -236,9 +238,24 @@ def test_mandatory_warnings_disabled(): assert config.cfgimpl_get_values().mandatory_warnings() == ['str', 'str1', 'unicode2', 'str3'] setting[descr.str].append('disabled') assert config.cfgimpl_get_values().mandatory_warnings() == ['str1', 'unicode2', 'str3'] + assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str1', 'unicode2', 'str3'] sleep(.1) +def test_mandatory_warnings_hidden(): + descr = make_description() + config = Config(descr) + config.str = '' + setting = config.cfgimpl_get_settings() + config.read_write() + config.cfgimpl_get_settings().setpermissive(('hidden',)) + config.str + assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str', 'str1', 'unicode2', 'str3'] + setting[descr.str].append('hidden') + assert list(config.cfgimpl_get_values().mandatory_warnings()) == ['str1', 'unicode2', 'str3'] + assert list(config.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == ['str', 'str1', 'unicode2', 'str3'] + + def test_mandatory_warnings_frozen(): descr = make_description() config = Config(descr) diff --git a/tiramisu/config.py b/tiramisu/config.py index da97f9e..6c95a81 100644 --- a/tiramisu/config.py +++ b/tiramisu/config.py @@ -734,8 +734,3 @@ class MetaConfig(GroupConfig): child._impl_meta = weakref.ref(self) super(MetaConfig, self).__init__(children, session_id, persistent, descr) - - -def mandatory_warnings(config): # pragma: optional cover - #only for retro-compatibility - return config.cfgimpl_get_values().mandatory_warnings() diff --git a/tiramisu/value.py b/tiramisu/value.py index 6d0ea70..11f6d79 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -441,7 +441,7 @@ class Values(object): raise ValueError(_("information's item" " not found: {0}").format(key)) - def mandatory_warnings(self): + def mandatory_warnings(self, force_permissive=False): """convenience function to trace Options that are mandatory and where no value has been set @@ -462,7 +462,8 @@ class Values(object): path = opt.impl_getpath(self._getcontext()) try: self._get_cached_item(opt, path=path, - force_properties=frozenset(('mandatory',))) + force_properties=frozenset(('mandatory',)), + force_permissive=force_permissive) except PropertiesOptionError as err: if err.proptype == ['mandatory']: _ret.append(path)