Merge "Don't save @property methods with other attributes"

This commit is contained in:
Jenkins 2017-05-02 03:23:27 +00:00 committed by Gerrit Code Review
commit f41879b009
2 changed files with 17 additions and 1 deletions

View File

@ -20,6 +20,15 @@ from mistral.utils import inspect_utils as i_u
from mistral.workflow import commands
class ClassWithProperties(object):
a = 1
@property
def prop(self):
pass
class InspectUtilsTest(base.BaseTest):
def test_get_parameters_str(self):
action_class = std_actions.HTTPAction
@ -48,3 +57,9 @@ class InspectUtilsTest(base.BaseTest):
parameters_str = i_u.get_arg_list_as_str(test_func)
self.assertEqual("foo, bar=null", parameters_str)
def test_get_public_fields(self):
attrs = i_u.get_public_fields(ClassWithProperties)
self.assertEqual(attrs, {'a': 1})

View File

@ -28,7 +28,8 @@ def get_public_fields(obj):
attr = getattr(obj, attribute_str)
is_field = not (inspect.isbuiltin(attr)
or inspect.isfunction(attr)
or inspect.ismethod(attr))
or inspect.ismethod(attr)
or isinstance(attr, property))
if is_field:
public_fields[attribute_str] = attr