File: test_no_socket.py

package info (click to toggle)
python-httplib2 0.22.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,448 kB
  • sloc: python: 6,629; javascript: 3,563; makefile: 56
file content (25 lines) | stat: -rw-r--r-- 661 bytes parent folder | download | duplicates (8)
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
"""Tests for httplib2 when the socket module is missing.

This helps ensure compatibility with environments such as AppEngine.
"""
import os
import sys
import unittest

import httplib2


class MissingSocketTest(unittest.TestCase):
    def setUp(self):
        self._oldsocks = httplib2.socks
        httplib2.socks = None

    def tearDown(self):
        httplib2.socks = self._oldsocks

    def testProxyDisabled(self):
        proxy_info = httplib2.ProxyInfo("blah", "localhost", 0)
        client = httplib2.Http(proxy_info=proxy_info)
        self.assertRaises(
            httplib2.ProxiesUnavailableError, client.request, "http://localhost:-1/"
        )