|
6 | 6 |
|
7 | 7 |
|
8 | 8 | import os |
| 9 | +import traceback |
9 | 10 |
|
| 11 | +from click.testing import Result |
10 | 12 | from pytest_simcore.helpers.typing_env import EnvVarsDict |
11 | 13 | from simcore_service_dask_sidecar._meta import API_VERSION |
12 | 14 | from simcore_service_dask_sidecar.cli import main |
13 | 15 | from simcore_service_dask_sidecar.settings import Settings |
14 | 16 | from typer.testing import CliRunner |
15 | 17 |
|
16 | 18 |
|
| 19 | +def _format_cli_error(result: Result) -> str: |
| 20 | + assert result.exception |
| 21 | + tb_message = "\n".join(traceback.format_tb(result.exception.__traceback__)) |
| 22 | + return tb_message |
| 23 | + |
| 24 | + |
17 | 25 | def test_cli_help_and_version(cli_runner: CliRunner): |
18 | 26 | # invitations-maker --help |
19 | 27 | result = cli_runner.invoke(main, "--help") |
20 | | - assert result.exit_code == os.EX_OK, result.output |
| 28 | + assert result.exit_code == os.EX_OK, _format_cli_error(result) |
21 | 29 |
|
22 | 30 | result = cli_runner.invoke(main, "--version") |
23 | | - assert result.exit_code == os.EX_OK, result.output |
| 31 | + assert result.exit_code == os.EX_OK, _format_cli_error(result) |
24 | 32 | assert result.stdout.strip() == API_VERSION |
25 | 33 |
|
26 | 34 |
|
27 | 35 | def test_list_settings(cli_runner: CliRunner, app_environment: EnvVarsDict): |
28 | 36 | result = cli_runner.invoke(main, ["settings", "--show-secrets", "--as-json"]) |
29 | | - assert result.exit_code == os.EX_OK, result.output |
| 37 | + assert result.exit_code == os.EX_OK, _format_cli_error(result) |
30 | 38 |
|
31 | 39 | print(result.output) |
32 | 40 | settings = Settings.parse_raw(result.output) |
|
0 commit comments