ferruzzi commented on code in PR #55659:
URL: https://github.com/apache/airflow/pull/55659#discussion_r2349958888
##########
task-sdk/tests/task_sdk/definitions/test_asset_decorators.py:
##########
@@ -115,7 +115,7 @@ def root_func():
def asset_func():
pass
- with pytest.raises(ValueError) as err:
+ with pytest.raises(ValueError, match="nested function not supported")
as err:
root_func()
assert err.value.args[0] == "nested function not supported"
Review Comment:
May be wrong, but I think err.value.args[0] is the error message. If that
is the case this (and elsewhere) can be cleaned up as well.
##########
task-sdk/tests/task_sdk/definitions/test_asset.py:
##########
@@ -386,10 +386,8 @@ def normalizer(uri):
_mock_get_uri_normalizer_raising_error,
)
def test_sanitize_uri_raises_exception():
- with pytest.raises(ValueError) as e_info:
+ with pytest.raises(ValueError, match="Incorrect URI format"):
_sanitize_uri("postgres://localhost:5432/database.schema.table")
- assert isinstance(e_info.value, ValueError)
- assert str(e_info.value) == "Incorrect URI format"
Review Comment:
I like that this one lets us consolidate multiple tests into one line.
##########
dev/stats/explore_pr_candidates.ipynb:
##########
Review Comment:
I agree with Ash, the two ipynb files don't seem to be relevant
##########
task-sdk/tests/task_sdk/definitions/decorators/test_task_group.py:
##########
@@ -174,14 +175,10 @@ def tg(a, b):
tg.partial(a=1).expand(b=t()["values"])
- with pytest.raises(ValueError) as ctx:
+ expected_msg = "cannot map over XCom with custom key 'values' from
<Task(_PythonDecoratedOperator): t>"
+ with pytest.raises(ValueError, match=re.escape(expected_msg)):
Review Comment:
Nitpick (here and below), feel free to close or ignore this, but I'm pretty
sure you can define the match string as a raw-string like this and save the
import, but I haven't tested this.
```suggestion
expected_msg = r"cannot map over XCom with custom key 'values' from
<Task(_PythonDecoratedOperator): t>"
with pytest.raises(ValueError, match=expected_msg):
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]