Skip to content

Commit f034700

Browse files
committed
Lint Robot files
1 parent a5d75cc commit f034700

4 files changed

Lines changed: 38 additions & 38 deletions

File tree

atest/tests.robot

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
*** Settings ***
2-
Library ${LIBRARY}.py
2+
Library ${LIBRARY}.py
33

44
*** Variables ***
5-
${LIBRARY} DynamicLibrary
5+
${LIBRARY} DynamicLibrary
66

77
*** Test Cases ***
88
Keyword names
@@ -12,31 +12,32 @@ Keyword names
1212
Method
1313
Custom name
1414
Cust omna me
15-
Run Keyword If $LIBRARY == "ExtendExistingLibrary"
16-
... Keyword in extending library
15+
IF $LIBRARY == "ExtendExistingLibrary"
16+
Keyword in extending library
17+
END
1718

1819
Method without @keyword are not keyowrds
1920
[Documentation] FAIL GLOB: No keyword with name 'Not keyword' found.*
2021
Not keyword
2122

2223
Arguments
2324
[Template] Return value should be
24-
'foo', 'bar' Mandatory foo bar
25-
'foo', 'default', 3 Defaults foo
26-
'foo', 2, 3 Defaults foo ${2}
27-
'a', 'b', 'c' Defaults a b c
25+
'foo', 'bar' Mandatory foo bar
26+
'foo', 'default', 3 Defaults foo
27+
'foo', 2, 3 Defaults foo ${2}
28+
'a', 'b', 'c' Defaults a b c
2829

2930
Named arguments
3031
[Template] Return value should be
31-
'foo', 'bar' Mandatory foo arg2=bar
32-
'1', 2 Mandatory arg2=${2} arg1=1
33-
'x', 'default', 'y' Defaults x arg3=y
32+
'foo', 'bar' Mandatory foo arg2=bar
33+
'1', 2 Mandatory arg2=${2} arg1=1
34+
'x', 'default', 'y' Defaults x arg3=y
3435

3536
Varargs and kwargs
3637
[Template] Return value should be
37-
${EMPTY} Varargs and kwargs
38-
'a', 'b', 'c' Varargs and kwargs a b c
39-
a\='1', b\=2 Varargs and kwargs a=1 b=${2}
38+
${EMPTY} Varargs and kwargs
39+
'a', 'b', 'c' Varargs and kwargs a b c
40+
a\='1', b\=2 Varargs and kwargs a=1 b=${2}
4041
'a', 'b\=b', c\='c' Varargs and kwargs a b\=b c=c
4142

4243
Embedded arguments
@@ -47,5 +48,5 @@ Embedded arguments
4748
*** Keywords ***
4849
Return value should be
4950
[Arguments] ${expected} ${keyword} @{args} &{kwargs}
50-
${result} = Run Keyword ${keyword} @{args} &{kwargs}
51+
${result} Run Keyword ${keyword} @{args} &{kwargs}
5152
Should Be Equal ${result} ${expected}

atest/tests_types.robot

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
*** Settings ***
2-
Library DynamicTypesLibrary.py
3-
Library DynamicTypesAnnotationsLibrary.py xxx
4-
Suite Setup Import DynamicTypesAnnotationsLibrary In Python 3 Only
2+
Library DynamicTypesLibrary.py
3+
Library DynamicTypesAnnotationsLibrary.py xxx
54

65
*** Test Cases ***
76
Keyword Default Argument As Abject None
@@ -17,60 +16,51 @@ Keyword Default Argument As String None
1716
Should Match Regexp ${return} None: <(class|type) '(unicode|str|NoneType)'>
1817

1918
Keyword Default As Booleans With Defaults
20-
${return} DynamicTypesLibrary.Keyword Booleans
19+
${return} = DynamicTypesLibrary.Keyword Booleans
2120
Should Match Regexp ${return} True: <(class|type) 'bool'>, False: <(class|type) 'bool'>
2221

2322
Keyword Default As Booleans With Objects
2423
${return} = DynamicTypesLibrary.Keyword Booleans ${False} ${True}
2524
Should Match Regexp ${return} False: <(class|type) 'bool'>, True: <(class|type) 'bool'>
2625

2726
Keyword Annonations And Bool Defaults Using Default
28-
[Tags] py3
2927
${return} = DynamicTypesAnnotationsLibrary.Keyword Default And Annotation 42
3028
Should Match Regexp ${return} 42: <(class|type) 'int'>, False: <(class|type) 'bool'>
3129

3230
Keyword Annonations And Bool Defaults Defining All Arguments
33-
[Tags] py3
3431
${return} = DynamicTypesAnnotationsLibrary.Keyword Default And Annotation 1 true
3532
Should Match Regexp ${return} 1: <(class|type) 'int'>, true: <(class|type) 'str'>
3633

3734
Keyword Annonations And Bool Defaults Defining All Arguments And With Number
38-
[Tags] py3
3935
${return} = DynamicTypesAnnotationsLibrary.Keyword Default And Annotation ${1} true
4036
Should Match Regexp ${return} 1: <(class|type) 'int'>, true: <(class|type) 'str'>
4137

4238
Keyword Annonations And Robot Types Disbales Argument Conversion
43-
[Tags] py3
4439
${return} = DynamicTypesAnnotationsLibrary.Keyword Robot Types Disabled And Annotations 111
4540
Should Match Regexp ${return} 111: <(class|type) 'str'>
4641

4742
Keyword Annonations And Keyword Only Arguments
48-
[Tags] py3
4943
${return} = DynamicTypesAnnotationsLibrary.Keyword Only Arguments 1 ${1} some=222
5044
Should Match Regexp ${return} \\('1', 1\\): <class 'tuple'>, 222: <class '(int|str)'>
5145

5246
Keyword Only Arguments Without VarArg
53-
[Tags] py3
5447
${return} = DynamicTypesAnnotationsLibrary.Keyword Only Arguments No Vararg other=tidii
5548
Should Match ${return} tidii: <class 'str'>
5649

5750
Varargs and KeywordArgs With Typing Hints
58-
[Tags] py3
5951
${return} = DynamicTypesAnnotationsLibrary.Keyword Self And Keyword Only Types
6052
... this_is_mandatory # mandatory argument
61-
... 1 2 3 4 # varargs
62-
... other=True # other argument
63-
... key1=1 key2=2 # kwargs
64-
Should Match ${return}
53+
... 1 2 3 4 # varargs
54+
... other=True # other argument
55+
... key1=1 key2=2 # kwargs
56+
Should Match ${return}
6557
... this_is_mandatory: <class 'str'>, (1, 2, 3, 4): <class 'tuple'>, True: <class 'bool'>, {'key1': 1, 'key2': 2}: <class 'dict'>
6658

6759
Enum Conversion Should Work
68-
[Tags] py3
6960
${value} = Enum Conversion ok
7061
Should Match OK penum.ok ${value}
7162

7263
Enum Conversion To Invalid Value Should Fail
73-
[Tags] py3
7464
Run Keyword And Expect Error ValueError: Argument 'param' got value 'not ok' that*
7565
... Enum Conversion not ok
7666

@@ -84,9 +74,3 @@ Type Conversion With Optional And None
8474
${types} = Keyword Optional With None ${None}
8575
Should Contain ${types} arg: None,
8676
Should Contain ${types} <class 'NoneType'>
87-
88-
*** Keywords ***
89-
Import DynamicTypesAnnotationsLibrary In Python 3 Only
90-
${py3} = DynamicTypesLibrary.Is Python 3
91-
Run Keyword If ${py3}
92-
... Import Library DynamicTypesAnnotationsLibrary.py Dummy

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ robotstatuschecker
55
flake8
66
black
77
isort
8+
robotframework-tidy

tasks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import sys
23
from pathlib import Path
34

@@ -127,3 +128,16 @@ def lint(ctx):
127128
ctx.run("black --target-version py36 --line-length 120 src/")
128129
print("Run isort")
129130
ctx.run("isort src/")
131+
print("Run tidy")
132+
in_ci = os.getenv("GITHUB_WORKFLOW")
133+
print(f"Lint Robot files {'in ci' if in_ci else ''}")
134+
command = [
135+
"robotidy",
136+
"--lineseparator",
137+
"unix",
138+
"atest/",
139+
]
140+
if in_ci:
141+
command.insert(1, "--check")
142+
command.insert(1, "--diff")
143+
ctx.run(" ".join(command))

0 commit comments

Comments
 (0)