def test_apiexception_value(self): exc = RedditAPIException("test", "testing", "test") assert exc.error_type == "test" exc2 = RedditAPIException(["test", "testing", "test"]) assert exc2.message == "testing" exc3 = RedditAPIException([["test", "testing", "test"]]) assert exc3.field == "test"
def test_items(self): container = RedditAPIException( [ ["BAD_SOMETHING", "invalid something", "some_field"], RedditErrorItem("BAD_SOMETHING", "invalid something", "some_field"), ] ) for exception in container.items: assert isinstance(exception, RedditErrorItem)
def test_catch(self): exc = RedditAPIException([["test", "testing", "test"]]) with pytest.raises(APIException): raise exc