diff --git a/reframe/core/variables.py b/reframe/core/variables.py index ef1fce3603..4a110358b5 100644 --- a/reframe/core/variables.py +++ b/reframe/core/variables.py @@ -17,6 +17,9 @@ class _UndefinedType: '''Custom type to flag a variable as undefined.''' __slots__ = () + def __deepcopy__(self, memo): + return self + _Undefined = _UndefinedType() @@ -116,7 +119,7 @@ def join(self, other, cls): f'parent classes of class {cls.__qualname__!r}' ) - self.vars[key] = var + self.vars[key] = copy.deepcopy(var) # Carry over the set of injected variables self._injected_vars.update(other._injected_vars) diff --git a/unittests/test_variables.py b/unittests/test_variables.py index 0c982bf33c..1f9a4d44e5 100644 --- a/unittests/test_variables.py +++ b/unittests/test_variables.py @@ -178,8 +178,13 @@ def __init__(self): class Bar(Base): pass + class Baz(Base): + my_var = [] + + assert Base().my_var == [1, 2] assert Foo().my_var == [1, 2, 3] assert Bar().my_var == [1, 2] + assert Baz().my_var == [] def test_variable_access():