aboutsummaryrefslogtreecommitdiff
blob: 73295075e5791bc1e8dd5c9d24698064ff97aa6b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pytest
from mastodon.Mastodon import MastodonAPIError

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()
Powered by cgit v1.2.3 (git 2.41.0)