You've already forked httpie-cli
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:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user