Duplicate await in integration test templates
Metadata
Current evaluation
Fixed charmcraft init integration templates in commit 3ea45cd3 by removing the duplicate await before deployment, preventing a PosixPath TypeError.
Resolution: closed resolved
Reason: Commit 3ea45cd3 ("templates: remove duplicate await") changed the template to pass the already-built charm path directly to model.deploy, resolving the reported TypeError.
Evaluated by: mr-cal-bot
No scores available.
Issue body
The integration tests generated by `charmcraft init` aren't quite right out of the box:
```
<cjwatson@niejwein ~>$ mkdir test-charm
<cjwatson@niejwein ~>$ cd test-charm
<cjwatson@niejwein ~/test-charm>$ charmcraft init --profile machine
Charmed operator package file and directory tree initialised.
Now edit the following package files to provide fundamental charm metadata and other information:
metadata.yaml
config.yaml
src/charm.py
README.md
<cjwatson@niejwein ~/test-charm>$ tox -e integration
integration create: /home/cjwatson/test-charm/.tox/integration
integration installdeps: pytest, juju, pytest-operator, -r/home/cjwatson/test-charm/requirements.txt
integration installed: asttokens==2.0.8,attrs==22.1.0,backcall==0.2.0,bcrypt==4.0.1,cachetools==5.2.0,certifi==2022.9.24,cffi==1.15.1,charset-normalizer==2.1.1,cryptography==38.0.1,decorator==5.1.1,executing==1.1.1,google-auth==2.13.0,idna==3.4,iniconfig==1.1.1,ipdb==0.13.9,ipython==8.5.0,jedi==0.18.1,Jinja2==3.1.2,juju==3.0.2,jujubundlelib==0.5.7,kubernetes==24.2.0,macaroonbakery==1.3.1,MarkupSafe==2.1.1,matplotlib-inline==0.1.6,mypy-extensions==0.4.3,oauthlib==3.2.2,ops==1.5.3,packaging==21.3,paramiko==2.11.0,parso==0.8.3,pexpect==4.8.0,pickleshare==0.7.5,pluggy==1.0.0,prompt-toolkit==3.0.31,protobuf==3.20.3,ptyprocess==0.7.0,pure-eval==0.2.2,py==1.11.0,pyasn1==0.4.8,pyasn1-modules==0.2.8,pycparser==2.21,Pygments==2.13.0,pymacaroons==0.13.0,PyNaCl==1.5.0,pyparsing==3.0.9,pyRFC3339==1.1,pytest==7.1.3,pytest-asyncio==0.19.0,pytest-operator==0.22.0,python-dateutil==2.8.2,pytz==2022.5,PyYAML==6.0,requests==2.28.1,requests-oauthlib==1.3.1,rsa==4.9,six==1.16.0,stack-data==0.5.1,theblues==0.5.2,toml==0.10.2,tomli==2.0.1,toposort==1.7,traitlets==5.5.0,typing-inspect==0.8.0,typing_extensions==4.4.0,urllib3==1.26.12,wcwidth==0.2.5,websocket-client==1.4.1,websockets==10.3
integration run-test-pre: PYTHONHASHSEED='789593337'
integration run-test: commands[0] | pytest -v --tb native --ignore=/home/cjwatson/test-charm/tests/unit --log-cli-level=INFO -s
======================================================================================== test session starts =========================================================================================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0 -- /home/cjwatson/test-charm/.tox/integration/bin/python
cachedir: .tox/integration/.pytest_cache
rootdir: /home/cjwatson/test-charm, configfile: pyproject.toml
plugins: operator-0.22.0, asyncio-0.19.0
asyncio: mode=strict
collected 1 item
tests/integration/test_charm.py::test_build_and_deploy
------------------------------------------------------------------------------------------- live log setup -------------------------------------------------------------------------------------------
INFO pytest_operator.plugin:plugin.py:625 Adding model lxd:test-charm-d9xw on cloud localhost
------------------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------------------
INFO pytest_operator.plugin:plugin.py:504 Using tmp_path: /home/cjwatson/test-charm/.tox/integration/tmp/pytest/test-charm-d9xw0
INFO pytest_operator.plugin:plugin.py:948 Building charm test-charm
INFO pytest_operator.plugin:plugin.py:953 Built charm test-charm in 280.45s
FAILED
----------------------------------------------------------------------------------------- live log teardown ------------------------------------------------------------------------------------------
INFO pytest_operator.plugin:plugin.py:768 Model status:
Model Controller Cloud/Region Version SLA Timestamp
test-charm-d9xw lxd localhost/localhost 2.9.35 unsupported 13:32:53+01:00
INFO pytest_operator.plugin:plugin.py:774 Juju error logs:
INFO pytest_operator.plugin:plugin.py:793 juju-crashdump command was not found.
INFO pytest_operator.plugin:plugin.py:861 Resetting model test-charm-d9xw...
INFO pytest_operator.plugin:plugin.py:866 Not waiting on reset to complete.
INFO pytest_operator.plugin:plugin.py:839 Forgetting main...
============================================================================================== FAILURES ==============================================================================================
_______________________________________________________________________________________ test_build_and_deploy ________________________________________________________________________________________
Traceback (most recent call last):
File "/home/cjwatson/test-charm/tests/integration/test_charm.py", line 30, in test_build_and_deploy
ops_test.model.deploy(await charm, application_name=APP_NAME),
TypeError: object PosixPath can't be used in 'await' expression
----------------------------------------------------------------------------------------- Captured log setup -----------------------------------------------------------------------------------------
INFO pytest_operator.plugin:plugin.py:625 Adding model lxd:test-charm-d9xw on cloud localhost
----------------------------------------------------------------------------------------- Captured log call ------------------------------------------------------------------------------------------
INFO pytest_operator.plugin:plugin.py:504 Using tmp_path: /home/cjwatson/test-charm/.tox/integration/tmp/pytest/test-charm-d9xw0
INFO pytest_operator.plugin:plugin.py:948 Building charm test-charm
INFO pytest_operator.plugin:plugin.py:953 Built charm test-charm in 280.45s
--------------------------------------------------------------------------------------- Captured log teardown ----------------------------------------------------------------------------------------
INFO pytest_operator.plugin:plugin.py:768 Model status:
Model Controller Cloud/Region Version SLA Timestamp
test-charm-d9xw lxd localhost/localhost 2.9.35 unsupported 13:32:53+01:00
INFO pytest_operator.plugin:plugin.py:774 Juju error logs:
INFO pytest_operator.plugin:plugin.py:793 juju-crashdump command was not found.
INFO pytest_operator.plugin:plugin.py:861 Resetting model test-charm-d9xw...
INFO pytest_operator.plugin:plugin.py:866 Not waiting on reset to complete.
INFO pytest_operator.plugin:plugin.py:839 Forgetting main...
====================================================================================== short test summary info =======================================================================================
FAILED tests/integration/test_charm.py::test_build_and_deploy - TypeError: object PosixPath can't be used in 'await' expression
=================================================================================== 1 failed in 299.71s (0:04:59) ====================================================================================
ERROR: InvocationError for command /home/cjwatson/test-charm/.tox/integration/bin/pytest -v --tb native --ignore=/home/cjwatson/test-charm/tests/unit --log-cli-level=INFO -s (exited with code 1)
______________________________________________________________________________________________ summary _______________________________________________________________________________________________
ERROR: integration: commands failed
```
This is because they do `charm = await ops_test.build_charm(".")`, and then `await charm` again just below.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed charmcraft init integration templates in commit 3ea45cd3 by removing the duplicate await before deployment, preventing a PosixPath TypeError. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed charmcraft init integration templates by removing the duplicate await in commit 3ea45cd3, preventing deployment of the already-built charm path from raising a TypeError. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed charmcraft init integration templates in commit 3ea45cd3 by removing a duplicate await that caused a PosixPath TypeError during deployment. | |
| stealth/space-bunny-alpha | — | closed resolved | Removed the duplicate await from `charmcraft init` integration test templates in commit 3ea45cd3, preventing the generated deploy test from raising a TypeError. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed charmcraft init integration templates by removing the duplicate await in commit 3ea45cd3, preventing TypeError failures when deploying the built charm. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged PR #911 (commit 3ea45cd3) removed the duplicate await from charmcraft init integration-test templates, fixing the reported PosixPath await TypeError. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved by removing the duplicate await from the generated integration test template, fixing the TypeError during charm deployment. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed by removing the redundant await call in charmcraft init integration test templates, resolving the TypeError during deployment. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed duplicate await in charmcraft init integration test templates. The redundant await caused a TypeError during test execution. Resolved by removing the extra await expression from the generated test code. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1540 fix: template integration tests | charmcraft | merged | Merged PR #1540 as commit f3f82031, updating integration-test templates to use charmcraft.yaml instead of metadata.yaml and completing the stalled change from #1468. | |
| #911 templates: remove duplicate "await" | charmcraft | merged | Merged PR #911 removed duplicate awaits from three integration-test templates in commit 3ea45cd3, fixing #910. | |
| #2695 feat(templates): add juju_setup to integration tests, improve comments, fix resolve() | charmcraft | merged | Merged in charmcraft PR #2695 (commit 74d12bce), adding juju_setup to generated integration tests, clarifying comments, and removing redundant resolve(). |