HTTPConnection subclass using FakeSocket; counts connect() calls
| 118 | return data |
| 119 | |
| 120 | class FakeSocketHTTPConnection(client.HTTPConnection): |
| 121 | """HTTPConnection subclass using FakeSocket; counts connect() calls""" |
| 122 | |
| 123 | def __init__(self, *args): |
| 124 | self.connections = 0 |
| 125 | super().__init__('example.com') |
| 126 | self.fake_socket_args = args |
| 127 | self._create_connection = self.create_connection |
| 128 | |
| 129 | def connect(self): |
| 130 | """Count the number of times connect() is invoked""" |
| 131 | self.connections += 1 |
| 132 | return super().connect() |
| 133 | |
| 134 | def create_connection(self, *pos, **kw): |
| 135 | return FakeSocket(*self.fake_socket_args) |
| 136 | |
| 137 | class HeaderTests(TestCase): |
| 138 | def test_auto_headers(self): |
no outgoing calls
searching dependent graphs…