Update allow_none_override as agreed under PR #21
diff --git a/reclass/datatypes/tests/test_parameters.py b/reclass/datatypes/tests/test_parameters.py
index 577bdc4..5c91893 100644
--- a/reclass/datatypes/tests/test_parameters.py
+++ b/reclass/datatypes/tests/test_parameters.py
@@ -202,6 +202,15 @@
p1.initialise_interpolation()
self.assertEqual(p1.as_dict()['key'], None)
+ def test_merge_none_over_list_negative(self):
+ l = ['foo', 1, 2]
+ settings = Settings({'allow_none_override': False})
+ p1 = Parameters(dict(key=l[:2]), settings, '')
+ p2 = Parameters(dict(key=None), settings, '')
+ with self.assertRaises(TypeError):
+ p1.merge(p2)
+ p1.initialise_interpolation()
+
def test_merge_none_over_dict(self):
settings = Settings({'allow_none_override': True})
p1 = Parameters(dict(key=SIMPLE), settings, '')
@@ -210,6 +219,14 @@
p1.initialise_interpolation()
self.assertEqual(p1.as_dict()['key'], None)
+ def test_merge_none_over_dict_negative(self):
+ settings = Settings({'allow_none_override': False})
+ p1 = Parameters(dict(key=SIMPLE), settings, '')
+ p2 = Parameters(dict(key=None), settings, '')
+ with self.assertRaises(TypeError):
+ p1.merge(p2)
+ p1.initialise_interpolation()
+
# def test_merge_bare_dict_over_dict(self):
# settings = Settings({'allow_bare_override': True})
# p1 = Parameters(dict(key=SIMPLE), settings, '')
diff --git a/reclass/defaults.py b/reclass/defaults.py
index 980bb92..a07877d 100644
--- a/reclass/defaults.py
+++ b/reclass/defaults.py
@@ -29,7 +29,7 @@
OPT_ALLOW_SCALAR_OVER_LIST = False
OPT_ALLOW_LIST_OVER_SCALAR = False
OPT_ALLOW_DICT_OVER_SCALAR = False
-OPT_ALLOW_NONE_OVERRIDE = True
+OPT_ALLOW_NONE_OVERRIDE = False
OPT_INVENTORY_IGNORE_FAILED_NODE = False
OPT_INVENTORY_IGNORE_FAILED_RENDER = False
diff --git a/reclass/values/scaitem.py b/reclass/values/scaitem.py
index 466d3c9..6bd65dc 100644
--- a/reclass/values/scaitem.py
+++ b/reclass/values/scaitem.py
@@ -21,12 +21,12 @@
if item.type == Item.SCALAR:
return self
elif item.type == Item.LIST:
- if self._settings.allow_scalar_over_list or (self._settings.allow_none_override and self._value in [None, 'none', 'None']):
+ if self._settings.allow_scalar_over_list or (self._settings.allow_none_override and self._value is None):
return self
else:
raise TypeError('allow scalar over list = False: cannot merge %s over %s' % (repr(self), repr(item)))
elif item.type == Item.DICTIONARY:
- if self._settings.allow_scalar_over_dict or (self._settings.allow_none_override and self._value in [None, 'none', 'None']):
+ if self._settings.allow_scalar_over_dict or (self._settings.allow_none_override and self._value is None):
return self
else:
raise TypeError('allow scalar over dict = False: cannot merge %s over %s' % (repr(self), repr(item)))