Skip to content

Support pickling AuthClientError #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion intuitlib/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import requests

class AuthClientError(Exception):
"""AuthClient Error object in case API response status != 200
Expand All @@ -33,3 +32,6 @@ def __init__(self, response):
self.timestamp = response.headers.get('Date', None)

Exception.__init__(self, 'HTTP status {0}, error message: {1}, intuit_tid {2} at time {3}'.format(self.status_code, self.content, self.intuit_tid, self.timestamp))

def __reduce__(self):
return self.__class__, (self.response,)
13 changes: 13 additions & 0 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pickle

from intuitlib.exceptions import AuthClientError
from tests.helper import MockResponse


class TestExceptions:
def mock_request(self, status=200, content=None):
return MockResponse(status=status, content=content)

def test_authclienterror_is_pickleable(self):
error = AuthClientError(self.mock_request(404))
pickle.dumps(error)