Skip to content

Commit

Permalink
chore: Do not show Click's "Aborted!" message when an error occurs du…
Browse files Browse the repository at this point in the history
…ring schema loading in CLI
  • Loading branch information
Stranger6667 committed Apr 24, 2020
1 parent 4c7c7c4 commit 4e5f463
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Expand Up @@ -25,6 +25,7 @@ Changed

- Added indentation & section name to the ``SUMMARY`` CLI block.
- Use C-extension for YAML loading when it is possible. It can cause more than 10x speedup on schema parsing.
- Do not show Click's "Aborted!" message when an error occurs during schema loading in CLI.

`1.2.0`_ - 2020-04-15
---------------------
Expand Down
6 changes: 5 additions & 1 deletion src/schemathesis/cli/__init__.py
@@ -1,3 +1,4 @@
import sys
import traceback
from enum import Enum
from typing import Callable, Dict, Generator, Iterable, List, Optional, Tuple, Union
Expand Down Expand Up @@ -272,7 +273,10 @@ def execute(
handler.handle_event(context, event)
except click.exceptions.Exit:
raise
except Exception:
except Exception as exc:
for handler in handlers:
handler.shutdown()
if isinstance(exc, click.Abort):
# To avoid showing "Aborted!" message, which is the default behavior in Click
sys.exit(1)
raise
2 changes: 0 additions & 2 deletions test/cli/test_commands.py
Expand Up @@ -695,7 +695,6 @@ def test_schema_not_available(cli, workers):
"Error: requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=1): "
"Max retries exceeded with url: /swagger.yaml"
)
assert lines[-2] == "Aborted!"


def test_schema_not_available_wsgi(cli, loadable_flask_app):
Expand All @@ -706,7 +705,6 @@ def test_schema_not_available_wsgi(cli, loadable_flask_app):
# And error message is displayed
lines = result.stdout.split("\n")
assert lines[0] == "Schema was not found at unknown.yaml"
assert lines[1] == "Aborted!"


@pytest.mark.endpoints("custom_format")
Expand Down

0 comments on commit 4e5f463

Please sign in to comment.