Merge pull request #19 from nvllsvm/str

Cast url to str
This commit is contained in:
Andrew Rabert 2019-05-07 11:12:25 -04:00 committed by GitHub
commit f5ea3ccb8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -338,7 +338,7 @@ class HTTPClientMixin:
request_headers['X-Retry-Attempt'] = str(attempt + 1)
try:
resp = await client.fetch(
url,
str(url),
method=method,
headers=request_headers,
body=body,

View file

@ -557,3 +557,19 @@ class MixinTestCase(testing.AsyncHTTPTestCase):
self.assertEqual(response.code, 429)
self.assertEqual(response.attempts, 1)
self.assertEqual([r.code for r in response.history], [429])
@testing.gen_test
def test_str_url(self):
class MyURL:
def __init__(self, url):
self._url = url
def __str__(self):
return self._url
mixin = http.HTTPClientMixin()
response = yield mixin.http_fetch(
MyURL(self.get_url('/test?foo=bar&status_code=200')))
self.assertTrue(response.ok)
self.assertEqual(response.code, 200)
self.assertEqual(response.attempts, 1)