How do I unit-test an op that uses some property of the OpExecutionContext but can't be set using build_op_context? #14806
Unanswered
OwenKephart
asked this question in
Q&A
Replies: 1 comment 1 reply
-
At the moment, the most viable solution would (unfortunately) be to mock out the property on the internal class: import mock
from dagster import build_op_context, op
@op
def my_op(context):
assert context.job_name == "my_job"
with mock.patch(
"dagster._core.execution.context.invocation.BoundOpExecutionContext.job_name",
new_callable=mock.PropertyMock,
) as job_name_mock:
job_name_mock.return_value = "my_job"
context = build_op_context()
my_op(context) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When using
build_op_context
, I'm not able to set a value for some properties on the OpExecutionContext, such asjob_name
. If my op depends on this property, how do I unit test it?Beta Was this translation helpful? Give feedback.
All reactions