Skip to content

Commit c75074c

Browse files
committed
fix: pickling test case handle python 2
python 2 adds a __cause__ that is None to the __dict__ of the thrown error, failing the assertion
1 parent 5668df9 commit c75074c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

tests/test_unit.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,26 @@ def test_pickle_error(self, mock_lib):
222222
except UnauthorizedError as e:
223223
pickled_error = pickle.dumps(e)
224224
unpickled_error = pickle.loads(pickled_error)
225-
self.assertDictEqual(
226-
e.__dict__,
227-
unpickled_error.__dict__,
228-
"original error and unpickled error must have the same state"
225+
226+
self.assertEqual(
227+
e.status_code,
228+
unpickled_error.status_code,
229+
"unpickled error must have the same status code",
230+
)
231+
self.assertEqual(
232+
e.reason,
233+
unpickled_error.reason,
234+
"unpickled error must have the same reason",
235+
)
236+
self.assertEqual(
237+
e.body,
238+
unpickled_error.body,
239+
"unpickled error must have the same body",
240+
)
241+
self.assertEqual(
242+
e.headers,
243+
unpickled_error.headers,
244+
"unpickled error must have the same headers",
229245
)
230246

231247

0 commit comments

Comments
 (0)