Skip to content

Commit 0088e4d

Browse files
committed
Python 3.10 type hint test
1 parent 3799829 commit 0088e4d

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
python-version: [3.7, 3.9, 3.10.0-rc.1]
11+
python-version: [3.7, 3.9, 3.10.0-rc.2]
1212
rf-version: [4.0.2, 4.1.1]
1313

1414
steps:

atest/DynamicTypesLibrary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def keyword_none(self, arg=None):
5858
return '{}: {}'.format(arg, type(arg))
5959

6060
@keyword
61-
def is_python_3(self):
62-
return sys.version_info >= (3,)
61+
def is_python_3_10(self):
62+
return sys.version_info >= (3, 10)
6363

6464
@keyword
6565
@def_deco

atest/Python310Library.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from robot.api import logger
2+
3+
from robotlibcore import DynamicCore, keyword
4+
5+
class Python310Library(DynamicCore):
6+
7+
def __init__(self):
8+
DynamicCore.__init__(self, [])
9+
10+
@keyword
11+
def python310_style(self, arg: int | dict):
12+
typing = f"arg: {arg}, type: {type(arg)}"
13+
logger.info(typing)
14+
return typing

atest/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
sys.exit(rc)
2626
process_output(output, verbose=False)
2727
output = join(outdir, 'lib-DynamicTypesLibrary-python-{}-robot-{}.xml'.format(python_version, rf_version))
28-
rc = run(tests_types, name='Types', output=output, report=None, log=None, loglevel='debug')
28+
exclude = "py310" if sys.version_info < (3, 10) else ""
29+
rc = run(tests_types, name='Types', output=output, report=None, log=None, loglevel='debug', exclude=exclude)
2930
if rc > 250:
3031
sys.exit(rc)
3132
process_output(output, verbose=False)

atest/tests_types.robot

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,17 @@ Type Conversion With Union And Multiple Types
9191
${types} = Keyword Union With None {"key": 1}
9292
Should Contain ${types} arg: {"key": 1},
9393
Should Contain ${types} <class 'str'>
94+
95+
Python 3.10 New Type Hints
96+
[Tags] py310
97+
[Setup] Import DynamicTypesAnnotationsLibrary In Python 3.10 Only
98+
${types} = Python310 Style 111
99+
Should Be Equal ${types} arg: 111, type: <class 'int'>
100+
${types} = Python310 Style {"key": 1}
101+
Should Be Equal ${types} arg: {'key': 1}, type: <class 'dict'>
102+
103+
*** Keywords ***
104+
Import DynamicTypesAnnotationsLibrary In Python 3.10 Only
105+
${py3} = DynamicTypesLibrary.Is Python 3 10
106+
Run Keyword If ${py3}
107+
... Import Library Python310Library.py

0 commit comments

Comments
 (0)