Closed as duplicate
Description
Scenario's Context object was designed with the old 'metadata/actions/config.yaml`s in mind.
Nowadays we have a single charmcraft.yaml, which makes the signature obsolete and confusing.
I recently helped someone debug this code:
def test_foo():
ctx = Context(MyCharm, config={"foo": "bar"})
ctx.run(..., State())
which failed with a strange AttributeError caused by the charm attempting to observe(self.on.foo_relation_changed)
.
The reason is that Context will only attempt to autoload meta/actions/config from the yaml files IF the user doesn't specify any of the meta, config, actions
Context params.
The fix was:
def test_foo():
ctx = Context(MyCharm)
ctx.run(..., State(config={"foo": "bar"}))
But it was not obvious.
It's not clear that the 'config' param in Context doesn't mean "juju config" but "the config section in charmcraft.yaml".
Can we improve this without breaking backwards compatibility?
Metadata
Metadata
Assignees
Labels
No labels