(self, *args, **kwargs)
| 127 | self.success_data = success_data |
| 128 | |
| 129 | def request(self, *args, **kwargs): |
| 130 | if not self.num_errors: |
| 131 | return httplib2.Response(self.success_json), self.success_data |
| 132 | elif self.num_errors == 5: |
| 133 | ex = ConnectionResetError # noqa: F821 |
| 134 | elif self.num_errors == 4: |
| 135 | ex = httplib2.ServerNotFoundError() |
| 136 | elif self.num_errors == 3: |
| 137 | ex = OSError() |
| 138 | ex.errno = socket.errno.EPIPE |
| 139 | elif self.num_errors == 2: |
| 140 | ex = ssl.SSLError() |
| 141 | else: |
| 142 | # Initialize the timeout error code to the platform's error code. |
| 143 | try: |
| 144 | # For Windows: |
| 145 | ex = OSError() |
| 146 | ex.errno = socket.errno.WSAETIMEDOUT |
| 147 | except AttributeError: |
| 148 | # For Linux/Mac: |
| 149 | ex = socket.timeout() |
| 150 | |
| 151 | self.num_errors -= 1 |
| 152 | raise ex |
| 153 | |
| 154 | |
| 155 | class HttpMockWithNonRetriableErrors(object): |
no outgoing calls
no test coverage detected