| 385 | self.do_test_default_behaviour(retry, response) |
| 386 | |
| 387 | def test_error_in_get_content(self): |
| 388 | retry = github.GithubRetry(total=3) |
| 389 | response = urllib3.response.HTTPResponse(status=403, reason="NOT GOOD") |
| 390 | |
| 391 | with mock.patch.object(retry, "_GithubRetry__log") as log: |
| 392 | with self.assertRaises(github.GithubException) as exp: |
| 393 | retry.increment("TEST", "URL", response) |
| 394 | self.assertIsNone(exp.exception.message) |
| 395 | self.assertEqual(403, exp.exception.status) |
| 396 | self.assertEqual("NOT GOOD", exp.exception.data) |
| 397 | self.assertEqual({}, exp.exception.headers) |
| 398 | |
| 399 | self.assertIsInstance(exp.exception.__cause__, RuntimeError) |
| 400 | self.assertEqual(("Failed to inspect response message",), exp.exception.__cause__.args) |
| 401 | |
| 402 | self.assertIsInstance(exp.exception.__cause__.__cause__, ValueError) |
| 403 | self.assertEqual( |
| 404 | ("Unable to determine whether fp is closed.",), |
| 405 | exp.exception.__cause__.__cause__.args, |
| 406 | ) |
| 407 | |
| 408 | log.assert_called_once_with(logging.INFO, "Request TEST URL failed with 403: NOT GOOD") |