From 2b8242cf42c82fd58558da51394bf5b1c4e43f41 Mon Sep 17 00:00:00 2001 From: Xavier-Do Date: Fri, 13 Jan 2023 12:04:35 +0100 Subject: [PATCH] [IMP] runbot: default empty value for result --- runbot/models/build_config.py | 2 +- runbot/tests/test_build_config_step.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index e38c7944..f87c9f8b 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -930,7 +930,7 @@ class ConfigStep(models.Model): def _make_python_results(self, build): eval_ctx = self.make_python_ctx(build) safe_eval(self.python_result_code.strip(), eval_ctx, mode="exec", nocopy=True) - return_value = eval_ctx.get('return_value') + return_value = eval_ctx.get('return_value', {}) # todo check return_value or write in try except. Example: local result setted to wrong value if not isinstance(return_value, dict): raise RunbotException('python_result_code must set return_value to a dict values on build') diff --git a/runbot/tests/test_build_config_step.py b/runbot/tests/test_build_config_step.py index 6a257afb..702eacba 100644 --- a/runbot/tests/test_build_config_step.py +++ b/runbot/tests/test_build_config_step.py @@ -674,7 +674,7 @@ Initiating shutdown self.assertEqual(result, {'local_result': 'ok'}) # invalid result code (no return_value set) - config_step.python_result_code = """a = 2*5\nr = {'a': 'ok'}""" + config_step.python_result_code = """a = 2*5\nr = {'a': 'ok'}\nreturn_value = 'ko'""" with self.assertRaises(RunbotException): result = config_step._make_results(build)