From 2f99a0982bbf436e59135d05bd044f66d720c7e7 Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Tue, 11 Oct 2016 19:17:43 +0300 Subject: [PATCH] [docs] Fix plugin references for class-based scenarios InfoMixin obtains documentation from objects __doc__ properties. In case of class based scenarios, __doc__ property is empty ( we decided to use docstrings of "run" method). This patch adds new object property - _doc_source_, which should include object from which docstings will be used. Change-Id: I799222fe213b96a88110d6d2ebb5aa3fe2d8f153 --- rally/common/plugin/info.py | 3 ++- rally/task/scenario.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rally/common/plugin/info.py b/rally/common/plugin/info.py index 003ff00f7e..b410f93008 100644 --- a/rally/common/plugin/info.py +++ b/rally/common/plugin/info.py @@ -83,7 +83,8 @@ class InfoMixin(object): @classmethod def get_info(cls): plugin_ = getattr(cls, "func_ref", cls) - doc = parse_docstring(plugin_.__doc__) + doc_source = getattr(plugin_, "_doc_source_", plugin_) + doc = parse_docstring(doc_source.__doc__) return { "name": plugin_.get_name(), diff --git a/rally/task/scenario.py b/rally/task/scenario.py index 9aae346730..a4e0e7579f 100644 --- a/rally/task/scenario.py +++ b/rally/task/scenario.py @@ -50,6 +50,9 @@ def configure(name=None, namespace="default", context=None): scen.is_classbased = hasattr(scen, "run") and callable(scen.run) if not scen.is_classbased: plugin.from_func(Scenario)(scen) + else: + scen._doc_source_ = scen.run + scen._meta_init() if name: if "." not in name.strip("."):