shahar1 commented on code in PR #27797:
URL: https://github.com/apache/airflow/pull/27797#discussion_r1038201659
##########
tests/operators/test_python.py:
##########
@@ -1155,6 +1169,21 @@ def f():
)
copy.deepcopy(task)
+ def test_except_value_error(self):
+ def f():
+ return 1
+
+ task = PythonVirtualenvOperator(
+ python_callable=f,
+ task_id="task",
+ dag=self.dag,
+ )
+
+ task.log.error = unittest.mock.Mock()
+ task.pickling_library.loads =
unittest.mock.Mock(side_effect=ValueError)
+ with pytest.raises(ValueError):
+ task._read_result(path=unittest.mock.Mock())
Review Comment:
Created a custom exception class to be raised, which includes the error from
`log.error` in its `__str__` method). I might have understood your intentions
wrong, let me know if it needs additional fixing.
##########
tests/operators/test_python.py:
##########
@@ -1155,6 +1169,21 @@ def f():
)
copy.deepcopy(task)
+ def test_except_value_error(self):
+ def f():
+ return 1
+
+ task = PythonVirtualenvOperator(
+ python_callable=f,
+ task_id="task",
+ dag=self.dag,
+ )
+
+ task.log.error = unittest.mock.Mock()
+ task.pickling_library.loads =
unittest.mock.Mock(side_effect=ValueError)
+ with pytest.raises(ValueError):
+ task._read_result(path=unittest.mock.Mock())
Review Comment:
Created a custom exception class to be raised, which includes the error from
`log.error` in its `__str__` method. I might have understood your intentions
wrong, let me know if it needs additional fixing.
--
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]