mirror of
https://github.com/kennethreitz/requests3.git
synced 2026-06-05 23:10:16 +00:00
Merge pull request #2617 from Lukasa/move_native_str_30
Move native string conversion to Request
This commit is contained in:
+3
-2
@@ -328,8 +328,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 = 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."""
|
||||
|
||||
@@ -432,9 +432,6 @@ class Session(SessionRedirectMixin):
|
||||
:param cert: (optional) if String, path to ssl client cert file (.pem).
|
||||
If Tuple, ('cert', 'key') pair.
|
||||
"""
|
||||
|
||||
method = to_native_string(method)
|
||||
|
||||
# Create the Request.
|
||||
req = Request(
|
||||
method = method.upper(),
|
||||
|
||||
+12
-2
@@ -89,7 +89,7 @@ class RequestsTestCase(unittest.TestCase):
|
||||
requests.get('http://')
|
||||
|
||||
def test_basic_building(self):
|
||||
req = requests.Request()
|
||||
req = requests.Request(method='GET')
|
||||
req.url = 'http://kennethreitz.org/'
|
||||
req.data = {'life': '42'}
|
||||
|
||||
@@ -813,7 +813,7 @@ class RequestsTestCase(unittest.TestCase):
|
||||
assert ('user', 'pass#pass') == requests.utils.get_auth_from_url(url)
|
||||
|
||||
def test_cannot_send_unprepared_requests(self):
|
||||
r = requests.Request(url=HTTPBIN)
|
||||
r = requests.Request(method='GET', url=HTTPBIN)
|
||||
with pytest.raises(ValueError):
|
||||
requests.Session().send(r)
|
||||
|
||||
@@ -1617,6 +1617,16 @@ def test_prepare_unicode_url():
|
||||
assert_copy(p, p.copy())
|
||||
|
||||
|
||||
def test_prepare_requires_a_request_method():
|
||||
req = requests.Request()
|
||||
with pytest.raises(ValueError):
|
||||
req.prepare()
|
||||
|
||||
prepped = PreparedRequest()
|
||||
with pytest.raises(ValueError):
|
||||
prepped.prepare()
|
||||
|
||||
|
||||
def test_urllib3_retries():
|
||||
from requests.packages.urllib3.util import Retry
|
||||
s = requests.Session()
|
||||
|
||||
Reference in New Issue
Block a user