'How to test click.context.obj mutation in python
I have a command group with sub-commands. The command group takes the current context through @click.pass_context and mutates the ctx.obj (which is carried onto the sub-commands). How can I assert the new value of ctx.obj?
I have tried the following
# define a dummy context
ctx = click.Context(command_group_name, obj=dummy_ctx_obj)
with ctx:
self.runner.invoke(command_group_name, ['sub-command', '--arg', 'value', ], parent=ctx)
# the bellow assert is failing
assert isinstance(ctx.obj, expected_type)
What am I missing? Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
