aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-03-10 07:03:22 -0700
committerOle Trøan <otroan@employees.org>2019-03-11 08:09:58 +0000
commitd3a9be2ca0b527bfeac808a822319e69e0d7fe76 (patch)
tree3fca640983207c69d2e4dcc8e82e65bb9f047782 /test
parent9a6dafd569db0d0b5dc9d7b5b34b17e3f411a9ee (diff)
Tests: remote_test.py. Private member test catching dunder names.
Private member check also catches __iter__, since it starts with '_'. Fixes: Captured traceback: ~~~~~~~~~~~~~~~~~~ b'Traceback (most recent call last):' b' File "/vpp/test/test_memif.py", line 47, in tearDown' b' remove_all_memif_vpp_config(self.remote_test)' b' File "/vpp/test/vpp_memif.py", line 36, in remove_all_memif_vpp_config' b' for d in dump:' b"TypeError: 'SerializableClassCopy' object is not iterable" b'' Change-Id: I6a3f3e0f2b1b2d0a2b97faa23bf542ff8f92de43 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'test')
-rw-r--r--test/remote_test.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/test/remote_test.py b/test/remote_test.py
index e90ccb24f83..bc6d70764ec 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):