summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBatuhan Taskaya <isidentical@gmail.com>2021-12-08 18:45:07 +0300
committerGitHub <noreply@github.com>2021-12-08 07:45:07 -0800
commit62e43abc866ca164deed8bbf449b483fbdf66f52 (patch)
tree49d3b112e4d1822eb7fac8e6d072423d90c0557d /tests
parentea8e22677a321c230157e0e901210401c2040dc9 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py1
-rw-r--r--tests/test_plugins_cli.py22
-rw-r--r--tests/utils/plugins_cli.py8
3 files changed, 31 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index fa0b367a..5e8c5110 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -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,
diff --git a/tests/test_plugins_cli.py b/tests/test_plugins_cli.py
index 39ee9c08..d644aba7 100644
--- a/tests/test_plugins_cli.py
+++ b/tests/test_plugins_cli.py
@@ -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)
diff --git a/tests/utils/plugins_cli.py b/tests/utils/plugins_cli.py
index 4e4d8a07..a750e664 100644
--- a/tests/utils/plugins_cli.py
+++ b/tests/utils/plugins_cli.py
@@ -179,6 +179,14 @@ def dummy_plugin(interface):
@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
return [