From d415f9292cfd6d0c9dd7aeebdff716b8b6b08c08 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Sun, 24 May 2020 23:45:39 +0300 Subject: [PATCH 1/8] Fixed test names --- utest/test_get_keyword_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utest/test_get_keyword_types.py b/utest/test_get_keyword_types.py index fab2953..402f3fa 100644 --- a/utest/test_get_keyword_types.py +++ b/utest/test_get_keyword_types.py @@ -184,13 +184,13 @@ def test_keyword_only_arguments_many(lib_types): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') -def test_keyword_only_arguments_many(lib_types): +def test_keyword_mandatory_and_keyword_only_arguments(lib_types): types = lib_types.get_keyword_types('keyword_mandatory_and_keyword_only_arguments') assert types == {'arg': int, 'some': bool} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') -def test_keyword_only_arguments_many(lib_types): +def test_keyword_only_arguments_many_positional_and_default(lib_types): types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default') assert types == {'four': bool, 'five': type(None), 'six': bool} From dae82d06bdf41b5d018288be55c545e0ce76b0d1 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Mon, 25 May 2020 00:24:28 +0300 Subject: [PATCH 2/8] Fixed code and utest --- atest/DynamicTypesAnnotationsLibrary.py | 10 +++++--- atest/DynamicTypesLibrary.py | 4 --- src/robotlibcore.py | 12 +-------- utest/test_get_keyword_source.py | 4 +-- utest/test_get_keyword_types.py | 34 +++++++++---------------- utest/test_robotlibcore.py | 2 -- 6 files changed, 21 insertions(+), 45 deletions(-) diff --git a/atest/DynamicTypesAnnotationsLibrary.py b/atest/DynamicTypesAnnotationsLibrary.py index b444c9b..7178527 100644 --- a/atest/DynamicTypesAnnotationsLibrary.py +++ b/atest/DynamicTypesAnnotationsLibrary.py @@ -55,7 +55,7 @@ def keyword_with_webdriver(self, arg: CustomObject): return arg @keyword - def keyword_default_and_annotation(self: 'DynamicTypesAnnotationsLibrary', arg1: int, arg2=False) -> str: + def keyword_default_and_annotation(self: 'DynamicTypesAnnotationsLibrary', arg1: int, arg2: Union[bool, str] = False) -> str: return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2)) @keyword(types={'arg': str}) @@ -67,7 +67,7 @@ def keyword_robot_types_disabled_and_annotations(self, arg: int): return '%s: %s' % (arg, type(arg)) @keyword(types={'arg1': str}) - def keyword_robot_types_and_bool_defaults(self, arg1, arg2=False): + def keyword_robot_types_and_bool_hint(self, arg1, arg2: bool): return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2)) @keyword @@ -87,7 +87,9 @@ def keyword_only_arguments_no_vararg(self, *, other): return f'{other}: {type(other)}' @keyword - def keyword_only_arguments_many_positional_and_default(self: 'DynamicTypesAnnotationsLibrary', *varargs, one, two, three, four=True, five=None, six=False): + def keyword_only_arguments_many_positional_and_default(self: 'DynamicTypesAnnotationsLibrary', *varargs, one, two, + three, four: Union[int, str] = 1, five=None, + six: Union[bool, str] = False): return f'{varargs}, {one}, {two}, {three}, {four}, {five}, {six}' @keyword @@ -99,7 +101,7 @@ def keyword_only_arguments_many(self, *varargs, some='value', other=None): return f'{some}: {type(some)}, {other}: {type(other)}, {varargs}: {type(varargs)}' @keyword - def keyword_mandatory_and_keyword_only_arguments(self, arg: int, *vararg, some=True): + def keyword_mandatory_and_keyword_only_arguments(self, arg: int, *vararg, some: bool): return f'{arg}, {vararg}, {some}' @keyword diff --git a/atest/DynamicTypesLibrary.py b/atest/DynamicTypesLibrary.py index 8fbb0d6..178550b 100644 --- a/atest/DynamicTypesLibrary.py +++ b/atest/DynamicTypesLibrary.py @@ -53,10 +53,6 @@ def keyword_default_types(self, arg=None): def keyword_many_default_types(self, arg1=1, arg2='Foobar'): return arg1, arg2 - @keyword - def keyword_booleans(self, arg1=True, arg2=False): - return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2)) - @keyword def keyword_none(self, arg=None): return '%s: %s' % (arg, type(arg)) diff --git a/src/robotlibcore.py b/src/robotlibcore.py index 4e79b6e..d95a05a 100644 --- a/src/robotlibcore.py +++ b/src/robotlibcore.py @@ -124,7 +124,7 @@ def get_keyword_types(self, keyword_name): return types if not types: types = self.__get_typing_hints(method) - types = self.__join_defaults_with_types(method, types) + types.pop('return', None) return types def __get_keyword(self, keyword_name): @@ -143,16 +143,6 @@ def __get_typing_hints(self, method): spec = ArgumentSpec.from_function(method) return spec.get_typing_hints() - def __join_defaults_with_types(self, method, types): - spec = ArgumentSpec.from_function(method) - for name, value in spec.defaults: - if name not in types and isinstance(value, (bool, type(None))): - types[name] = type(value) - for name, value in spec.kwonlydefaults: - if name not in types and isinstance(value, (bool, type(None))): - types[name] = type(value) - return types - def get_keyword_source(self, keyword_name): method = self.__get_keyword(keyword_name) path = self.__get_keyword_path(method) diff --git a/utest/test_get_keyword_source.py b/utest/test_get_keyword_source.py index 4dbae3a..eab55a6 100644 --- a/utest/test_get_keyword_source.py +++ b/utest/test_get_keyword_source.py @@ -52,7 +52,7 @@ def test_location_in_class(lib, lib_path_components): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_decorator_wrapper(lib_types, lib_path_types): source = lib_types.get_keyword_source('keyword_wrapped') - assert source == '%s:76' % lib_path_types + assert source == '%s:72' % lib_path_types def test_location_in_class_custom_keyword_name(lib, lib_path_components): @@ -81,7 +81,7 @@ def test_no_path_and_no_line_number(lib, when): def test_def_in_decorator(lib_types, lib_path_types): source = lib_types.get_keyword_source('keyword_with_def_deco') - assert source == '%s:70' % lib_path_types + assert source == '%s:66' % lib_path_types def test_error_in_getfile(lib, when): diff --git a/utest/test_get_keyword_types.py b/utest/test_get_keyword_types.py index 402f3fa..14e6460 100644 --- a/utest/test_get_keyword_types.py +++ b/utest/test_get_keyword_types.py @@ -33,7 +33,7 @@ def test_types_disabled(lib): def test_keyword_types_and_bool_default(lib): types = lib.get_keyword_types('keyword_robot_types_and_bool_default') - assert types == {'arg1': str, 'arg2': bool} + assert types == {'arg1': str} def test_one_keyword_type_defined(lib): @@ -51,14 +51,9 @@ def test_not_keyword(lib): lib.get_keyword_types('not_keyword') -def test_keyword_booleans(lib): - types = lib.get_keyword_types('keyword_booleans') - assert types == {'arg1': bool, 'arg2': bool} - - def test_keyword_none(lib): types = lib.get_keyword_types('keyword_none') - assert types == {'arg': type(None)} + assert types == {} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') @@ -79,11 +74,6 @@ def test_multiple_types(lib_types): assert types == {'arg': Union[List, None]} -def test_keyword_with_default_type(lib): - types = lib.get_keyword_types('keyword_default_types') - assert types == {'arg': type(None)} - - @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_new_type(lib_types): types = lib_types.get_keyword_types('keyword_new_type') @@ -123,7 +113,7 @@ def test_keyword_with_annotation_external_class(lib_types): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_with_annotation_and_default(lib_types): types = lib_types.get_keyword_types('keyword_default_and_annotation') - assert types == {'arg1': int, 'arg2': bool} + assert types == {'arg1': int, 'arg2': Union[bool, str]} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') @@ -140,13 +130,13 @@ def test_keyword_with_robot_types_disbaled_and_annotations(lib_types): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_with_robot_types_and_bool_annotations(lib_types): - types = lib_types.get_keyword_types('keyword_robot_types_and_bool_defaults') - assert types == {'arg1': str, 'arg2': bool} - + types = lib_types.get_keyword_types('keyword_robot_types_and_bool_hint') + assert types == {'arg1': str} -def test_init_args(lib): - types = lib.get_keyword_types('__init__') - assert types == {'arg': bool} +@pytest.mark.skipif(PY2, reason='Only applicable on Python 3') +def test_init_args(lib_types): + types = lib_types.get_keyword_types('__init__') + assert types == {'arg': str} def test_dummy_magic_method(lib): @@ -180,7 +170,7 @@ def test_keyword_only_arguments(lib_types): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_only_arguments_many(lib_types): types = lib_types.get_keyword_types('keyword_only_arguments_many') - assert types == {'other': type(None)} + assert types == {} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') @@ -192,13 +182,13 @@ def test_keyword_mandatory_and_keyword_only_arguments(lib_types): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_only_arguments_many_positional_and_default(lib_types): types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default') - assert types == {'four': bool, 'five': type(None), 'six': bool} + assert types == {'four': Union[int, str], 'six': Union[bool, str]} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_all_args(lib_types): types = lib_types.get_keyword_types('keyword_all_args') - assert types == {'value': bool} + assert types == {} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') diff --git a/utest/test_robotlibcore.py b/utest/test_robotlibcore.py index a37ef8e..5b7ab26 100644 --- a/utest/test_robotlibcore.py +++ b/utest/test_robotlibcore.py @@ -41,7 +41,6 @@ def test_dir(): '_DynamicCore__get_keyword_line', '_DynamicCore__get_keyword_path', '_DynamicCore__get_typing_hints', - '_DynamicCore__join_defaults_with_types', '_HybridCore__get_members', '_HybridCore__get_members_from_instance', '_custom_name', @@ -76,7 +75,6 @@ def test_dir(): '_DynamicCore__get_keyword', '_DynamicCore__get_keyword_line', '_DynamicCore__get_keyword_path', - '_DynamicCore__join_defaults_with_types', 'get_keyword_arguments', 'get_keyword_documentation', 'get_keyword_source', From 99b4c8d6b9aa6da9490637cdf987b62b4456cd7a Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Mon, 25 May 2020 00:30:25 +0300 Subject: [PATCH 3/8] Fixed atests --- atest/DynamicTypesLibrary.py | 4 ++++ atest/tests_types.robot | 11 +++-------- src/robotlibcore.py | 12 +++++++++++- utest/test_get_keyword_types.py | 4 ++-- utest/test_robotlibcore.py | 2 ++ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/atest/DynamicTypesLibrary.py b/atest/DynamicTypesLibrary.py index 178550b..8fbb0d6 100644 --- a/atest/DynamicTypesLibrary.py +++ b/atest/DynamicTypesLibrary.py @@ -53,6 +53,10 @@ def keyword_default_types(self, arg=None): def keyword_many_default_types(self, arg1=1, arg2='Foobar'): return arg1, arg2 + @keyword + def keyword_booleans(self, arg1=True, arg2=False): + return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2)) + @keyword def keyword_none(self, arg=None): return '%s: %s' % (arg, type(arg)) diff --git a/atest/tests_types.robot b/atest/tests_types.robot index 4d5a773..2a4f7e0 100644 --- a/atest/tests_types.robot +++ b/atest/tests_types.robot @@ -13,7 +13,7 @@ Keyword Default Argument As Abject None Default Value Keyword Default Argument As String None ${return} = DynamicTypesLibrary.Keyword None None - Should Match Regexp ${return} None: <(class|type) 'NoneType'> + Should Match Regexp ${return} None: <(class|type) '(unicode|str|NoneType)'> Keyword Default As Booleans With Defaults ${return} DynamicTypesLibrary.Keyword Booleans @@ -35,23 +35,18 @@ Keyword Annonations And Bool Defaults Using Default 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) 'bool'> + 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) 'bool'> + 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 Robot Types Defined - [Tags] py3 - ${return} = DynamicTypesAnnotationsLibrary.Keyword Robot Types And Bool Defaults tidii 111 - Should Match Regexp ${return} tidii: <(class|type) 'str'>, 111: <(class|type) 'str'> - Keyword Annonations And Keyword Only Arguments [Tags] py3 ${return} = DynamicTypesAnnotationsLibrary.Keyword Only Arguments 1 ${1} some=222 diff --git a/src/robotlibcore.py b/src/robotlibcore.py index d95a05a..b6bf0f8 100644 --- a/src/robotlibcore.py +++ b/src/robotlibcore.py @@ -124,7 +124,7 @@ def get_keyword_types(self, keyword_name): return types if not types: types = self.__get_typing_hints(method) - types.pop('return', None) + types = self.__join_defaults_with_types(method, types) return types def __get_keyword(self, keyword_name): @@ -137,6 +137,16 @@ def __get_keyword(self, keyword_name): raise ValueError('Keyword "%s" not found.' % keyword_name) return method + def __join_defaults_with_types(self, method, types): + spec = ArgumentSpec.from_function(method) + for name, value in spec.defaults: + if name not in types and isinstance(value, bool): + types[name] = type(value) + for name, value in spec.kwonlydefaults: + if name not in types and isinstance(value, bool): + types[name] = type(value) + return types + def __get_typing_hints(self, method): if PY2: return {} diff --git a/utest/test_get_keyword_types.py b/utest/test_get_keyword_types.py index 14e6460..fb69eea 100644 --- a/utest/test_get_keyword_types.py +++ b/utest/test_get_keyword_types.py @@ -33,7 +33,7 @@ def test_types_disabled(lib): def test_keyword_types_and_bool_default(lib): types = lib.get_keyword_types('keyword_robot_types_and_bool_default') - assert types == {'arg1': str} + assert types == {'arg1': str, 'arg2': bool} def test_one_keyword_type_defined(lib): @@ -188,7 +188,7 @@ def test_keyword_only_arguments_many_positional_and_default(lib_types): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_all_args(lib_types): types = lib_types.get_keyword_types('keyword_all_args') - assert types == {} + assert types == {'value': bool} @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') diff --git a/utest/test_robotlibcore.py b/utest/test_robotlibcore.py index 5b7ab26..a37ef8e 100644 --- a/utest/test_robotlibcore.py +++ b/utest/test_robotlibcore.py @@ -41,6 +41,7 @@ def test_dir(): '_DynamicCore__get_keyword_line', '_DynamicCore__get_keyword_path', '_DynamicCore__get_typing_hints', + '_DynamicCore__join_defaults_with_types', '_HybridCore__get_members', '_HybridCore__get_members_from_instance', '_custom_name', @@ -75,6 +76,7 @@ def test_dir(): '_DynamicCore__get_keyword', '_DynamicCore__get_keyword_line', '_DynamicCore__get_keyword_path', + '_DynamicCore__join_defaults_with_types', 'get_keyword_arguments', 'get_keyword_documentation', 'get_keyword_source', From f2a57e61bf3dd0e38f29efcd8dd9521360c0d547 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Thu, 28 May 2020 23:55:49 +0300 Subject: [PATCH 4/8] Fixed utests --- utest/test_get_keyword_source.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utest/test_get_keyword_source.py b/utest/test_get_keyword_source.py index eab55a6..4dbae3a 100644 --- a/utest/test_get_keyword_source.py +++ b/utest/test_get_keyword_source.py @@ -52,7 +52,7 @@ def test_location_in_class(lib, lib_path_components): @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_decorator_wrapper(lib_types, lib_path_types): source = lib_types.get_keyword_source('keyword_wrapped') - assert source == '%s:72' % lib_path_types + assert source == '%s:76' % lib_path_types def test_location_in_class_custom_keyword_name(lib, lib_path_components): @@ -81,7 +81,7 @@ def test_no_path_and_no_line_number(lib, when): def test_def_in_decorator(lib_types, lib_path_types): source = lib_types.get_keyword_source('keyword_with_def_deco') - assert source == '%s:66' % lib_path_types + assert source == '%s:70' % lib_path_types def test_error_in_getfile(lib, when): From 4c8f85bf430ab3b430f6e4549b15b959afb129a7 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Thu, 28 May 2020 23:58:27 +0300 Subject: [PATCH 5/8] Tuning --- src/robotlibcore.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/robotlibcore.py b/src/robotlibcore.py index b6bf0f8..4e1ea8d 100644 --- a/src/robotlibcore.py +++ b/src/robotlibcore.py @@ -137,6 +137,12 @@ def __get_keyword(self, keyword_name): raise ValueError('Keyword "%s" not found.' % keyword_name) return method + def __get_typing_hints(self, method): + if PY2: + return {} + spec = ArgumentSpec.from_function(method) + return spec.get_typing_hints() + def __join_defaults_with_types(self, method, types): spec = ArgumentSpec.from_function(method) for name, value in spec.defaults: @@ -147,12 +153,6 @@ def __join_defaults_with_types(self, method, types): types[name] = type(value) return types - def __get_typing_hints(self, method): - if PY2: - return {} - spec = ArgumentSpec.from_function(method) - return spec.get_typing_hints() - def get_keyword_source(self, keyword_name): method = self.__get_keyword(keyword_name) path = self.__get_keyword_path(method) From d7a2a82f14bdeda673cfe3c7f04cb0da8b60aa7f Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Thu, 28 May 2020 23:58:41 +0300 Subject: [PATCH 6/8] Add missing test --- utest/test_get_keyword_types.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utest/test_get_keyword_types.py b/utest/test_get_keyword_types.py index fb69eea..5ed6a94 100644 --- a/utest/test_get_keyword_types.py +++ b/utest/test_get_keyword_types.py @@ -51,6 +51,11 @@ def test_not_keyword(lib): lib.get_keyword_types('not_keyword') +def test_keyword_booleans(lib): + types = lib.get_keyword_types('keyword_booleans') + assert types == {'arg1': bool, 'arg2': bool} + + def test_keyword_none(lib): types = lib.get_keyword_types('keyword_none') assert types == {} From bdd0dc45ea07374b9eefac01282040eadf4648a0 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Mon, 1 Jun 2020 23:42:30 +0300 Subject: [PATCH 7/8] Fixed based on comments --- src/robotlibcore.py | 9 +++++--- utest/test_get_keyword_types.py | 39 ++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/robotlibcore.py b/src/robotlibcore.py index 4e1ea8d..4b878de 100644 --- a/src/robotlibcore.py +++ b/src/robotlibcore.py @@ -124,7 +124,10 @@ def get_keyword_types(self, keyword_name): return types if not types: types = self.__get_typing_hints(method) - types = self.__join_defaults_with_types(method, types) + if RF31: + types = self.__join_defaults_with_types(method, types) + else: + types.pop('return', None) return types def __get_keyword(self, keyword_name): @@ -146,10 +149,10 @@ def __get_typing_hints(self, method): def __join_defaults_with_types(self, method, types): spec = ArgumentSpec.from_function(method) for name, value in spec.defaults: - if name not in types and isinstance(value, bool): + if name not in types and isinstance(value, (bool, type(None))): types[name] = type(value) for name, value in spec.kwonlydefaults: - if name not in types and isinstance(value, bool): + if name not in types and isinstance(value, (bool, type(None))): types[name] = type(value) return types diff --git a/utest/test_get_keyword_types.py b/utest/test_get_keyword_types.py index 5ed6a94..908d429 100644 --- a/utest/test_get_keyword_types.py +++ b/utest/test_get_keyword_types.py @@ -1,7 +1,7 @@ import pytest -from robotlibcore import PY2 +from robotlibcore import PY2, RF31 if not PY2: from typing import List, Union, Dict @@ -31,11 +31,18 @@ def test_types_disabled(lib): assert types is None -def test_keyword_types_and_bool_default(lib): +@pytest.mark.skipif(not RF31, reason='Only for RF3.1') +def test_keyword_types_and_bool_default_rf31(lib): types = lib.get_keyword_types('keyword_robot_types_and_bool_default') assert types == {'arg1': str, 'arg2': bool} +@pytest.mark.skipif(RF31, reason='Only for RF3.2+') +def test_keyword_types_and_bool_default_rf32(lib): + types = lib.get_keyword_types('keyword_robot_types_and_bool_default') + assert types == {'arg1': str} + + def test_one_keyword_type_defined(lib): types = lib.get_keyword_types('keyword_with_one_type') assert types == {'arg1': str} @@ -51,16 +58,30 @@ def test_not_keyword(lib): lib.get_keyword_types('not_keyword') -def test_keyword_booleans(lib): +@pytest.mark.skipif(not RF31, reason='Only for RF3.2+') +def test_keyword_booleans_rf31(lib): types = lib.get_keyword_types('keyword_booleans') assert types == {'arg1': bool, 'arg2': bool} -def test_keyword_none(lib): +@pytest.mark.skipif(RF31, reason='Only for RF3.2+') +def test_keyword_booleans_rf32(lib): + types = lib.get_keyword_types('keyword_booleans') + assert types == {} + + +@pytest.mark.skipif(RF31, reason='Only for RF3.2+') +def test_keyword_none_rf32(lib): types = lib.get_keyword_types('keyword_none') assert types == {} +@pytest.mark.skipif(not RF31, reason='Only for RF3.2+') +def test_keyword_none_rf31(lib): + types = lib.get_keyword_types('keyword_none') + assert types == {'arg': type(None)} + + @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_single_annotation(lib_types): types = lib_types.get_keyword_types('keyword_with_one_annotation') @@ -190,8 +211,16 @@ def test_keyword_only_arguments_many_positional_and_default(lib_types): assert types == {'four': Union[int, str], 'six': Union[bool, str]} +@pytest.mark.skipif(RF31, reason='Only for RF3.2+') +@pytest.mark.skipif(PY2, reason='Only applicable on Python 3') +def test_keyword_all_args_rf32(lib_types): + types = lib_types.get_keyword_types('keyword_all_args') + assert types == {} + + +@pytest.mark.skipif(not RF31, reason='Only for RF3.1') @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') -def test_keyword_all_args(lib_types): +def test_keyword_all_args_rf31(lib_types): types = lib_types.get_keyword_types('keyword_all_args') assert types == {'value': bool} From 97dc60fbb8835f8f66bd5e945f66a49143148d07 Mon Sep 17 00:00:00 2001 From: Tatu Aalto Date: Mon, 1 Jun 2020 23:51:31 +0300 Subject: [PATCH 8/8] Fixed RF31 errors --- utest/test_get_keyword_types.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/utest/test_get_keyword_types.py b/utest/test_get_keyword_types.py index 908d429..9104469 100644 --- a/utest/test_get_keyword_types.py +++ b/utest/test_get_keyword_types.py @@ -193,24 +193,40 @@ def test_keyword_only_arguments(lib_types): assert types == {} +@pytest.mark.skipif(RF31, reason='Only for RF3.2+') @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_only_arguments_many(lib_types): types = lib_types.get_keyword_types('keyword_only_arguments_many') assert types == {} +@pytest.mark.skipif(not RF31, reason='Only for RF3.1') +@pytest.mark.skipif(PY2, reason='Only applicable on Python 3') +def test_keyword_only_arguments_many(lib_types): + types = lib_types.get_keyword_types('keyword_only_arguments_many') + assert types == {'other': type(None)} + + @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_mandatory_and_keyword_only_arguments(lib_types): types = lib_types.get_keyword_types('keyword_mandatory_and_keyword_only_arguments') assert types == {'arg': int, 'some': bool} +@pytest.mark.skipif(RF31, reason='Only for RF3.2+') @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') -def test_keyword_only_arguments_many_positional_and_default(lib_types): +def test_keyword_only_arguments_many_positional_and_default_rf32(lib_types): types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default') assert types == {'four': Union[int, str], 'six': Union[bool, str]} +@pytest.mark.skipif(not RF31, reason='Only for RF3.1') +@pytest.mark.skipif(PY2, reason='Only applicable on Python 3') +def test_keyword_only_arguments_many_positional_and_default_rf31(lib_types): + types = lib_types.get_keyword_types('keyword_only_arguments_many_positional_and_default') + assert types == {'four': Union[int, str], 'five': type(None), 'six': Union[bool, str]} + + @pytest.mark.skipif(RF31, reason='Only for RF3.2+') @pytest.mark.skipif(PY2, reason='Only applicable on Python 3') def test_keyword_all_args_rf32(lib_types):