Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cca331c

Browse files
committed
Test for deferred evaluation of annotations in library.
See PEP 649 for details. Part of Python 3.14 support (#5352).
1 parent 98af479 commit cca331c

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

atest/interpreter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def excludes(self):
5757
if self.is_pypy:
5858
yield 'no-pypy'
5959
yield 'require-lxml'
60-
for require in [(3, 8), (3, 9), (3, 10)]:
60+
for require in [(3, 9), (3, 10), (3, 14)]:
6161
if self.version_info < require:
6262
yield 'require-py%d.%d' % require
6363
if self.is_windows:

atest/robot/cli/dryrun/type_conversion.robot

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ Resource atest_resource.robot
33

44
*** Test Cases ***
55
Annotations
6-
Run Tests --dryrun keywords/type_conversion/annotations.robot
6+
# Exclude test requiring Python 3.14 unconditionally to avoid a failure with
7+
# older versions. It can be included once Python 3.14 is our minimum versoin.
8+
Run Tests --dryrun --exclude require-py3.14 keywords/type_conversion/annotations.robot
79
Should be equal ${SUITE.status} PASS
810

911
Keyword Decorator

atest/robot/keywords/type_conversion/annotations.robot

+5
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,8 @@ Default value is used if explicit type conversion fails
239239

240240
Explicit conversion failure is used if both conversions fail
241241
Check Test Case ${TESTNAME}
242+
243+
Deferred evaluation of annotations
244+
[Documentation] https://peps.python.org/pep-0649
245+
[Tags] require-py3.14
246+
Check Test Case ${TESTNAME}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from robot.api.deco import library
2+
3+
4+
class Library:
5+
6+
def deferred_evaluation_of_annotations(self, arg: Argument) -> str:
7+
return arg.value
8+
9+
10+
class Argument:
11+
12+
def __init__(self, value: str):
13+
self.value = value
14+
15+
@classmethod
16+
def from_string(cls, value: str) -> Argument:
17+
return cls(value)
18+
19+
20+
Library = library(converters={Argument: Argument.from_string},
21+
auto_keywords=True)(Library)

atest/testdata/keywords/type_conversion/annotations.robot

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*** Settings ***
22
Library Annotations.py
3+
Library DeferredAnnotations.py
34
Library OperatingSystem
45
Resource conversion.resource
56

@@ -634,3 +635,8 @@ Explicit conversion failure is used if both conversions fail
634635
[Template] Conversion Should Fail
635636
Type and default 4 BANG! type=list error=Invalid expression.
636637
Type and default 3 BANG! type=timedelta error=Invalid time string 'BANG!'.
638+
639+
Deferred evaluation of annotations
640+
[Tags] require-py3.14
641+
${value} = Deferred evaluation of annotations PEP 649
642+
Should be equal ${value} PEP 649

0 commit comments

Comments
 (0)