File tree Expand file tree Collapse file tree
tests/ert/unit_tests/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -194,8 +194,6 @@ def validate_types(self) -> Self:
194194 f"Failed to load { self .name } , script had wrong "
195195 f"type, expected ErtScript, got { ertscript_class } "
196196 )
197- if ertscript_class .__doc__ :
198- self .description = textwrap .dedent (ertscript_class .__doc__ .strip ())
199197 return self
200198
201199 @property
@@ -227,6 +225,12 @@ def serialize_model(self) -> _SerializedSiteInstalledErtScriptWorkflow:
227225 def load_ert_script_class (self ) -> builtins .type [ErtScript ]:
228226 return self .ert_script
229227
228+ @model_validator (mode = "after" )
229+ def set_default_description (self ) -> Self :
230+ if not self .description and self .ert_script .__doc__ :
231+ self .description = textwrap .dedent (self .ert_script .__doc__ .strip ())
232+ return self
233+
230234 @model_validator (mode = "before" )
231235 @classmethod
232236 def deserialize_model (
Original file line number Diff line number Diff line change @@ -72,6 +72,22 @@ class MockedErtScript(ErtScript):
7272 assert configs .get_workflows ()["MockedErtScript" ].description == "description"
7373
7474
75+ def test_that_explicit_workflow_description_takes_precedence_over_ertscript_docstring ():
76+ class MockedErtScript (ErtScript ):
77+ """Class docstring."""
78+
79+ configs = workflow_config .WorkflowConfigs ()
80+ configs .add_workflow (
81+ ert_script = MockedErtScript ,
82+ description = "Explicit description." ,
83+ )
84+
85+ assert (
86+ configs .get_workflows ()["MockedErtScript" ].description
87+ == "Explicit description."
88+ )
89+
90+
7591@pytest .mark .filterwarnings ("ignore:Use of legacy_ertscript_workflow is deprecated" )
7692def test_legacy_workflow_config_can_set_description_through_parameter ():
7793 class MockedErtScript (ErtScript ):
You can’t perform that action at this time.
0 commit comments