1
0
mirror of https://github.com/httpie/cli.git synced 2026-06-20 11:32:56 +02:00

Ignore crashes that happen on the 3rd party plugins (#1228)

* Ignore crashes that happen on the 3rd party plugins

* Give a suggestion about how to uninstall
This commit is contained in:
Batuhan Taskaya
2021-12-08 18:45:07 +03:00
committed by GitHub
parent ea8e22677a
commit 62e43abc86
5 changed files with 46 additions and 3 deletions
+1
View File
@@ -6,6 +6,7 @@ from pytest_httpbin import certs
from .utils import HTTPBIN_WITH_CHUNKED_SUPPORT_DOMAIN, HTTPBIN_WITH_CHUNKED_SUPPORT
from .utils.plugins_cli import ( # noqa
broken_plugin,
dummy_plugin,
dummy_plugins,
httpie_plugins,
+22
View File
@@ -93,6 +93,28 @@ def test_plugins_double_uninstall(httpie_plugins, httpie_plugins_success, dummy_
)
def test_broken_plugins(httpie_plugins, httpie_plugins_success, dummy_plugin, broken_plugin):
httpie_plugins_success("install", dummy_plugin.path, broken_plugin.path)
with pytest.warns(
UserWarning,
match=(
f'While loading "{broken_plugin.name}", an error'
' ocurred: broken plugin'
)
):
data = parse_listing(httpie_plugins_success('list'))
assert len(data) == 2
# We load before the uninstallation, so it will warn again.
with pytest.warns(UserWarning):
httpie_plugins_success("uninstall", broken_plugin.name)
# No warning now, since it is uninstalled.
data = parse_listing(httpie_plugins_success('list'))
assert len(data) == 1
def test_plugins_cli_error_message_without_args():
# No arguments
result = httpie(no_debug=True)
+8
View File
@@ -178,6 +178,14 @@ def dummy_plugin(interface):
return interface.make_dummy_plugin()
@pytest.fixture(scope='function')
def broken_plugin(interface):
base_plugin = interface.make_dummy_plugin()
with open(base_plugin.path / (base_plugin.import_name + '.py'), 'a') as stream:
stream.write('raise ValueError("broken plugin")\n')
return base_plugin
@pytest.fixture(scope='function')
def dummy_plugins(interface):
# Multiple plugins with different configurations