cuddly-jelly-27016
05/26/2025, 12:10 AM1.11.0 -> 1.12.0, unit tests to verify that tasks raise expected errors are no longer passing. Instead of surfacing the error, the tests fail with a SystemExit.
from flytekit import task
@task
def f(x: int) -> int:
if x > 0:
return x + 2
else:
raise ValueError("x must be positive")
# Passes in 1.11.0, fails in 1.12.0
def test_f_raises():
with pytest.raises(ValueError):
f(-1)
We've been able to bypass this issue by accessing the task_function value directly in the tests, but this is non-intuitive and required a lot of manual updates to our test suite:
# Passes in 1.12.0
def test_f_raises():
with pytest.raises(ValueError):
_f = f.task_function
_f(-1)
Slack thread: https://flyte-org.slack.com/archives/CP2HDHKE1/p1716391591793619
### Expected behavior
I would expect to be able to test that tasks raise errors directly, without needing to access the internal task function:
# Should pass
def test_f_raises():
with pytest.raises(ValueError):
f(-1)
### Additional context to reproduce
No response
### Screenshots
No response
### Are you sure this issue hasn't been raised already?
• Yes
### Have you read the Code of Conduct?
• Yes
flyteorg/flytecuddly-jelly-27016
05/26/2025, 12:10 AM