From 3f83ee0a4ca9d843472f69cbb9a962504950470c Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 11 Mar 2019 14:50:23 +0100 Subject: failing test for #160 --- tests/test_errors.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/test_errors.py (limited to 'tests') diff --git a/tests/test_errors.py b/tests/test_errors.py new file mode 100644 index 0000000..77230c6 --- /dev/null +++ b/tests/test_errors.py @@ -0,0 +1,20 @@ +import pytest +from mastodon.Mastodon import MastodonAPIError +import re +try: + from mock import MagicMock +except ImportError: + from unittest.mock import MagicMock + +def test_nonstandard_errors(api): + response = MagicMock() + response.json = MagicMock(return_value= + "I am a non-standard instance and this error is a plain string.") + response.ok = False + session = MagicMock() + session.request = MagicMock(return_value=response) + + api.session = session + with pytest.raises(MastodonAPIError): + api.instance() + -- cgit v1.2.3 From e594bad9bb5c459862e7837b42b471d9e5937b6c Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 15 Apr 2019 14:31:41 +0200 Subject: remove extraneous import --- tests/test_errors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test_errors.py b/tests/test_errors.py index 77230c6..7329507 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,6 +1,6 @@ import pytest from mastodon.Mastodon import MastodonAPIError -import re + try: from mock import MagicMock except ImportError: -- cgit v1.2.3