Skip to content

Commit

Permalink
test: pull out bad render test into its own function and add another …
Browse files Browse the repository at this point in the history
…case
  • Loading branch information
edufnt committed Oct 11, 2024
1 parent 4c4e0ee commit c5b29f9
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ def fn(arg5: int, arg6: AtRender[int]) -> float:
return arg5 + arg6 + arg7 + arg8 + int(ARG1) + int(ARG2)


@workflow()
def to_int_bad(num: int, should_double: bool) -> int | float:
"""A mock workflow that casts to an int with a wrong type for handling doubles."""
return increment(num=num) if should_double else sum(left=num, right=num)
# @workflow()
# def to_int_bad(num: int, should_double: bool) -> int | float:
# """A mock workflow that casts to an int with a wrong type for handling doubles."""
# return increment(num=num) if should_double else sum(left=num, right=num)


# @workflow()
# def to_int_bad_2(num: int, should_double: Any) -> int | float:
# """A mock workflow that casts to an int with a wrong type for handling doubles."""
# return increment(num=num) if should_double else sum(left=num, right=num)


@workflow()
Expand Down Expand Up @@ -76,12 +82,18 @@ def test_can_analyze_annotations() -> None:
assert analyser.argument_has("ARG1", AtRender) is False


def test_at_render() -> None:
"""Test the rendering of workflows with `dewret.annotations.AtRender` and exceptions handling."""
with pytest.raises(TaskException) as _:
result = to_int_bad(num=increment(num=3), should_double=True)
wkflw = construct(result, simplify_ids=True)
# def test_at_render_bad() -> None:
# """Test the rendering of workflows with exceptions handling."""
# with pytest.raises(TaskException) as _:
# result = to_int_bad(num=increment(num=3), should_double=True)
# wkflw = construct(result, simplify_ids=True)
# with pytest.raises(TaskException) as _:
# result = to_int_bad_2(num=increment(num=3), should_double=True)
# wkflw = construct(result, simplify_ids=True)


def test_at_render() -> None:
"""Test the rendering of workflows with `dewret.annotations.AtRender`."""
result = to_int(num=increment(num=3), should_double=True)
wkflw = construct(result, simplify_ids=True)
subworkflows = render(wkflw, allow_complex_types=True)
Expand Down

0 comments on commit c5b29f9

Please sign in to comment.