diff --git a/docs/releasenotes/unreleased/fixes.2.rst b/docs/releasenotes/unreleased/fixes.2.rst new file mode 100644 index 00000000..2ba03ae1 --- /dev/null +++ b/docs/releasenotes/unreleased/fixes.2.rst @@ -0,0 +1,7 @@ +Missing [Setup] order for keywords in OrderSettings (#690) +---------------------------------------------------------- + +Since Robot Framework 7.0 it is possible to use ``[Setup]`` with keywords. This change was not reflected in +``OrderSettings`` settings order and it was not possible to configure order of ``[Setup]``. + +If you are using OrderSettings with custom order, this change requires to add ``setup`` to your order. diff --git a/robotidy/transformers/OrderSettings.py b/robotidy/transformers/OrderSettings.py index 771cd1ba..8fba3b0f 100644 --- a/robotidy/transformers/OrderSettings.py +++ b/robotidy/transformers/OrderSettings.py @@ -82,6 +82,7 @@ class OrderSettings(Transformer): "tags": Token.TAGS, "timeout": Token.TIMEOUT, "arguments": Token.ARGUMENTS, + "setup": Token.SETUP, "return": Token.RETURN, "teardown": Token.TEARDOWN, } @@ -96,7 +97,7 @@ class OrderSettings(Transformer): def __init__( self, - keyword_before: str = "documentation,tags,timeout,arguments", + keyword_before: str = "documentation,tags,arguments,timeout,setup", keyword_after: str = "teardown,return", test_before: str = "documentation,tags,template,timeout,setup", test_after: str = "teardown", diff --git a/tests/atest/transformers/OrderSettings/expected/custom_order_all_end.robot b/tests/atest/transformers/OrderSettings/expected/custom_order_all_end.robot index 3e71e287..d483af14 100644 --- a/tests/atest/transformers/OrderSettings/expected/custom_order_all_end.robot +++ b/tests/atest/transformers/OrderSettings/expected/custom_order_all_end.robot @@ -57,6 +57,7 @@ Keyword [Tags] sanity [Arguments] ${arg} [Teardown] Keyword + [Setup] Setup [Return] ${value} Another Keyword ${var} diff --git a/tests/atest/transformers/OrderSettings/expected/custom_order_default.robot b/tests/atest/transformers/OrderSettings/expected/custom_order_default.robot index 040a84fc..372440b4 100644 --- a/tests/atest/transformers/OrderSettings/expected/custom_order_default.robot +++ b/tests/atest/transformers/OrderSettings/expected/custom_order_default.robot @@ -47,6 +47,7 @@ Keyword ... doc [Tags] sanity [Arguments] ${arg} + [Setup] Setup Keyword No Operation IF ${condition} diff --git a/tests/atest/transformers/OrderSettings/expected/custom_order_without_test_teardown.robot b/tests/atest/transformers/OrderSettings/expected/custom_order_without_test_teardown.robot index 6b4fe0f9..63a50a9d 100644 --- a/tests/atest/transformers/OrderSettings/expected/custom_order_without_test_teardown.robot +++ b/tests/atest/transformers/OrderSettings/expected/custom_order_without_test_teardown.robot @@ -47,6 +47,7 @@ Keyword ... doc [Tags] sanity [Arguments] ${arg} + [Setup] Setup Keyword No Operation IF ${condition} diff --git a/tests/atest/transformers/OrderSettings/expected/test.robot b/tests/atest/transformers/OrderSettings/expected/test.robot index 040a84fc..372440b4 100644 --- a/tests/atest/transformers/OrderSettings/expected/test.robot +++ b/tests/atest/transformers/OrderSettings/expected/test.robot @@ -47,6 +47,7 @@ Keyword ... doc [Tags] sanity [Arguments] ${arg} + [Setup] Setup Keyword No Operation IF ${condition} diff --git a/tests/atest/transformers/OrderSettings/source/test.robot b/tests/atest/transformers/OrderSettings/source/test.robot index ce34b233..268b3705 100644 --- a/tests/atest/transformers/OrderSettings/source/test.robot +++ b/tests/atest/transformers/OrderSettings/source/test.robot @@ -58,6 +58,7 @@ Keyword Log ${var} END Pass + [Setup] Setup Another Keyword ${var} No Operation diff --git a/tests/atest/transformers/OrderSettings/test_order_settings.py b/tests/atest/transformers/OrderSettings/test_order_settings.py index ce10def4..9b0de92b 100644 --- a/tests/atest/transformers/OrderSettings/test_order_settings.py +++ b/tests/atest/transformers/OrderSettings/test_order_settings.py @@ -13,7 +13,7 @@ def test_order(self): "keyword_before, keyword_after, test_before, test_after, expected", [ ( - "documentation,tags,timeout,arguments", + "documentation,tags,timeout,arguments,setup", "teardown,return", "documentation,tags,template,timeout,setup", "teardown", @@ -21,7 +21,7 @@ def test_order(self): ), ( "", - "documentation,tags,timeout,arguments,teardown,return", + "documentation,tags,timeout,arguments,teardown,setup,return", "", "documentation,tags,template,timeout,setup,teardown", "custom_order_all_end.robot", @@ -50,7 +50,7 @@ def test_custom_order_invalid_param(self): expected_output = ( f"Error: {self.TRANSFORMER_NAME}: Invalid 'keyword_after' parameter value: 'tags,invalid'." f" Custom order should be provided in comma separated list with valid setting names: " - f"arguments,documentation,return,tags,teardown,timeout\n" + f"arguments,documentation,return,setup,tags,teardown,timeout\n" ) assert result.output == expected_output