mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #3108 from kevinburke/flip-conditional
Flip conditional in session.send()
This commit is contained in:
@@ -557,7 +557,7 @@ class Session(SessionRedirectMixin):
|
||||
|
||||
# It's possible that users might accidentally send a Request object.
|
||||
# Guard against that specific failure case.
|
||||
if not isinstance(request, PreparedRequest):
|
||||
if isinstance(request, Request):
|
||||
raise ValueError('You can only send PreparedRequests.')
|
||||
|
||||
# Set up variables needed for resolve_redirects and dispatching of hooks
|
||||
|
||||
@@ -638,6 +638,14 @@ class TestRequests:
|
||||
resp = s.send(prep)
|
||||
assert resp.status_code == 200
|
||||
|
||||
def test_non_prepared_request_error(self):
|
||||
s = requests.Session()
|
||||
req = requests.Request(u('POST'), '/')
|
||||
|
||||
with pytest.raises(ValueError) as e:
|
||||
s.send(req)
|
||||
assert str(e.value) == 'You can only send PreparedRequests.'
|
||||
|
||||
def test_custom_content_type(self, httpbin):
|
||||
r = requests.post(
|
||||
httpbin('post'),
|
||||
|
||||
Reference in New Issue
Block a user