Skip to content

Commit 3d2dcc5

Browse files
committed
Reveals the bug
1 parent 44d4cda commit 3d2dcc5

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

atest/DynamicTypesAnnotationsLibrary.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,7 @@ def enum_conversion(self, param: Optional[penum] = None):
148148
def keyword_with_deco_and_signature(self, arg1: bool = False, arg2: bool = False):
149149
"""Test me doc here"""
150150
return f"{arg1}: {type(arg1)}, {arg2}: {type(arg2)}"
151+
152+
@keyword
153+
def keyword_optional_with_none(self, arg: Optional[str] = None):
154+
return f"arg: {arg}, type: {type(arg)}"

atest/tests_types.robot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*** Settings ***
22
Library DynamicTypesLibrary.py
3+
Library DynamicTypesAnnotationsLibrary.py xxx
34
Suite Setup Import DynamicTypesAnnotationsLibrary In Python 3 Only
45

56
*** Test Cases ***
@@ -73,6 +74,16 @@ Enum Conversion To Invalid Value Should Fail
7374
Run Keyword And Expect Error ValueError: Argument 'param' got value 'not ok' that*
7475
... Enum Conversion not ok
7576

77+
Type Conversion With Optional And None
78+
${types} = Keyword Optional With None
79+
Should Contain ${types} arg: None,
80+
Should Contain ${types} <class 'NoneType'>
81+
${types} = Keyword Optional With None None
82+
Should Contain ${types} arg: None,
83+
Should Contain ${types} <class 'str'>
84+
${types} = Keyword Optional With None ${None}
85+
Should Contain ${types} arg: None,
86+
Should Contain ${types} <class 'NoneType'>
7687

7788
*** Keywords ***
7889
Import DynamicTypesAnnotationsLibrary In Python 3 Only

utest/test_get_keyword_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,8 @@ def test_keyword_self_and_keyword_only_types(lib_types):
180180
def test_keyword_with_decorator_arguments(lib_types):
181181
types = lib_types.get_keyword_types('keyword_with_deco_and_signature')
182182
assert types == {'arg1': bool, 'arg2': bool}
183+
184+
185+
def test_keyword_optional_with_none_1(lib_types):
186+
types = lib_types.get_keyword_types('keyword_optional_with_none')
187+
assert types == {'arg': Union[str, type(None)]}

0 commit comments

Comments
 (0)