reframe
reframe copied to clipboard
Inconsistent use of "private" fields in subclasses
Subclasses of RegressionTest are not allowed to use private fields for obvious reasons. However, in several other places of the framework private fields (i.e. fields starting with _) have more the meaning of protected fields. We should figure this out and change the code accordingly. An option could be to treat fields starting with _ as protected and fields starting with __ are really private (which is actually true).
In the following, the _protected attribute can be accessed by subclasses, but the __private one is not accessible and an AttributeError is raised (technically, it can be accessed, but it's hacky and implementation dependent).
class C:
def __init__(self):
self._protected = 1
self.__private = 2
class D(C):
def __init__(self):
super().__init__()
self.a = self._protected
self.b = self.__private
d = D()
This results to the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in __init__
AttributeError: 'D' object has no attribute '_D__private'
Internal issue: https://madra.cscs.ch/scs/reframe/issues/474