Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.9, 3.10.0-rc.1]
python-version: [3.7, 3.9, 3.10.0-rc.1]
rf-version: [4.0.2, 4.1.1]

steps:
Expand Down
31 changes: 16 additions & 15 deletions atest/tests.robot
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*** Settings ***
Library ${LIBRARY}.py
Library ${LIBRARY}.py

*** Variables ***
${LIBRARY} DynamicLibrary
${LIBRARY} DynamicLibrary

*** Test Cases ***
Keyword names
Expand All @@ -12,31 +12,32 @@ Keyword names
Method
Custom name
Cust omna me
Run Keyword If $LIBRARY == "ExtendExistingLibrary"
... Keyword in extending library
IF $LIBRARY == "ExtendExistingLibrary"
Keyword in extending library
END

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

Arguments
[Template] Return value should be
'foo', 'bar' Mandatory foo bar
'foo', 'default', 3 Defaults foo
'foo', 2, 3 Defaults foo ${2}
'a', 'b', 'c' Defaults a b c
'foo', 'bar' Mandatory foo bar
'foo', 'default', 3 Defaults foo
'foo', 2, 3 Defaults foo ${2}
'a', 'b', 'c' Defaults a b c

Named arguments
[Template] Return value should be
'foo', 'bar' Mandatory foo arg2=bar
'1', 2 Mandatory arg2=${2} arg1=1
'x', 'default', 'y' Defaults x arg3=y
'foo', 'bar' Mandatory foo arg2=bar
'1', 2 Mandatory arg2=${2} arg1=1
'x', 'default', 'y' Defaults x arg3=y

Varargs and kwargs
[Template] Return value should be
${EMPTY} Varargs and kwargs
'a', 'b', 'c' Varargs and kwargs a b c
a\='1', b\=2 Varargs and kwargs a=1 b=${2}
${EMPTY} Varargs and kwargs
'a', 'b', 'c' Varargs and kwargs a b c
a\='1', b\=2 Varargs and kwargs a=1 b=${2}
'a', 'b\=b', c\='c' Varargs and kwargs a b\=b c=c

Embedded arguments
Expand All @@ -47,5 +48,5 @@ Embedded arguments
*** Keywords ***
Return value should be
[Arguments] ${expected} ${keyword} @{args} &{kwargs}
${result} = Run Keyword ${keyword} @{args} &{kwargs}
${result} Run Keyword ${keyword} @{args} &{kwargs}
Should Be Equal ${result} ${expected}
30 changes: 7 additions & 23 deletions atest/tests_types.robot
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
*** Settings ***
Library DynamicTypesLibrary.py
Library DynamicTypesAnnotationsLibrary.py xxx
Suite Setup Import DynamicTypesAnnotationsLibrary In Python 3 Only
Library DynamicTypesLibrary.py
Library DynamicTypesAnnotationsLibrary.py xxx

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

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

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

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

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

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

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

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

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

Varargs and KeywordArgs With Typing Hints
[Tags] py3
${return} = DynamicTypesAnnotationsLibrary.Keyword Self And Keyword Only Types
... this_is_mandatory # mandatory argument
... 1 2 3 4 # varargs
... other=True # other argument
... key1=1 key2=2 # kwargs
Should Match ${return}
... 1 2 3 4 # varargs
... other=True # other argument
... key1=1 key2=2 # kwargs
Should Match ${return}
... this_is_mandatory: <class 'str'>, (1, 2, 3, 4): <class 'tuple'>, True: <class 'bool'>, {'key1': 1, 'key2': 2}: <class 'dict'>

Enum Conversion Should Work
[Tags] py3
${value} = Enum Conversion ok
Should Match OK penum.ok ${value}

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

Expand All @@ -84,9 +74,3 @@ Type Conversion With Optional And None
${types} = Keyword Optional With None ${None}
Should Contain ${types} arg: None,
Should Contain ${types} <class 'NoneType'>

*** Keywords ***
Import DynamicTypesAnnotationsLibrary In Python 3 Only
${py3} = DynamicTypesLibrary.Is Python 3
Run Keyword If ${py3}
... Import Library DynamicTypesAnnotationsLibrary.py Dummy
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ robotstatuschecker
flake8
black
isort
robotframework-tidy
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
keywords = 'robotframework testing testautomation library development',
platforms = 'any',
classifiers = CLASSIFIERS,
python_requires = '>=3.6, <4',
python_requires = '>=3.7, <4',
package_dir = {'': 'src'},
packages = find_packages('src'),
py_modules = ['robotlibcore'],
Expand Down
14 changes: 14 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
from pathlib import Path

Expand Down Expand Up @@ -127,3 +128,16 @@ def lint(ctx):
ctx.run("black --target-version py36 --line-length 120 src/")
print("Run isort")
ctx.run("isort src/")
print("Run tidy")
in_ci = os.getenv("GITHUB_WORKFLOW")
print(f"Lint Robot files {'in ci' if in_ci else ''}")
command = [
"robotidy",
"--lineseparator",
"unix",
"atest/",
]
if in_ci:
command.insert(1, "--check")
command.insert(1, "--diff")
ctx.run(" ".join(command))