File: test_no_ssl.py

package info (click to toggle)
python-urllib3 1.16-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 1,376 kB
  • sloc: python: 9,448; makefile: 152
file content (29 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Test connections without the builtin ssl module

Note: Import urllib3 inside the test functions to get the importblocker to work
"""
from ..test_no_ssl import TestWithoutSSL

from dummyserver.testcase import (
        HTTPDummyServerTestCase, HTTPSDummyServerTestCase)


class TestHTTPWithoutSSL(HTTPDummyServerTestCase, TestWithoutSSL):
    def test_simple(self):
        import urllib3

        pool = urllib3.HTTPConnectionPool(self.host, self.port)
        r = pool.request('GET', '/')
        self.assertEqual(r.status, 200, r.data)


class TestHTTPSWithoutSSL(HTTPSDummyServerTestCase, TestWithoutSSL):
    def test_simple(self):
        import urllib3

        pool = urllib3.HTTPSConnectionPool(self.host, self.port)
        try:
            pool.request('GET', '/')
        except urllib3.exceptions.SSLError as e:
            self.assertTrue('SSL module is not available' in str(e))