Skip to content

Commit 3799829

Browse files
committed
More tests
1 parent b16bceb commit 3799829

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

atest/DynamicTypesAnnotationsLibrary.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from enum import Enum
22
from functools import wraps
3-
from typing import List, Union, NewType, Optional, Tuple
3+
from typing import List, Union, NewType, Optional, Tuple, Dict
44

55
from robot.api import logger
66

@@ -152,3 +152,7 @@ def keyword_with_deco_and_signature(self, arg1: bool = False, arg2: bool = False
152152
@keyword
153153
def keyword_optional_with_none(self, arg: Optional[str] = None):
154154
return f"arg: {arg}, type: {type(arg)}"
155+
156+
@keyword
157+
def keyword_union_with_none(self, arg: Union[None, Dict, str] = None):
158+
return f"arg: {arg}, type: {type(arg)}"

atest/tests_types.robot

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
Library DynamicTypesLibrary.py
33
Library DynamicTypesAnnotationsLibrary.py xxx
44

5+
*** Variables ***
6+
${CUSTOM NONE} = ${None}
7+
58
*** Test Cases ***
69
Keyword Default Argument As Abject None
710
${return} = DynamicTypesLibrary.Keyword None ${None}
@@ -74,3 +77,17 @@ Type Conversion With Optional And None
7477
${types} = Keyword Optional With None ${None}
7578
Should Contain ${types} arg: None,
7679
Should Contain ${types} <class 'NoneType'>
80+
${types} = Keyword Optional With None arg=${CUSTOM NONE}
81+
Should Contain ${types} arg: None,
82+
Should Contain ${types} <class 'NoneType'>
83+
84+
Type Conversion With Union And Multiple Types
85+
${types} = Keyword Union With None
86+
Should Contain ${types} arg: None,
87+
Should Contain ${types} <class 'NoneType'>
88+
${types} = Keyword Union With None None
89+
Should Contain ${types} arg: None,
90+
Should Contain ${types} <class 'str'>
91+
${types} = Keyword Union With None {"key": 1}
92+
Should Contain ${types} arg: {"key": 1},
93+
Should Contain ${types} <class 'str'>

utest/test_get_keyword_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,8 @@ def test_keyword_with_decorator_arguments(lib_types):
186186
def test_keyword_optional_with_none(lib_types):
187187
types = lib_types.get_keyword_types('keyword_optional_with_none')
188188
assert types == {'arg': typing.Union[str, type(None)]}
189+
190+
191+
def test_keyword_union_with_none(lib_types):
192+
types = lib_types.get_keyword_types('keyword_union_with_none')
193+
assert types == {'arg': typing.Union[type(None), typing.Dict, str]}

0 commit comments

Comments
 (0)