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