diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 74ea4db..ef3d47b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: diff --git a/atest/tests.robot b/atest/tests.robot index b279fe0..12571b1 100644 --- a/atest/tests.robot +++ b/atest/tests.robot @@ -1,8 +1,8 @@ *** Settings *** -Library ${LIBRARY}.py +Library ${LIBRARY}.py *** Variables *** -${LIBRARY} DynamicLibrary +${LIBRARY} DynamicLibrary *** Test Cases *** Keyword names @@ -12,8 +12,9 @@ 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.* @@ -21,22 +22,22 @@ Method without @keyword are not keyowrds 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 @@ -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} diff --git a/atest/tests_types.robot b/atest/tests_types.robot index 436c8c0..7299790 100644 --- a/atest/tests_types.robot +++ b/atest/tests_types.robot @@ -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 @@ -17,7 +16,7 @@ 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 @@ -25,52 +24,43 @@ Keyword Default As Booleans With Objects 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\\): , 222: Keyword Only Arguments Without VarArg - [Tags] py3 ${return} = DynamicTypesAnnotationsLibrary.Keyword Only Arguments No Vararg other=tidii Should Match ${return} tidii: 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: , (1, 2, 3, 4): , True: , {'key1': 1, 'key2': 2}: 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 @@ -84,9 +74,3 @@ Type Conversion With Optional And None ${types} = Keyword Optional With None ${None} Should Contain ${types} arg: None, Should Contain ${types} - -*** Keywords *** -Import DynamicTypesAnnotationsLibrary In Python 3 Only - ${py3} = DynamicTypesLibrary.Is Python 3 - Run Keyword If ${py3} - ... Import Library DynamicTypesAnnotationsLibrary.py Dummy diff --git a/requirements-dev.txt b/requirements-dev.txt index 885b302..124691c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,3 +5,4 @@ robotstatuschecker flake8 black isort +robotframework-tidy \ No newline at end of file diff --git a/setup.py b/setup.py index 5997895..a182fcb 100644 --- a/setup.py +++ b/setup.py @@ -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'], diff --git a/tasks.py b/tasks.py index e4f0627..cb1807a 100644 --- a/tasks.py +++ b/tasks.py @@ -1,3 +1,4 @@ +import os import sys from pathlib import Path @@ -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))