Merge commit '8c4d4f1af3a501ae0beec5e270f3206cda5c4842' into v3.0.0

This commit is contained in:
2016-02-01 23:46:26 -05:00
2 changed files with 14 additions and 3 deletions
+4 -3
View File
@@ -220,7 +220,7 @@ class Request(RequestHooksMixin):
for (k, v) in list(hooks.items()):
self.register_hook(event=k, hook=v)
self.method = to_native_string(method)
self.method = method
self.url = url
self.headers = headers
self.files = files
@@ -318,8 +318,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
def prepare_method(self, method):
"""Prepares the given HTTP method."""
self.method = method
if self.method is not None:
self.method = to_native_string(self.method.upper())
if self.method is None:
raise ValueError('Request method cannot be "None"')
self.method = to_native_string(self.method).upper()
def prepare_url(self, url, params):
"""Prepares the given HTTP URL."""
+10
View File
@@ -1738,6 +1738,16 @@ def test_prepare_unicode_url():
assert_copy(p, p.copy())
def test_prepare_requires_a_request_method():
req = Request()
with pytest.raises(ValueError):
req.prepare()
prepped = PreparedRequest()
with pytest.raises(ValueError):
prepped.prepare()
def test_urllib3_retries(httpbin):
from requests.packages.urllib3.util import Retry
s = requests.Session()