summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-11-23 17:42:45 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-11-23 17:42:45 (GMT)
commitfcfb18ee2b754368ff005a3fec8a9fe7930ccf7d (patch)
treed0ec3069e6f10073b55fca4ebf710a8da6123b1f /Lib/test/test_urllib2.py
parent5f6b89bda3cc9797186c567b6be5c6d8feedb3ec (diff)
downloadcpython-fcfb18ee2b754368ff005a3fec8a9fe7930ccf7d.zip
cpython-fcfb18ee2b754368ff005a3fec8a9fe7930ccf7d.tar.gz
cpython-fcfb18ee2b754368ff005a3fec8a9fe7930ccf7d.tar.bz2
allow passing cert/ssl information to urllib2.urlopen and httplib.HTTPSConnection
This is basically a backport of issues #9003 and #22366.
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 39a0132..5b2c708 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -8,6 +8,11 @@ import StringIO
import urllib2
from urllib2 import Request, OpenerDirector
+try:
+ import ssl
+except ImportError:
+ ssl = None
+
# XXX
# Request
# CacheFTPHandler (hard to write)
@@ -47,6 +52,14 @@ class TrivialTests(unittest.TestCase):
for string, list in tests:
self.assertEqual(urllib2.parse_http_list(string), list)
+ @unittest.skipUnless(ssl, "ssl module required")
+ def test_cafile_and_context(self):
+ context = ssl.create_default_context()
+ with self.assertRaises(ValueError):
+ urllib2.urlopen(
+ "https://localhost", cafile="/nonexistent/path", context=context
+ )
+
def test_request_headers_dict():
"""