diff --git a/mistral/tests/unit/utils/test_inspect_utils.py b/mistral/tests/unit/utils/test_inspect_utils.py index 8ee122ae..67b6650d 100644 --- a/mistral/tests/unit/utils/test_inspect_utils.py +++ b/mistral/tests/unit/utils/test_inspect_utils.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time + from mistral.actions import std_actions from mistral.tests.unit import base from mistral.utils import inspect_utils as i_u @@ -37,3 +39,11 @@ class InspectUtilsTest(base.BaseTest): parameters_str = i_u.get_arg_list_as_str(clazz.__init__) self.assertEqual("wf_ex, task_spec, ctx", parameters_str) + + def test_get_parameters_str_with_function_parameter(self): + + def test_func(foo, bar=None, test_func=time.sleep): + pass + + parameters_str = i_u.get_arg_list_as_str(test_func) + self.assertEqual("foo, bar=null", parameters_str) diff --git a/mistral/utils/inspect_utils.py b/mistral/utils/inspect_utils.py index e3491881..407049e5 100644 --- a/mistral/utils/inspect_utils.py +++ b/mistral/utils/inspect_utils.py @@ -66,12 +66,15 @@ def get_arg_list_as_str(func): for index, default in enumerate(args): if index >= diff_args_defs: - arg_str_list.append( - "%s=%s" % ( - args[index], - json.dumps(defs[index - diff_args_defs]) + try: + arg_str_list.append( + "%s=%s" % ( + args[index], + json.dumps(defs[index - diff_args_defs]) + ) ) - ) + except TypeError: + pass else: arg_str_list.append("%s" % args[index])