Skip to content

Commit c3855f7

Browse files
committed
#3482 Improve stringigy annotation tests
1 parent 3a1fc06 commit c3855f7

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/psyclone/tests/utils_test.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,22 +338,35 @@ def apply(self, node, opt3: int = 1, **kwargs):
338338

339339
def test_stringify_annotation():
340340
'''Test the stringify_annotation method does as expected.'''
341-
def func(temp: bool, temp2: Union[bool, int]):
341+
def func(basic: bool,
342+
compound: Union[bool, int],
343+
any_length: tuple[int, ...],
344+
custom_class: Transformation,
345+
forwardref: "Transformation"):
342346
''' Test function for annotations.'''
343347

344348
signature = inspect.signature(func)
345349
for k, v in signature.parameters.items():
346-
# For first parameter temp
347-
if "temp" == k:
350+
if "basic" == k:
348351
anno = stringify_annotation(v.annotation)
349352
assert "bool" == anno
350353

351-
# For second parameter temp2
352-
if "temp2" == k:
354+
if "compound" == k:
353355
anno = stringify_annotation(v.annotation)
354356
# Python >= 3.14 uses the second format
355357
assert "typing.Union[bool, int]" == anno or "bool | int" == anno
356358

359+
if "any_length" == k:
360+
anno = stringify_annotation(v.annotation)
361+
assert "tuple[int, ...]" == anno
362+
363+
if "custom_class" == k:
364+
anno = stringify_annotation(v.annotation)
365+
assert "Transformation" == anno
366+
367+
if "forwardref" == k:
368+
anno = stringify_annotation(v.annotation)
369+
assert "Transformation" == anno
357370

358371
def test_transformation_doc_wrapper_subtrans():
359372
'''Test the transformation doc wrapper works correctly for

0 commit comments

Comments
 (0)