Skip to content

Commit

Permalink
Add [Setup] to keyword order
Browse files Browse the repository at this point in the history
  • Loading branch information
bhirsz committed May 12, 2024
1 parent 2355a2f commit 28f4761
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions docs/releasenotes/unreleased/fixes.2.rst
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion robotidy/transformers/OrderSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Keyword
[Tags] sanity
[Arguments] ${arg}
[Teardown] Keyword
[Setup] Setup
[Return] ${value}

Another Keyword ${var}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Keyword
... doc
[Tags] sanity
[Arguments] ${arg}
[Setup] Setup
Keyword
No Operation
IF ${condition}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Keyword
... doc
[Tags] sanity
[Arguments] ${arg}
[Setup] Setup
Keyword
No Operation
IF ${condition}
Expand Down
1 change: 1 addition & 0 deletions tests/atest/transformers/OrderSettings/expected/test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Keyword
... doc
[Tags] sanity
[Arguments] ${arg}
[Setup] Setup
Keyword
No Operation
IF ${condition}
Expand Down
1 change: 1 addition & 0 deletions tests/atest/transformers/OrderSettings/source/test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Keyword
Log ${var}
END
Pass
[Setup] Setup

Another Keyword ${var}
No Operation
Expand Down
6 changes: 3 additions & 3 deletions tests/atest/transformers/OrderSettings/test_order_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ 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",
"custom_order_default.robot",
),
(
"",
"documentation,tags,timeout,arguments,teardown,return",
"documentation,tags,timeout,arguments,teardown,setup,return",
"",
"documentation,tags,template,timeout,setup,teardown",
"custom_order_all_end.robot",
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 28f4761

Please sign in to comment.