You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "/usr/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.10/unittest/case.py", line 591, in run
self._callTestMethod(testMethod)
File "/usr/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
method()
File "/usr/lib/python3.10/unittest/mock.py", line 1379, in patched
return func(*newargs, **newkeywargs)
File "/home/ubuntu/code/o11y/alertmanager-k8s-operator/tests/unit/test_charm.py", line 226, in test_show_config
results = self.harness.run_action("show-config").results
File "/home/ubuntu/code/o11y/alertmanager-k8s-operator/.tox/unit/lib/python3.10/site-packages/ops/testing.py", line 1913, in run_action
raise ActionFailed(
ops.testing.ActionFailed
Traceback (most recent call last):
File "/home/ubuntu/code/o11y/alertmanager-k8s-operator/tests/unit/test_charm.py", line 227, in test_show_config
results = self.harness.run_action("show-config").results
File "/home/ubuntu/code/o11y/alertmanager-k8s-operator/.tox/unit/lib/python3.10/site-packages/ops/testing.py", line 1913, in run_action
raise ActionFailed(
ops.testing.ActionFailed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.10/unittest/case.py", line 591, in run
self._callTestMethod(testMethod)
File "/usr/lib/python3.10/unittest/case.py", line 549, in _callTestMethod
method()
File "/usr/lib/python3.10/unittest/mock.py", line 1379, in patched
return func(*newargs, **newkeywargs)
File "/home/ubuntu/code/o11y/alertmanager-k8s-operator/tests/unit/test_charm.py", line 229, in test_show_config
self.fail(f"{e.message}; {e.output}")
File "/usr/lib/python3.10/unittest/case.py", line 675, in fail
raise self.failureException(msg)
AssertionError: not-found - stat /etc/alertmanager/templates.tmpl: no such file or directory; ActionOutput(logs=['Fetching /etc/alertmanager/alertmanager.yml'], results={})
but ideally we should be able to avoid the boilerplate.
The text was updated successfully, but these errors were encountered:
…output (#1209)
Add a `__str__` to `ops.testing.ActionFailed` so that an uncaught
`event.fail()` in tests produces a more informative traceback.
Currently, `event.fail()` and `event.fail(message)` will look somewhat
like:
```python
Traceback (most recent call last):
File "/tmp/1204.py", line 18, in <module>
harness.run_action("act")
File "/home/tameyer/code/operator/ops/testing.py", line 2001, in run_action
raise ActionFailed(
ops.testing.ActionFailed
```
After this PR, `event.fail()` will look like:
```python
Traceback (most recent call last):
File "/tmp/1204.py", line 19, in <module>
harness.run_action("act")
File "/home/tameyer/code/operator/ops/testing.py", line 2006, in run_action
raise ActionFailed(
ops.testing.ActionFailed: Event handler called `fail()` with no additional details.
```
and `event.fail("Message")` will look like:
```python
Traceback (most recent call last):
File "/tmp/1204.py", line 18, in <module>
harness.run_action("act")
File "/home/tameyer/code/operator/ops/testing.py", line 2006, in run_action
raise ActionFailed(
ops.testing.ActionFailed: Message
```
Fixes#1204
---------
Co-authored-by: Tiexin Guo <tiexin.guo@canonical.com>
When an action fails in a unit test (#1053), the reason isn't displayed in the traceback:
Wrapping in a try-except helps,
but ideally we should be able to avoid the boilerplate.
The text was updated successfully, but these errors were encountered: