Hey all, I'm trying to write unit tests for an op...
# ask-community
p
Hey all, I'm trying to write unit tests for an op that requires a
context
. What's the best way to mock the context if the op accesses special context fields like
context.op.name
and
context.job_name
?
build_op_context()
does not set these fields. Before the new python config and configurable resources, I used to pass
MagicMock()
for the context as a workaround but now I get this error when I try to use MagicMock:
Copy code
dagster._core.errors.DagsterInvalidInvocationError: Cannot provide resources in both context and kwargs
Any help would be appreciated, thanks!
s
Hi Pranav - would you mind filing a Github issue with the code that you'd expect to work but does not?
p
Hi @sandy, I opened an issue here: https://github.com/dagster-io/dagster/issues/16195 Thanks!