コード例 #1
0
ファイル: tests.py プロジェクト: ut-adamc/https_shim
 def _create(self, host, port, ssl_version=None):
     if ssl_version is None:
         conn = HTTPSConnection(host, port, timeout=120)
         conn.set_debuglevel(1)
     else:
         conn = HTTPSConnection(host, port, ssl_version=ssl_version)
     return conn
コード例 #2
0
ファイル: tests.py プロジェクト: ut-adamc/https_shim
 def test_ssl_version_in_init_is_used_in_connect(self):
     version = Mock()
         
     with patch.object(HTTPSConnection, '_connect_with_ssl_version')\
         as mock:
         conn = HTTPSConnection('httpbin.org', '443')
         conn.connect(ssl_version=version)
         mock.assert_called_with(version)
コード例 #3
0
ファイル: tests.py プロジェクト: ut-adamc/https_shim
    def test_ssl_version_in_init_is_used_in_request(self):
        version = Mock()
        real_method = HTTPSConnection._connect_with_ssl_version
        
        with patch.object(HTTPSConnection, '_connect_with_ssl_version')\
            as mock:
            conn = HTTPSConnection('httpbin.org', '443', ssl_version=version)
            # request will attempt to make the call, so we need to keep
            # it from failing
            def side_effect(version):
                return real_method(conn, ssl.PROTOCOL_TLSv1)

            mock.side_effect = side_effect
            
            conn.request('GET', '/get?foo=bar')
            mock.assert_called_with(version)