Skip to content
Snippets Groups Projects
Commit a926b34a authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Changes to the `Configurable` method `merge`

See merge request !1319
parents 6adec3a7 e8d80311
No related branches found
No related tags found
1 merge request!1319Changes to the `Configurable` method `merge`
Pipeline #3758894 canceled
......@@ -281,6 +281,8 @@ class Configurable(ConfigMetaHelper):
(or both unnamed) and the settings must be mergable (according to
their semantics).
"""
if self is other:
return self
if type(self) is not type(other):
raise TypeError(
"cannot merge instance of {} into an instance of {}".format(
......@@ -296,8 +298,11 @@ class Configurable(ConfigMetaHelper):
)
)
for name in other._descriptors:
if not other.is_property_set(name):
for name in other._properties:
if (
name in self._properties
and self._properties[name] == other._properties[name]
):
continue
try:
setattr(
......
......@@ -23,6 +23,12 @@ def teardown_func():
useGlobalInstances(False)
def test_merge_identical():
a = MyAlg("ThisAlg", AnIntProp=42)
a.merge(a)
assert a.AnIntProp == 42
def test_merge():
a = MyAlg("ThisAlg", AnIntProp=42)
b = MyAlg("ThisAlg", AStringProp="42")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment