Initial tests from `charmcraft init` do not pass
Metadata
Current evaluation
Superseded by charmcraft#247, which took ownership of redesigning charmcraft init and its generated tests; no direct fixing implementation was recorded for #243.
Resolution: closed superseded
Reason: The maintainer stated that issue #247 would address the future of init tests and fix this failure. No resolving PR or commit is cited directly for #243.
Evaluated by: mr-cal-bot
No scores available.
Issue body
If you create a new charm with `charmcraft init`, the tests will not pass out of the box.
This appears to be because the `config.yaml` file exists, but does not contain any valid yaml (just comments).
```
tomwardill@microk8s-juju:~/work/harbor-charms/harbor-core$ ./run_tests
test_action (tests.test_charm.TestCharm) ... ERROR
test_action_fail (tests.test_charm.TestCharm) ... ERROR
test_config_changed (tests.test_charm.TestCharm) ... ERROR
======================================================================
ERROR: test_action (tests.test_charm.TestCharm)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tomwardill/work/harbor-charms/harbor-core/tests/test_charm.py", line 21, in test_action
harness = Harness(HarborCoreCharm)
File "/home/tomwardill/work/harbor-charms/harbor-core/venv/lib/python3.8/site-packages/ops/testing.py", line 92, in __init__
self._update_config(key_values=self._load_config_defaults(config))
File "/home/tomwardill/work/harbor-charms/harbor-core/venv/lib/python3.8/site-packages/ops/testing.py", line 277, in _load_config_defaults
charm_config = charm_config.get('options', {})
AttributeError: 'NoneType' object has no attribute 'get'
======================================================================
ERROR: test_action_fail (tests.test_charm.TestCharm)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tomwardill/work/harbor-charms/harbor-core/tests/test_charm.py", line 30, in test_action_fail
harness = Harness(HarborCoreCharm)
File "/home/tomwardill/work/harbor-charms/harbor-core/venv/lib/python3.8/site-packages/ops/testing.py", line 92, in __init__
self._update_config(key_values=self._load_config_defaults(config))
File "/home/tomwardill/work/harbor-charms/harbor-core/venv/lib/python3.8/site-packages/ops/testing.py", line 277, in _load_config_defaults
charm_config = charm_config.get('options', {})
AttributeError: 'NoneType' object has no attribute 'get'
======================================================================
ERROR: test_config_changed (tests.test_charm.TestCharm)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/tomwardill/work/harbor-charms/harbor-core/tests/test_charm.py", line 13, in test_config_changed
harness = Harness(HarborCoreCharm)
File "/home/tomwardill/work/harbor-charms/harbor-core/venv/lib/python3.8/site-packages/ops/testing.py", line 92, in __init__
self._update_config(key_values=self._load_config_defaults(config))
File "/home/tomwardill/work/harbor-charms/harbor-core/venv/lib/python3.8/site-packages/ops/testing.py", line 277, in _load_config_defaults
charm_config = charm_config.get('options', {})
AttributeError: 'NoneType' object has no attribute 'get'
----------------------------------------------------------------------
Ran 3 tests in 0.017s
FAILED (errors=3)
```
Either removing `config.yaml` so it drops into the default in `_load_config_defaults`, or making it's contents represent an empty dictionary is enough to fix it.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed superseded | Superseded by charmcraft#247, which took ownership of redesigning charmcraft init and its generated tests; no direct fixing implementation was recorded for #243. | |
| stealth/space-bunny-alpha | — | closed superseded | Closed as superseded by #247, which proposed redesigning charmcraft init and its tests; the tracking issue was closed without implementation. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Superseded by PR #247, which updates the init workflow to resolve failing tests caused by invalid config.yaml generation. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed as superseded by PR #247, which updates charmcraft init test generation to resolve the config.yaml parsing error and ensure tests pass out of the box. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by PR #247, which resolves the failing tests caused by invalid config.yaml generation in charmcraft init. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved by PR #247, which overhauls init test generation to prevent invalid config.yaml from breaking tests. |
Update history
No update history recorded yet.
Related work
-
Superseded By:
charmcraft#247
(confidence 99%)
The maintainer explicitly identified #247 as the work that would replace and fix the generated init tests.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #238 `charmcraft init` creates broken charm | charmcraft | closed | Superseded by charmcraft#247, a planned overhaul of init templates and generated tests; #247 later closed without implementing its proposed guard against building incomplete templates. | |
| #91 First pass at 'charmcraft init' | charmcraft | merged | Merged PR #91 delivered the first non-interactive charmcraft init scaffolding implementation; README improvements, extra options, and prompts were deferred (commit 0ebd9f87). | |
| #1092 Some tests will require the charm plugin to be enabled | craft-application | open | Open, unlabelled issue: charmcraft PR #2722 may make craft-application tests depend on the charm plugin; the maintainer asks to remove that dependency, but no affected test or fix is identified. | |
| #2364 Update charmcraft test to use the new testing infrastructure | charmcraft | closed | Fixed by merged PR charmcraft#2385 (commit b7730efc), replacing Charmcraft’s custom test command with craft-application’s upstream test infrastructure. | |
| #197 `charmcraft init` should not populate actions.yaml with real data | charmcraft | closed | charmcraft#197 was closed as abandoned after years of inactivity, with no recorded resolving PR or commit. |