X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Fremote_test.py;h=0a6c3208ca876979b19444a032e2230ec9eb115f;hb=c42c7f08f5f9e30109877932847232ff581c2cdc;hp=43cb9b93080c92b1b4cec7167378ccf0cab804b9;hpb=0b1f8a7e69228bb6ac4862faafb05c05171e0edc;p=vpp.git diff --git a/test/remote_test.py b/test/remote_test.py index 43cb9b93080..0a6c3208ca8 100644 --- a/test/remote_test.py +++ b/test/remote_test.py @@ -43,14 +43,16 @@ class RemoteClassAttr(object): def __getattr__(self, attr): if attr[0] == '_': - raise AttributeError + if not (attr.startswith('__') and attr.endswith('__')): + raise AttributeError self._path.append(attr) return self def __setattr__(self, attr, val): if attr[0] == '_': - super(RemoteClassAttr, self).__setattr__(attr, val) - return + if not (attr.startswith('__') and attr.endswith('__')): + super(RemoteClassAttr, self).__setattr__(attr, val) + return self._path.append(attr) self._remote._remote_exec(RemoteClass.SETATTR, self.path_to_str(), True, value=val) @@ -114,15 +116,17 @@ class RemoteClass(Process): def __getattr__(self, attr): if attr[0] == '_' or not self.is_alive(): - if hasattr(super(RemoteClass, self), '__getattr__'): - return super(RemoteClass, self).__getattr__(attr) - raise AttributeError + if not (attr.startswith('__') and attr.endswith('__')): + if hasattr(super(RemoteClass, self), '__getattr__'): + return super(RemoteClass, self).__getattr__(attr) + raise AttributeError return RemoteClassAttr(self, attr) def __setattr__(self, attr, val): if attr[0] == '_' or not self.is_alive(): - super(RemoteClass, self).__setattr__(attr, val) - return + if not (attr.startswith('__') and attr.endswith('__')): + super(RemoteClass, self).__setattr__(attr, val) + return setattr(RemoteClassAttr(self, None), attr, val) def _remote_exec(self, op, path=None, ret=True, *args, **kwargs): @@ -241,7 +245,8 @@ class RemoteClass(Process): # copy at least serializable attributes and properties for name, member in inspect.getmembers(obj): if name[0] == '_': # skip private members - continue + if not (name.startswith('__') and name.endswith('__')): + continue if callable(member) and not isinstance(member, property): continue if not self._serializable(member): @@ -348,7 +353,7 @@ class RemoteVppTestCase(VppTestCase): @classmethod def setUpClass(cls): - # fork new process before clinet connects to VPP + # fork new process before client connects to VPP cls.remote_test = RemoteClass(RemoteVppTestCase) # start remote process @@ -375,12 +380,14 @@ class RemoteVppTestCase(VppTestCase): def __init__(self): super(RemoteVppTestCase, self).__init__("emptyTest") + # Note: __del__ is a 'Finalizer" not a 'Destructor'. + # https://docs.python.org/3/reference/datamodel.html#object.__del__ def __del__(self): if hasattr(self, "vpp"): - cls.vpp.poll() - if cls.vpp.returncode is None: - cls.vpp.terminate() - cls.vpp.communicate() + self.vpp.poll() + if self.vpp.returncode is None: + self.vpp.terminate() + self.vpp.communicate() @classmethod def setUpClass(cls, tempdir):