aboutsummaryrefslogtreecommitdiff
path: root/test/test_exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_exceptions.py')
-rw-r--r--test/test_exceptions.py45
1 files changed, 28 insertions, 17 deletions
diff --git a/test/test_exceptions.py b/test/test_exceptions.py
index e20649b..4190a61 100644
--- a/test/test_exceptions.py
+++ b/test/test_exceptions.py
@@ -11,25 +11,36 @@ from urllib3.connectionpool import HTTPConnectionPool
class TestPickle(unittest.TestCase):
- def cycle(self, item):
+ def verify_pickling(self, item):
return pickle.loads(pickle.dumps(item))
def test_exceptions(self):
- assert self.cycle(HTTPError(None))
- assert self.cycle(MaxRetryError(None, None, None))
- assert self.cycle(LocationParseError(None))
- assert self.cycle(ConnectTimeoutError(None))
+ assert self.verify_pickling(HTTPError(None))
+ assert self.verify_pickling(MaxRetryError(None, None, None))
+ assert self.verify_pickling(LocationParseError(None))
+ assert self.verify_pickling(ConnectTimeoutError(None))
def test_exceptions_with_objects(self):
- assert self.cycle(HTTPError('foo'))
- assert self.cycle(MaxRetryError(HTTPConnectionPool('localhost'),
- '/', None))
- assert self.cycle(LocationParseError('fake location'))
- assert self.cycle(ClosedPoolError(HTTPConnectionPool('localhost'),
- None))
- assert self.cycle(EmptyPoolError(HTTPConnectionPool('localhost'),
- None))
- assert self.cycle(HostChangedError(HTTPConnectionPool('localhost'),
- '/', None))
- assert self.cycle(ReadTimeoutError(HTTPConnectionPool('localhost'),
- '/', None))
+ assert self.verify_pickling(
+ HTTPError('foo'))
+
+ assert self.verify_pickling(
+ HTTPError('foo', IOError('foo')))
+
+ assert self.verify_pickling(
+ MaxRetryError(HTTPConnectionPool('localhost'), '/', None))
+
+ assert self.verify_pickling(
+ LocationParseError('fake location'))
+
+ assert self.verify_pickling(
+ ClosedPoolError(HTTPConnectionPool('localhost'), None))
+
+ assert self.verify_pickling(
+ EmptyPoolError(HTTPConnectionPool('localhost'), None))
+
+ assert self.verify_pickling(
+ HostChangedError(HTTPConnectionPool('localhost'), '/', None))
+
+ assert self.verify_pickling(
+ ReadTimeoutError(HTTPConnectionPool('localhost'), '/', None))