Skip to content

Commit ced29a9

Browse files
committed
Explicit test for type conversion with a: str = None.
We already had test for `a: Optional[str] = None` which yields exactly same type info via `typing.get_type_hints`. Better to cover both cases especially when Python functionality in this regard may change. This is related to robotframework#3908.
1 parent a050236 commit ced29a9

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

‎atest/robot/keywords/type_conversion/unions.robot‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ Optional argument
3131
Optional argument with default
3232
Check Test Case ${TESTNAME}
3333

34-
Optional string with default
34+
Optional string with None default
35+
Check Test Case ${TESTNAME}
36+
37+
String with None default
3538
Check Test Case ${TESTNAME}
3639

3740
Avoid unnecessary conversion

‎atest/testdata/keywords/type_conversion/unions.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def optional_argument_with_default(argument: Optional[float] = None, expected=ob
5555
assert argument == expected
5656

5757

58-
def optional_string_with_default(argument: Optional[str] = None, expected=object()):
58+
def optional_string_with_none_default(argument: Optional[str] = None, expected=object()):
59+
assert argument == expected
60+
61+
62+
def string_with_none_default(argument: str = None, expected=object()):
5963
assert argument == expected
6064

6165

‎atest/testdata/keywords/type_conversion/unions.robot‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,17 @@ Optional argument with default
7272
${None} ${None}
7373
expected=${None}
7474

75-
Optional string with default
76-
[Template] Optional string with default
75+
Optional string with None default
76+
[Template] Optional string with None default
77+
Hyvä! Hyvä!
78+
1 1
79+
${1} 1
80+
None None
81+
${None} ${None}
82+
expected=${None}
83+
84+
String with None default
85+
[Template] String with None default
7786
Hyvä! Hyvä!
7887
1 1
7988
${1} 1

0 commit comments

Comments
 (0)